Commit 7be3a603 authored by zhang_z's avatar zhang_z

提交新颜色;

修改PaymentFragment;
parent b4f7f4dc
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<w>baozheng</w> <w>baozheng</w>
<w>caocao</w> <w>caocao</w>
<w>guanyu</w> <w>guanyu</w>
<w>huanggai</w>
<w>inputer</w> <w>inputer</w>
<w>likui</w> <w>likui</w>
<w>mawu</w> <w>mawu</w>
......
...@@ -24,11 +24,7 @@ ...@@ -24,11 +24,7 @@
android:name=".ui.splash.SplashActivity" android:name=".ui.splash.SplashActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden" android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> </activity>
<activity <activity
android:name=".ui.login.LoginActivity" android:name=".ui.login.LoginActivity"
...@@ -45,7 +41,13 @@ ...@@ -45,7 +41,13 @@
<activity <activity
android:name=".ui.payment.PaymentActivity" android:name=".ui.payment.PaymentActivity"
android:configChanges="keyboard|orientation|screenSize|keyboardHidden" android:configChanges="keyboard|orientation|screenSize|keyboardHidden"
android:windowSoftInputMode="adjustUnspecified|stateHidden" /> android:windowSoftInputMode="adjustUnspecified|stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -69,8 +69,8 @@ public class App extends Application { ...@@ -69,8 +69,8 @@ public class App extends Application {
.callback(this) .callback(this)
.start(); .start();
// 初始化异常处理 // 初始化异常处理
initEx(); // initEx();
//初始化Fragment框架 //初始化Fragment框架
initFragment(); initFragment();
...@@ -147,8 +147,6 @@ public class App extends Application { ...@@ -147,8 +147,6 @@ public class App extends Application {
} }
public static void reStartApp() { public static void reStartApp() {
// 重启 // 重启
Intent intent = new Intent(instance.getApplicationContext(), SplashActivity Intent intent = new Intent(instance.getApplicationContext(), SplashActivity
......
...@@ -3,9 +3,12 @@ package com.xingdata.zzdpos.ui.payment; ...@@ -3,9 +3,12 @@ package com.xingdata.zzdpos.ui.payment;
import com.xingdata.zzdpos.R; import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseActivity; import com.xingdata.zzdpos.base.BaseActivity;
import com.xingdata.zzdpos.databinding.ActivityPaymentBinding; import com.xingdata.zzdpos.databinding.ActivityPaymentBinding;
import com.xingdata.zzdpos.ui.payment.fragment.PaymentFragment;
public class PaymentActivity extends BaseActivity<PaymentPresenter, ActivityPaymentBinding> implements PaymentContract.View { public class PaymentActivity extends BaseActivity<PaymentPresenter, ActivityPaymentBinding> implements PaymentContract.View {
private PaymentFragment mPaymentFragment = new PaymentFragment();
@Override @Override
public int getLayoutId() { public int getLayoutId() {
return R.layout.activity_payment; return R.layout.activity_payment;
...@@ -13,6 +16,7 @@ public class PaymentActivity extends BaseActivity<PaymentPresenter, ActivityPaym ...@@ -13,6 +16,7 @@ public class PaymentActivity extends BaseActivity<PaymentPresenter, ActivityPaym
@Override @Override
public void initView() { public void initView() {
loadRootFragment(R.id.f_payment, mPaymentFragment);
} }
} }
//package com.xingdata.zzdpos.ui.payment.fragment;
//
//import com.xingdata.zzdpos.base.BaseFragment;
//import com.xingdata.zzdpos.ui.payment.PaymentPresenter;
//
///**
// * Created by Eurus on 2017/12/21.
// */
//
//public class CalculatorFragment extends BaseFragment<PaymentPresenter,> {
//}
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;
import com.xingdata.zzdpos.ui.payment.PaymentPresenter;
import com.xingdata.zzdpos.ui.payment.view.CalculatorView;
import com.xingdata.zzdpos.util.ConvertUtil;
public class PaymentFragment extends BaseFragment<PaymentPresenter, FragmentPaymentBinding> {
private CalculatorView mCalculatorView = new CalculatorView();
@Override
public int getLayoutId() {
return R.layout.fragment_payment;
}
@Override
public void initView() {
loadRootFragment(R.id.f_inputer, mCalculatorView);
mCalculatorView.setmOnResultChangeListener((exp, result) -> {
LogUtils.e(exp + "\n" + result);
});
mCalculatorView.setmOnSettleClickListener(result -> {
LogUtils.e(ConvertUtil.fenToYuan(result));
});
}
}
...@@ -2,6 +2,7 @@ package com.xingdata.zzdpos.ui.payment.view; ...@@ -2,6 +2,7 @@ package com.xingdata.zzdpos.ui.payment.view;
import android.view.View; import android.view.View;
import android.widget.TextView;
import com.xingdata.zzdpos.R; import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseFragment; import com.xingdata.zzdpos.base.BaseFragment;
...@@ -16,9 +17,17 @@ import java.util.regex.Pattern; ...@@ -16,9 +17,17 @@ import java.util.regex.Pattern;
public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculatorBinding> { public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculatorBinding> {
private String mExp; private String mExp;
private String mValue;
private OnResultChangeListener mOnResultChangeListener; private OnResultChangeListener mOnResultChangeListener;
private onSettleClickListener mOnSettleClickListener; private onSettleClickListener mOnSettleClickListener;
public CalculatorView() {
mExp = "";
mValue = "";
}
public interface OnResultChangeListener { public interface OnResultChangeListener {
void onResultChange(String exp, Long result); void onResultChange(String exp, Long result);
} }
...@@ -36,16 +45,6 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato ...@@ -36,16 +45,6 @@ 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_add:
break;
case R.id.btn_sub:
break;
case R.id.btn_mul:
break;
case R.id.btn_div:
break;
case R.id.btn_point:
break;
case R.id.btn_del: case R.id.btn_del:
delete(); delete();
break; break;
...@@ -55,13 +54,34 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato ...@@ -55,13 +54,34 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato
case R.id.btn_settle: case R.id.btn_settle:
settle(); settle();
break; break;
default:
if (view instanceof TextView) {
String str = ((TextView) view).getText().toString();
if (mExp.length() == 0 && str.matches("[+\\-*/]")) return;
if (mExp.length() == 0 && str.equals(".")) mExp += "0";
if (mValue.length() > 0 && str.matches("[+\\-*/]")) {
mValue = "";
} else {
if (mValue.contains(".") && str.matches("[.]")) return;
mValue += str;
String[] _values = mValue.split("[.]");
if (_values.length > 1) {
if (_values[1].length() > 2) return;
}
}
mExp += str;
}
break;
} }
if (mOnResultChangeListener != null) { if (mOnResultChangeListener != null) {
mOnResultChangeListener.onResultChange(mExp, ConvertUtil.yuanToFen(parseExp(mExp))); mOnResultChangeListener.onResultChange(mExp, ConvertUtil.yuanToFen(parseExp(mExp)));
} }
}; };
mViewBinding.setOnClick(mOnClickListener); mViewBinding.setOnClick(mOnClickListener);
} }
/** /**
...@@ -106,7 +126,7 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato ...@@ -106,7 +126,7 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato
if (exp.matches(minExp)) { if (exp.matches(minExp)) {
String result = calculate(exp); String result = calculate(exp);
return Double.parseDouble(result) >= 0 ? result : "[" + result + "]"; return Double.parseDouble(result) >= 0 ? result : "[" + result + "]";
} else if (exp.matches("[0-9]+")) { } else if (exp.matches("[0-9.]+")) {
return exp; return exp;
} else if (exp.length() == 0) { } else if (exp.length() == 0) {
return "0"; return "0";
...@@ -131,7 +151,7 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato ...@@ -131,7 +151,7 @@ public class CalculatorView extends BaseFragment<PaymentPresenter, ViewCalculato
} }
return parseExp(exp); return parseExp(exp);
} }
String minParentheses = "\\([^\\(\\)]+\\)"; String minParentheses = "\\([^()]+\\)";
Pattern patt = Pattern.compile(minParentheses); Pattern patt = Pattern.compile(minParentheses);
Matcher mat = patt.matcher(exp); Matcher mat = patt.matcher(exp);
if (mat.find()) { if (mat.find()) {
......
...@@ -13,40 +13,9 @@ ...@@ -13,40 +13,9 @@
android:title="收款" android:title="收款"
android:titleTextColor="@color/white" /> android:titleTextColor="@color/white" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@color/store_product_bg"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/white"
android:gravity="end|center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="小计:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="40.00"
android:textColor="@color/deep_red" />
</LinearLayout>
<FrameLayout <FrameLayout
android:id="@+id/f_payment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent" />
android:layout_weight="7" />
</LinearLayout> </LinearLayout>
</layout> </layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@color/store_product_bg"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/white"
android:gravity="end|center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="小计:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="40.00"
android:textColor="@color/deep_red" />
</LinearLayout>
<FrameLayout
android:id="@+id/f_inputer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="7" />
</LinearLayout>
</layout>
\ No newline at end of file
...@@ -119,6 +119,7 @@ ...@@ -119,6 +119,7 @@
<color name="red_guanyu">#b4282d</color> <color name="red_guanyu">#b4282d</color>
<color name="red_xishi">#e57b7b</color> <color name="red_xishi">#e57b7b</color>
<color name="gray_zhouyu">#f1f3f7</color> <color name="gray_zhouyu">#f1f3f7</color>
<color name="gray_huanggai">#afb9c3</color>
<color name="white_caocao">#ffffff</color> <color name="white_caocao">#ffffff</color>
<color name="black_zhangfei">#233142</color> <color name="black_zhangfei">#233142</color>
<color name="black_baozheng">#121212</color> <color name="black_baozheng">#121212</color>
......
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