Commit d1419b6e authored by 王海's avatar 王海

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/src/main/AndroidManifest.xml
parents fbdd9024 12c81300
...@@ -3,11 +3,13 @@ ...@@ -3,11 +3,13 @@
<words> <words>
<w>baozheng</w> <w>baozheng</w>
<w>caocao</w> <w>caocao</w>
<w>exps</w>
<w>guanyu</w> <w>guanyu</w>
<w>huanggai</w> <w>huanggai</w>
<w>inputer</w> <w>inputer</w>
<w>likui</w> <w>likui</w>
<w>mawu</w> <w>mawu</w>
<w>patt</w>
<w>xishi</w> <w>xishi</w>
<w>zhangfei</w> <w>zhangfei</w>
<w>zhouyu</w> <w>zhouyu</w>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
android:configChanges="keyboard|orientation|screenSize|keyboardHidden" android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:label="@string/main_title" android:label="@string/main_title"
android:launchMode="singleTask" android:launchMode="singleTask"
android:windowSoftInputMode="adjustUnspecified|stateHidden"> android:windowSoftInputMode="adjustUnspecified|stateHidden" >
</activity> </activity>
<activity <activity
...@@ -36,16 +36,16 @@ ...@@ -36,16 +36,16 @@
<activity <activity
android:name=".ui.login.LoginActivity" android:name=".ui.login.LoginActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden" android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:windowSoftInputMode="adjustUnspecified|stateHidden"/> android:windowSoftInputMode="adjustUnspecified|stateHidden" />
<activity <activity
android:name=".ui.exception.ErrorDialogActivity" android:name=".ui.exception.ErrorDialogActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden" android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:theme="@style/Theme.AppCompat.Light.Dialog"/> android:theme="@style/Theme.AppCompat.Light.Dialog" />
<activity <activity
android:name=".ui.exception.ServerErrActivity" android:name=".ui.exception.ServerErrActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden" android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:theme="@style/Theme.AppCompat.Light.Dialog"/> android:theme="@style/Theme.AppCompat.Light.Dialog" />
<activity <activity
android:name=".ui.payment.PaymentActivity" android:name=".ui.payment.PaymentActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden" android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
......
...@@ -10,5 +10,11 @@ interface PaymentContract { ...@@ -10,5 +10,11 @@ interface PaymentContract {
} }
abstract class Presenter extends BasePresenter<PaymentContract.View> { abstract class Presenter extends BasePresenter<PaymentContract.View> {
/**
* 收款界面 - 点击收款
*
* @param amt 金额
*/
public abstract void clickSettle(Long amt);
} }
} }
\ No newline at end of file
...@@ -5,4 +5,9 @@ public class PaymentPresenter extends PaymentContract.Presenter { ...@@ -5,4 +5,9 @@ public class PaymentPresenter extends PaymentContract.Presenter {
@Override @Override
public void onAttached() { public void onAttached() {
} }
@Override
public void clickSettle(Long amt) {
}
} }
package com.xingdata.zzdpos.ui.payment.fragment; package com.xingdata.zzdpos.ui.payment.fragment;
import com.blankj.utilcode.util.LogUtils;
import com.xingdata.zzdpos.R; import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseFragment; import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.databinding.FragmentPaymentBinding; import com.xingdata.zzdpos.databinding.FragmentPaymentBinding;
...@@ -21,13 +20,14 @@ public class PaymentFragment extends BaseFragment<PaymentPresenter, FragmentPaym ...@@ -21,13 +20,14 @@ public class PaymentFragment extends BaseFragment<PaymentPresenter, FragmentPaym
public void initView() { public void initView() {
loadRootFragment(R.id.f_inputer, mCalculatorView); loadRootFragment(R.id.f_inputer, mCalculatorView);
mCalculatorView.setmOnResultChangeListener((exp, result) -> { mCalculatorView.setOnResultChangeListener((exp, result) -> {
LogUtils.e(exp + "\n" + result);
mViewBinding.tvExp.setText(exp); mViewBinding.tvExp.setText(exp);
mViewBinding.tvResult.setText(ConvertUtil.fenToYuan(result)); String strResult = ConvertUtil.fenToYuan(result);
mViewBinding.tvResult.setText(strResult);
mViewBinding.tvAmt.setText(strResult);
}); });
mCalculatorView.setmOnSettleClickListener(result -> { mCalculatorView.setOnSettleClickListener(result -> {
LogUtils.e(ConvertUtil.fenToYuan(result)); if (result > 0) mPresenter.clickSettle(result);
}); });
} }
} }
...@@ -48,13 +48,13 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato ...@@ -48,13 +48,13 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato
public void initView() { public void initView() {
View.OnClickListener mOnClickListener = view -> { View.OnClickListener mOnClickListener = view -> {
switch (view.getId()) { switch (view.getId()) {
case R.id.btn_del: case R.id.tv_del:
delete(); delete();
break; break;
case R.id.btn_clear: case R.id.tv_clear:
clear(); clear();
break; break;
case R.id.btn_settle: case R.id.tv_settle:
settle(); settle();
break; break;
default: default:
...@@ -64,20 +64,20 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato ...@@ -64,20 +64,20 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato
String[] mExps = mExp.split("[+\\-×÷]"); String[] mExps = mExp.split("[+\\-×÷]");
if (mExps.length > 1) mValue = mExps[mExps.length - 1]; if (mLast.matches("[+\\-×÷]")) mValue = "";
else mValue = mExp; else if (mExps.length > 1) mValue = mExps[mExps.length - 1];
else mValue = mExp.replaceAll("[+\\-×÷]", "");
if (mLast.matches("[+\\-×÷.]") && str.matches("[+\\-×÷.]")) return; //限制位数
if (str.matches("[0-9]+") && mValue.split("[.]").length > 1 && mValue.split("[.]")[1].length() == 2)
return;
//限制小数点
if ((mExp.length() == 0 || mValue.contains(".")) && str.matches("[.]"))
return;
//限制符号
if (mLast.matches("[+\\-×÷.]") && str.matches("[+\\-×÷.]"))
return;
if (mValue.length() > 0 && str.matches("[+\\-×÷]")) {
mValue = "";
} else {
if (mValue.length() == 0 && str.matches("[+\\-×÷]")) return;
if (mValue.contains(".") && str.matches("[+\\-×÷.]")) return;
if (mValue.split("[.]").length > 1 && mValue.split("[.]")[1].length() > 2)
return;
if (mValue.length() == 0 && str.equals(".")) mExp += "0";
}
mLast = str; mLast = str;
mExp += str; mExp += str;
...@@ -97,7 +97,8 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato ...@@ -97,7 +97,8 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato
private void delete() { private void delete() {
if (mExp.length() > 0) { if (mExp.length() > 0) {
mExp = mExp.substring(0, mExp.length() - 1); mExp = mExp.substring(0, mExp.length() - 1);
mLast = mExp.substring(mExp.length() - 1, mExp.length()); if (mExp.length() > 0) mLast = mExp.substring(mExp.length() - 1, mExp.length());
else mLast = "";
} }
} }
...@@ -196,11 +197,12 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato ...@@ -196,11 +197,12 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato
} }
public void setmOnResultChangeListener(OnResultChangeListener mOnResultChangeListener) { public void setOnResultChangeListener(OnResultChangeListener onResultChangeListener) {
this.mOnResultChangeListener = mOnResultChangeListener; this.mOnResultChangeListener = onResultChangeListener;
mOnResultChangeListener.onResultChange(mExp, ConvertUtil.yuanToFen(parseExp(mExp)));
} }
public void setmOnSettleClickListener(onSettleClickListener mOnSettleClickListener) { public void setOnSettleClickListener(onSettleClickListener onSettleClickListener) {
this.mOnSettleClickListener = mOnSettleClickListener; this.mOnSettleClickListener = onSettleClickListener;
} }
} }
...@@ -71,7 +71,8 @@ public class ConvertUtil { ...@@ -71,7 +71,8 @@ public class ConvertUtil {
*/ */
public static Long yuanToFen(String yuan) { public static Long yuanToFen(String yuan) {
yuan = StringUtils.isEmpty(yuan) ? "0" : yuan; yuan = StringUtils.isEmpty(yuan) ? "0" : yuan;
return (long) (Double.valueOf(yuan) * 100); BigDecimal b = new BigDecimal(Double.valueOf(yuan) * 100);
return b.setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
} }
/** /**
...@@ -95,11 +96,11 @@ public class ConvertUtil { ...@@ -95,11 +96,11 @@ public class ConvertUtil {
if (l == null) return "0"; if (l == null) return "0";
return String.valueOf(l); return String.valueOf(l);
} }
/** /**
* 分转元去掉.0 ROUND_DOWN * 分转元去掉.0 ROUND_DOWN
* *
* @param fen * @param fen 分
* 分
* @return 元 * @return 元
*/ */
public static String fenToYuanNoZero(Long fen) { public static String fenToYuanNoZero(Long fen) {
...@@ -121,13 +122,11 @@ public class ConvertUtil { ...@@ -121,13 +122,11 @@ public class ConvertUtil {
/** /**
* 分转元保留2位小數 * 分转元保留2位小數
* *
* @param fen * @param fen 分
* 分
* @return 元 * @return 元
*/ */
public static String fenToYuan2(Long fen) { public static String fenToYuan2(Long fen) {
if (fen==null) if (fen == null) {
{
return "0.00"; return "0.00";
} }
BigDecimal decimal = new BigDecimal(fen); BigDecimal decimal = new BigDecimal(fen);
...@@ -137,8 +136,7 @@ public class ConvertUtil { ...@@ -137,8 +136,7 @@ public class ConvertUtil {
/** /**
* 折扣率转换最大100 * 折扣率转换最大100
* *
* @param dis * @param dis 分
* 分
* @return 元 * @return 元
*/ */
public static String discount(Long dis) { public static String discount(Long dis) {
......
...@@ -6,12 +6,31 @@ ...@@ -6,12 +6,31 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<Toolbar <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="?attr/actionBarSize"
android:background="@color/store_product_bg" android:background="@color/black_zhangfei">
android:title="收款"
android:titleTextColor="@color/white" /> <ImageButton
android:layout_width="@dimen/title_height"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/all_go_back"
android:gravity="center"
android:padding="@dimen/all_margin"
android:src="@mipmap/back_white" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/payment_title"
android:textColor="@color/white_caocao"
android:textSize="@dimen/all_sub_title_size" />
</FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/f_payment" android:id="@+id/f_payment"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout> <layout xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/gray_zhouyu"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <android.support.constraint.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="3" android:layout_weight="3"
android:background="@color/store_product_bg" android:background="@color/black_zhangfei"
android:orientation="vertical"> android:gravity="bottom"
android:paddingBottom="@dimen/all_margin">
<TextView <TextView
android:id="@+id/tv_exp" android:id="@+id/tv_exp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/all_spacing"
android:layout_marginEnd="@dimen/all_margin"
android:gravity="end|center_vertical"
android:textColor="@color/white_caocao"
android:textSize="@dimen/all_title_size"
app:layout_constraintBottom_toTopOf="@id/tv_result"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/tv_money_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/all_margin"
android:gravity="end|center_vertical" android:gravity="end|center_vertical"
android:textColor="@color/white_caocao" /> android:text="@string/money_rmb"
android:textColor="@color/white_caocao"
android:textSize="@dimen/fragment_settle_bigtextsize"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_result" />
<TextView <TextView
android:id="@+id/tv_result" android:id="@+id/tv_result"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/all_margin"
android:gravity="end|center_vertical" android:gravity="end|center_vertical"
android:textColor="@color/white_caocao" /> android:textColor="@color/white_caocao"
</LinearLayout> android:textSize="@dimen/fragment_settle_bigtextsize"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/tv_money_hint"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/white" android:background="@color/white_caocao"
android:gravity="end|center_vertical" android:gravity="end|center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="小计:" /> android:layout_marginEnd="@dimen/all_spacing"
android:text="@string/payment_total"
android:textSize="@dimen/all_text_size" />
<TextView <TextView
android:id="@+id/tv_amt"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="40.00" android:layout_marginEnd="@dimen/all_margin"
android:textColor="@color/deep_red" /> android:textColor="@color/deep_red"
android:textSize="@dimen/all_sub_title_size" />
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/all_line_width"
android:layout_marginBottom="@dimen/all_margin_big"
android:background="@color/gray_huanggai" />
<FrameLayout <FrameLayout
android:id="@+id/f_inputer" android:id="@+id/f_inputer"
android:layout_width="match_parent" android:layout_width="match_parent"
......
This diff is collapsed.
...@@ -489,5 +489,9 @@ ...@@ -489,5 +489,9 @@
<string name="inputer_mul">×</string> <string name="inputer_mul">×</string>
<string name="inputer_div">÷</string> <string name="inputer_div">÷</string>
<!--收款-->
<string name="payment_title">收款</string>
<string name="payment_total">总计:</string>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment