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 @@
<words>
<w>baozheng</w>
<w>caocao</w>
<w>exps</w>
<w>guanyu</w>
<w>huanggai</w>
<w>inputer</w>
<w>likui</w>
<w>mawu</w>
<w>patt</w>
<w>xishi</w>
<w>zhangfei</w>
<w>zhouyu</w>
......
......@@ -19,7 +19,7 @@
android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:label="@string/main_title"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustUnspecified|stateHidden">
android:windowSoftInputMode="adjustUnspecified|stateHidden" >
</activity>
<activity
......@@ -36,16 +36,16 @@
<activity
android:name=".ui.login.LoginActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:windowSoftInputMode="adjustUnspecified|stateHidden"/>
android:windowSoftInputMode="adjustUnspecified|stateHidden" />
<activity
android:name=".ui.exception.ErrorDialogActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:theme="@style/Theme.AppCompat.Light.Dialog"/>
android:theme="@style/Theme.AppCompat.Light.Dialog" />
<activity
android:name=".ui.exception.ServerErrActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:theme="@style/Theme.AppCompat.Light.Dialog"/>
android:theme="@style/Theme.AppCompat.Light.Dialog" />
<activity
android:name=".ui.payment.PaymentActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
......
......@@ -10,5 +10,11 @@ interface PaymentContract {
}
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 {
@Override
public void onAttached() {
}
@Override
public void clickSettle(Long amt) {
}
}
package com.xingdata.zzdpos.ui.payment.fragment;
import com.blankj.utilcode.util.LogUtils;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.databinding.FragmentPaymentBinding;
......@@ -21,13 +20,14 @@ public class PaymentFragment extends BaseFragment<PaymentPresenter, FragmentPaym
public void initView() {
loadRootFragment(R.id.f_inputer, mCalculatorView);
mCalculatorView.setmOnResultChangeListener((exp, result) -> {
LogUtils.e(exp + "\n" + result);
mCalculatorView.setOnResultChangeListener((exp, result) -> {
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 -> {
LogUtils.e(ConvertUtil.fenToYuan(result));
mCalculatorView.setOnSettleClickListener(result -> {
if (result > 0) mPresenter.clickSettle(result);
});
}
}
......@@ -48,13 +48,13 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato
public void initView() {
View.OnClickListener mOnClickListener = view -> {
switch (view.getId()) {
case R.id.btn_del:
case R.id.tv_del:
delete();
break;
case R.id.btn_clear:
case R.id.tv_clear:
clear();
break;
case R.id.btn_settle:
case R.id.tv_settle:
settle();
break;
default:
......@@ -64,20 +64,20 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato
String[] mExps = mExp.split("[+\\-×÷]");
if (mExps.length > 1) mValue = mExps[mExps.length - 1];
else mValue = mExp;
if (mLast.matches("[+\\-×÷]")) mValue = "";
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;
mExp += str;
......@@ -97,7 +97,8 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato
private void delete() {
if (mExp.length() > 0) {
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
}
public void setmOnResultChangeListener(OnResultChangeListener mOnResultChangeListener) {
this.mOnResultChangeListener = mOnResultChangeListener;
public void setOnResultChangeListener(OnResultChangeListener onResultChangeListener) {
this.mOnResultChangeListener = onResultChangeListener;
mOnResultChangeListener.onResultChange(mExp, ConvertUtil.yuanToFen(parseExp(mExp)));
}
public void setmOnSettleClickListener(onSettleClickListener mOnSettleClickListener) {
this.mOnSettleClickListener = mOnSettleClickListener;
public void setOnSettleClickListener(onSettleClickListener onSettleClickListener) {
this.mOnSettleClickListener = onSettleClickListener;
}
}
......@@ -71,7 +71,8 @@ public class ConvertUtil {
*/
public static Long yuanToFen(String 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 {
if (l == null) return "0";
return String.valueOf(l);
}
/**
* 分转元去掉.0 ROUND_DOWN
*
* @param fen
* 分
* @param fen 分
* @return 元
*/
public static String fenToYuanNoZero(Long fen) {
......@@ -121,13 +122,11 @@ public class ConvertUtil {
/**
* 分转元保留2位小數
*
* @param fen
* 分
* @param fen 分
* @return 元
*/
public static String fenToYuan2(Long fen) {
if (fen==null)
{
if (fen == null) {
return "0.00";
}
BigDecimal decimal = new BigDecimal(fen);
......@@ -137,8 +136,7 @@ public class ConvertUtil {
/**
* 折扣率转换最大100
*
* @param dis
* 分
* @param dis 分
* @return 元
*/
public static String discount(Long dis) {
......
......@@ -6,12 +6,31 @@
android:layout_height="match_parent"
android:orientation="vertical">
<Toolbar
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/store_product_bg"
android:title="收款"
android:titleTextColor="@color/white" />
android:layout_height="?attr/actionBarSize"
android:background="@color/black_zhangfei">
<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
android:id="@+id/f_payment"
......
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_zhouyu"
android:orientation="vertical">
<LinearLayout
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@color/store_product_bg"
android:orientation="vertical">
android:background="@color/black_zhangfei"
android:gravity="bottom"
android:paddingBottom="@dimen/all_margin">
<TextView
android:id="@+id/tv_exp"
android:layout_width="match_parent"
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: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
android:id="@+id/tv_result"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/all_margin"
android:gravity="end|center_vertical"
android:textColor="@color/white_caocao" />
</LinearLayout>
android:textColor="@color/white_caocao"
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
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/white"
android:background="@color/white_caocao"
android:gravity="end|center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="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
android:id="@+id/tv_amt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="40.00"
android:textColor="@color/deep_red" />
android:layout_marginEnd="@dimen/all_margin"
android:textColor="@color/deep_red"
android:textSize="@dimen/all_sub_title_size" />
</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
android:id="@+id/f_inputer"
android:layout_width="match_parent"
......
This diff is collapsed.
......@@ -489,5 +489,9 @@
<string name="inputer_mul">×</string>
<string name="inputer_div">÷</string>
<!--收款-->
<string name="payment_title">收款</string>
<string name="payment_total">总计:</string>
</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