Pārlūkot izejas kodu

优化了一下触屏重新计时
新增logo

ccc 1 mēnesi atpakaļ
vecāks
revīzija
97ad880ba3

+ 4 - 0
BaseLibrary/src/main/java/com/hboxs/base_library/util/DrawableSelectorUtils.java

@@ -374,6 +374,10 @@ public class DrawableSelectorUtils {
             logoF = R.drawable.logo_magicjea;//magic_jea
             width = R.dimen.dp_80;
             height = R.dimen.dp_40;
+        }else if ("7765".equals(logo)){
+            logoF = R.drawable.logo_german_pro;//德国
+            width = R.dimen.dp_80;
+            height = R.dimen.dp_40;
         }
         ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
         layoutParams.width = UiUtil.getDimensionPixelRes(width);

BIN
BaseLibrary/src/main/res/drawable/logo_german_pro.png


BIN
BaseLibrary/src/main/res/drawable/logo_kiddie.png


+ 3 - 1
app/src/main/java/com/bgy/autosale/helpers/CommunicationHelper.java

@@ -23,6 +23,8 @@ import com.bgy.autosale.plc.IceCreamAgreement;
 import com.bgy.autosale.utils.IceCreamErrorUtils;
 import com.bgy.autosale.utils.PlcLog;
 import com.bgy.autosale.utils.SPUtils;
+import com.example.offpay.ictrs232.ByteUtils;
+import com.example.offpay.wmdb.WeaverUtil;
 import com.hboxs.base_library.constant.Name;
 import com.hboxs.base_library.event.ApiMessageEvent;
 import com.hboxs.base_library.event.ErrorApiMessageEvent;
@@ -285,7 +287,7 @@ public class CommunicationHelper {
                 }
             }
             // TODO 这里处理退款逻辑,需要退款的雪糕在 iceCreamOrders 内
-
+//            WeaverUtil.creditCardVendSuccess(ByteUtils.decimal2fitHex((long) 1, 4));
 
             makingIceCream = null;
             iceCreamOrders = null;

+ 2 - 1
app/src/main/java/com/bgy/autosale/payutil/MQService.java

@@ -1346,7 +1346,8 @@ public class MQService extends Service implements SendCallback, Callback<Result>
                 || "5769".equals(s) || "6894".equals(s) || "8123".equals(s) || "5217".equals(s) || "6431".equals(s)
                 || "7777".equals(s) || "8080".equals(s) || "6702".equals(s) || "7772".equals(s) || "7761".equals(s)
                 || "7773".equals(s) || "7774".equals(s) || "7786".equals(s) || "7775".equals(s) || "7754".equals(s)
-                || "0000".equals(s) || "7764".equals(s) || "5784".equals(s) || "7749".equals(s) || "7756".equals(s)) {
+                || "0000".equals(s) || "7764".equals(s) || "5784".equals(s) || "7749".equals(s) || "7756".equals(s)
+                || "7765".equals(s)) {
             Hawk.put("logo", s);
             Hawk.get("logo", "7777");
         }

+ 1 - 0
app/src/main/java/com/bgy/autosale/ui/MainActivity.java

@@ -17,6 +17,7 @@ import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentTransaction;
 import android.text.TextUtils;
 import android.util.Log;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ProgressBar;

+ 18 - 12
app/src/main/java/com/bgy/autosale/ui/base/BaseAutoExitFragment.java

@@ -28,13 +28,9 @@ public abstract class BaseAutoExitFragment extends BaseFragment {
 
     private Handler handler = new Handler(Looper.getMainLooper());
 
-    private Runnable exitRunnable = new Runnable() {
-        @Override
-        public void run() {
-            Log.d(TAG, "runexitRunnable: "+exitRunnable);
-            onTimeOutFinish();
-        }
-    };
+    private Runnable exitRunnable;
+
+    private int exitTime;
 
     @Override
     public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
@@ -74,11 +70,21 @@ public abstract class BaseAutoExitFragment extends BaseFragment {
 
     // 开始超时计时
     protected void startFinishDelay() {
-        int exitTime = getExitTime();
-        if (exitTime > 0) {
-            handler.postDelayed(exitRunnable, exitTime);
-            Log.d(TAG, "startFinishDelay: "+exitTime);
-        }
+        exitTime = getExitTime();
+        exitRunnable = new Runnable() {
+            @Override
+            public void run() {
+                if (exitTime > 0) {
+                    exitTime--;
+                    handler.postDelayed(exitRunnable, 1000);
+                    Log.d(TAG, "startFinishDelay: " + exitTime);
+                } else {
+                    // 倒计时结束后的处理
+                    onTimeOutFinish();
+                }
+            }
+        };
+        handler.post(exitRunnable);
     }
 
     // 当前页面超时,自动退出

+ 71 - 23
app/src/main/java/com/bgy/autosale/ui/consumer/IceCreamFragment.java

@@ -15,6 +15,7 @@ import android.os.Looper;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 import android.support.annotation.RequiresApi;
+import android.support.v4.app.DialogFragment;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentTransaction;
@@ -259,7 +260,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
     }
 
     protected int getExitTime() {
-        return isManualMode() ? ADVERTISING_TIME2 * 1000 : ADVERTISING_TIME1 * 1000;
+        return isManualMode() ? ADVERTISING_TIME2 : ADVERTISING_TIME1;
     }
 
     @Override
@@ -279,10 +280,13 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
         flbuy.setOnTouchListener(new View.OnTouchListener() {
             @Override
             public boolean onTouch(View view, MotionEvent motionEvent) {
-                if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
-                    resetFinishDelay();
+                switch (motionEvent.getAction()) {
+                    case MotionEvent.ACTION_DOWN:
+                        resetFinishDelay();
+                        return true;
+                    default:
+                        return false;
                 }
-                return false;
             }
         });
 
@@ -488,6 +492,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
     @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        LogUtils.logWrite("进入了选购页面");
         Heartbeat.deviceId = FileUtil.getDeviceId().trim();
         EventBus.getDefault().register(this);
         Log.d(TAG, "MDB_COIN: 0");
@@ -568,16 +573,22 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
             serialPortHelper.setSphResultCallback(new SphResultCallback() {
                 @Override
                 public void onSendData(SphCmdEntity sendCom) {
+                    if (sendCom.commandsHex!=null){
+                        LogUtils.logWrite("MDB_COIN1:"+sendCom.commandsHex);
+                    }
                 }
 
                 @Override
                 public void onReceiveData(SphCmdEntity data) {
-                    if (data.commandsHex.startsWith("010304") && data.commandsHex.length() >= 10) {
-                        String result = data.commandsHex.substring(6, 10);
-                        double coin = Integer.parseInt(result, 16) / 100.00;
-                        if (!result.equals("0000")) {
-                            Global.hascoin = Global.hascoin.add(new BigDecimal((coin * Global.coinMultiplier) / Global.coinMultiplierDivide)).setScale(2, RoundingMode.HALF_UP);
-                            getDefault().post(new OfflineMessageEvent(Name.CURRENCYCHANGES, null));
+                    if (data.commandsHex!=null) {
+                        LogUtils.logWrite("MDB_COIN2:" + data.commandsHex);
+                        if (data.commandsHex.startsWith("010304") && data.commandsHex.length() >= 10) {
+                            String result = data.commandsHex.substring(6, 10);
+                            double coin = Integer.parseInt(result, 16) / 100.00;
+                            if (!result.equals("0000")) {
+                                Global.hascoin = Global.hascoin.add(new BigDecimal((coin * Global.coinMultiplier) / Global.coinMultiplierDivide)).setScale(2, RoundingMode.HALF_UP);
+                                getDefault().post(new OfflineMessageEvent(Name.CURRENCYCHANGES, null));
+                            }
                         }
                     }
                 }
@@ -615,9 +626,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
     public void onDestroyView() {
         super.onDestroyView();
         LogUtils.logWrite("退出了选购页面");
-        if (loadingDialog != null && loadingDialog.isShowing()) {
-            loadingDialog.dismiss();
-        }
+        closeAllDialog();
         removeFinish();
         mHandler.removeCallbacks(mRunnable);
         UISoundHelper.getInstance().playSelectFlavor(false);
@@ -626,6 +635,12 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
         if (getView() != null) {
             imm.hideSoftInputFromWindow(getView().getWindowToken(), 0);
         }
+        FragmentManager fragmentManager = getChildFragmentManager();
+        for (Fragment fragment : fragmentManager.getFragments()) {
+            if (fragment instanceof DialogFragment) {
+                ((DialogFragment) fragment).dismiss(); // 关闭 DialogFragment
+            }
+        }
     }
 
     @Override
@@ -687,6 +702,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
         } else if (id == R.id.dishes_kernel_2) {
             selectKernel(1);
         }
+        resetFinishDelay();
     }
 
     private void showChoosePay() {
@@ -702,7 +718,9 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
                     double totalSum = 0.0; // 用于存储总和
                     if (orderHelper.getOrderList().get(i).selectSpecBeans.size() > 0) {
                         for (int j = 0; j < orderHelper.getOrderList().get(i).selectSpecBeans.size(); j++) {
-                            totalSum += Double.parseDouble(orderHelper.getOrderList().get(i).selectSpecBeans.get(j).price);
+                            String priceString = orderHelper.getOrderList().get(i).selectSpecBeans.get(j).price;
+                            priceString = priceString.replace(',', '.');
+                            totalSum += Double.parseDouble(priceString);
                         }
                         totalSum += shoppingCart.getPrice();
                     } else {
@@ -761,6 +779,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
             dismissLoading();
             showDialogChoosePay();
         }
+        resetFinishDelay();
     }
 
     private ShoppingTrolleyDialogChoosePay shoppingTrolleyDialogChoosePay;
@@ -781,7 +800,6 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
             public void onClickListener(int type) {
                 switch (type) {
                     case 125:
-                        resetFinishDelay();
                         shoppingTrolleyDialogChoosePay.dismiss();
                         break;
                     case R.id.iv_qianbi:
@@ -822,6 +840,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
     }
 
     private void handlePaymentSelection(int payType, int id, Runnable fallbackAction) {
+        resetFinishDelay();
         this.payType = payType;
         shoppingNumber = 0;
         specialPrice = 0;
@@ -861,7 +880,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
     private void showDialogCreditCard() {
         Log.d(TAG, "showDialogCreditCard: ");
         LogUtils.logWrite("弹出刷卡对话框");
-        removeFinish();
+//        removeFinish();
         mCreditCardDialog = new CreditCardDialog(getContext(), getActivity());
         Log.d(TAG, "showDialogCreditCard: " + coin);
         mCreditCardDialog.setListener(new DialogClickListener() {
@@ -875,7 +894,6 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
                         if (mCreditCardPresenter.is_ready()) {
                             mCreditCardPresenter.CanselSession();
                         }
-                        resetFinishDelay();
                         //关闭 重新支付弹窗倒计
                         LogUtil.d(TAG, "倒计时showTimeOutDialog:111 ");
                         break;
@@ -1509,7 +1527,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
 //            return;
 //        }
         UISoundHelper.getInstance().playSelectFlavor(false);
-        removeFinish();
+//        removeFinish();
 
         if (getFragmentManager() != null) {
             Fragment f = null;
@@ -1781,7 +1799,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
 
 
     private void showPayMixDialog() {
-        removeFinish();
+//        removeFinish();
         if (payMixDialog == null) {
             payMixDialog = new PayMixDialog(getContext(), getActivity());
         }
@@ -1872,7 +1890,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
             showDialogPaySuccess(R.string.pay_success, R.drawable.img_toubi_pay);
             return;
         }
-        removeFinish();
+//        removeFinish();
         if (mMdbCreditCardDialog == null) {
             mMdbCreditCardDialog = new MdbCreditCardDialog(getContext());
             mMdbCreditCardDialog.setCanTouchOutsideDismiss(false);
@@ -1890,7 +1908,6 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
             public void onClickListener(int type) {
                 switch (type) {
                     case 125:
-                        resetFinishDelay();
                         break;
                     case 130:
                         //通用
@@ -1992,7 +2009,9 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
                 shoppingCart.setCount(orderHelper.getOrderList().get(i).buyCount);
                 shoppingCart.setPrice(Double.parseDouble(orderHelper.getOrderList().get(i).price));
                 for (int j = 0; j < orderHelper.getOrderList().get(i).selectSpecBeans.size(); j++) {
-                    totalSum += Double.parseDouble(orderHelper.getOrderList().get(i).selectSpecBeans.get(j).price);
+                    String priceString = orderHelper.getOrderList().get(i).selectSpecBeans.get(j).price;
+                    priceString = priceString.replace(',', '.');
+                    totalSum += Double.parseDouble(priceString);
                 }
                 totalSum += shoppingCart.getPrice();
                 Log.d(TAG, "manualMake:42 " + totalSum + "*" + orderHelper.getOrderList().get(i).buyCount);
@@ -2007,7 +2026,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
                     if (!priceList1.isEmpty()) {
                         double newPri = getPriceList.get(j) - priceList1.get(0);
                         String roundedResult = df.format(newPri);
-                        getPriceList.set(j, Double.valueOf(roundedResult));
+                        getPriceList.set(j, Double.valueOf(roundedResult.replace(',', '.')));
                         priceList1.remove(0);
                         Log.d(TAG, "DecimalFormat: 2");
                     }
@@ -2778,6 +2797,8 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
     }
 
     public void getConfirmCodeSuccess(double format, int id) {
+        resetFinishDelay();
+
         pri = PriceUtil.getAllDishPriceDouble(orderHelper.getOrderList()) - format;
         if (id == R.id.iv_qianbi) {
             showPayMixDialog();
@@ -3039,4 +3060,31 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
         com.hboxs.base_library.util.ToastUtil.showToast(message);
         closeGkashCardDialog();
     }
+
+    private void closeAllDialog(){
+        if (loadingDialog!=null&& loadingDialog.isShowing()){
+            loadingDialog.dismiss();
+        }
+        if (shoppingTrolleyDialogChoosePay!=null) {
+            shoppingTrolleyDialogChoosePay.dismiss();
+        }
+        if (gkashPayDialog!=null) {
+            gkashPayDialog.dismiss();
+        }
+        if (httpCreditCardDialog!=null) {
+            httpCreditCardDialog.dismiss();
+        }
+        if (paySuccessDialog != null) {
+            paySuccessDialog.dismiss();
+        }
+        if (mMdbCreditCardDialog!=null) {
+            mMdbCreditCardDialog.dismiss();
+        }
+        if (payMixDialog!=null) {
+            payMixDialog.dismiss();
+        }
+        if (mCreditCardDialog!=null) {
+            mCreditCardDialog.dismiss();
+        }
+    }
 }

+ 7 - 7
app/src/main/java/com/bgy/autosale/ui/consumer/PaySuccessFragment.java

@@ -43,7 +43,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
  **/
 public class PaySuccessFragment extends BaseAutoExitFragment implements Callback<Result> {
 
-    private int exitTime = 60000;
+    private int exitTime = 60;
 
     CircularProgressView progressView;
 
@@ -170,27 +170,27 @@ public class PaySuccessFragment extends BaseAutoExitFragment implements Callback
                 switch (result.code) {
                     case BasePlcAgreement.RESULT_CODE_ORDER_ERROR:
                         makeFail();
-                        exitTime = 15000; // 不知道什么错, 15秒超时退出
+                        exitTime = 15; // 不知道什么错, 15秒超时退出
                         break;
                     case BasePlcAgreement.RESULT_CODE_ORDER_CHILD_PREPARE: // 4
                         int time = updateMakingInfo();
                         progressView.setProgress(30);
                         progressView.setProgress(1500, time);
-                        exitTime = 300000; // 制作中, 5分钟超时退出
+                        exitTime = 300; // 制作中, 5分钟超时退出
                         break;
                     case BasePlcAgreement.RESULT_CODE_ORDER_CHILD_OUT: // 1
                         progressView.setProgress(1800, 1000);
                         updateTakeInfo();
-                        exitTime = 600000; // 待取餐, 10分钟超时退出
+                        exitTime = 600; // 待取餐, 10分钟超时退出
                         break;
                     case BasePlcAgreement.RESULT_CODE_ORDER_CHILD_FINISH: // 2
                         updateCloseInfo();
-                        exitTime = 120000; // 子订单取走了, 2分钟超时退出
+                        exitTime = 120; // 子订单取走了, 2分钟超时退出
                         break;
                     case BasePlcAgreement.RESULT_CODE_ORDER_COMPLETE: // 3
                         updateFinishInfo();
                         if (Global.isVersions == 1) {
-                            exitTime = 5000; // 完成订单, 5秒超时退出
+                            exitTime = 5; // 完成订单, 5秒超时退出
                         } else {
                             new Handler().postDelayed(new Runnable() {
                                 @Override
@@ -204,7 +204,7 @@ public class PaySuccessFragment extends BaseAutoExitFragment implements Callback
                         }
                         break;
                     default:
-                        exitTime = 120000; // 不知道什么指令 2分钟超时退出
+                        exitTime = 120; // 不知道什么指令 2分钟超时退出
                         break;
                 }
                 resetFinishDelay();

+ 2 - 1
app/src/main/java/com/bgy/autosale/ui/operator/fragments/SwitchFragment.java

@@ -461,7 +461,8 @@ public class SwitchFragment extends BaseFragment implements RadioGroup.OnChecked
             String s = etChanglog.getText().toString();
             if ("1".equals(s) ||"7772".equals(s)||"7770".equals(s)||"7777".equals(s)||"7761".equals(s)
                     ||"7773".equals(s)||"7774".equals(s)||"7786".equals(s)||"7775".equals(s)||"7754".equals(s)
-            ||"0000".equals(s)|| "7764".equals(s)|| "5784".equals(s)|| "7749".equals(s)|| "7756".equals(s)) {
+            ||"0000".equals(s)|| "7764".equals(s)|| "5784".equals(s)|| "7749".equals(s)|| "7756".equals(s)
+                    || "7765".equals(s)) {
                 Hawk.put("logo", s);
                 Hawk.get("logo", "7777");
                 ToastUtil.showToast(UiUtil.getStringRes(R.string.xgwc));

+ 1 - 1
config.gradle

@@ -5,7 +5,7 @@ ext {
             "minSdkVersion"                : 21,
             "targetSdkVersion"             : 28,
             "versionCode"                  : 110,
-            "versionName"                  : "1.0.85",//版本号修改
+            "versionName"                  : "1.0.89",//版本号修改
 
             "androidSupport"               : "28.0.0",
             "constraint-layout"            : "1.1.3",

+ 3 - 1
lm-library/src/main/java/top/keepempty/sph/library/SphConcurrentCom.java

@@ -54,7 +54,9 @@ public class SphConcurrentCom {
                 e.printStackTrace();
             }
         }
-        currentCmdEntity = mEntryList.remove(0);
+        if (!mEntryList.isEmpty()){
+            currentCmdEntity = mEntryList.remove(0);
+        }
         notify();
         return currentCmdEntity;
     }

+ 1 - 1
lm-library/src/main/java/top/keepempty/sph/library/SphDataProcess.java

@@ -72,7 +72,7 @@ public class SphDataProcess {
      */
     public void writeData() {
         if (concurrentCom.getCurrentCmdEntity() == null) {
-            if (!concurrentCom.isCmdEmpty()) {
+            if (!concurrentCom.isCmdEmpty()&&concurrentCom.get()!=null) {
                 currentCommand = concurrentCom.get();
                 if (onResultCallback != null) {
                     onResultCallback.onSendData(currentCommand);

+ 8 - 1
lm-library/src/main/java/top/keepempty/sph/library/SphThreads.java

@@ -1,5 +1,7 @@
 package top.keepempty.sph.library;
 
+import android.util.Log;
+
 /**
  * 串口读写线程
  *
@@ -7,6 +9,7 @@ package top.keepempty.sph.library;
  * @date:2019/3/30 18:45
  */
 public class SphThreads {
+    private static final String TAG = "SphThreads";
     /**
      * 读写线程
      */
@@ -62,7 +65,11 @@ public class SphThreads {
         @Override
         public void run() {
             while (!writeThread.isInterrupted()) {
-                processingData.writeData();
+                if (processingData!=null){
+                    processingData.writeData();
+                }else {
+                    break;
+                }
             }
         }
     }

+ 2 - 3
module_offpay/src/main/java/com/example/offpay/wmdb/WeaverUtil.java

@@ -69,9 +69,8 @@ public class WeaverUtil {
      *               0Ah:信用额度不足
      */
     public static void creditCardVendFailed(String itemNumber,String vendAmount,String itemCount,String optionsAmount,String reason) {
-        Log.d(TAG, "creditCardrequestVend: " + "1302" + itemNumber+vendAmount+itemCount+optionsAmount+reason);
-        SerialPortUtil.getSerialPortUtil().sendSerialPort("1303" + "00"+vendAmount+itemCount+optionsAmount+"00");
-
+        Log.d(TAG, "creditCardrequestVend: " + "1303" + itemNumber);
+        SerialPortUtil.getSerialPortUtil().sendSerialPort("1303" +itemNumber);
     }
 
     /**