Browse Source

1、优化自动返回广告页时间逻辑

ccc 1 week ago
parent
commit
38e4630a4e

+ 4 - 1
BaseLibrary/src/main/java/com/hboxs/base_library/constant/Global.java

@@ -20,7 +20,7 @@ public abstract class Global {
      * 1:
      * 2:国外线上
      */
-    public static final int isVersions = 2;
+    public static final int isVersions = 1;
 
     /**
      * 用来初始化这个Global的类,不然会很卡。
@@ -267,5 +267,8 @@ public abstract class Global {
         return hashMap;
     }
 
+    //当前fragment
+    public static String thisFragment ="";
+
 }
 

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

@@ -479,7 +479,7 @@ public class MainActivity extends BaseScanGunActivity  implements SendCallback,
         UISoundHelper.getInstance();
         findViewById(R.id.main_fragment).setVisibility(View.VISIBLE);
         if (!SPUtils.getInstance(App.app).getBoolean(Constant.LOCK_IN_ERROR, false)) {
-//            App.app.initDeviceStateListener();//是否开机
+            App.app.initDeviceStateListener();//是否开机
             Log.d(TAG, "initMainView: ");
         }
 

+ 7 - 0
app/src/main/java/com/bgy/autosale/ui/base/BaseAutoExitFragment.java

@@ -47,6 +47,7 @@ public abstract class BaseAutoExitFragment extends BaseFragment {
     @Override
     public void onDestroy() {
         super.onDestroy();
+        Log.d(TAG, "onDestroy: removeFinish");
         removeFinish();
     }
 
@@ -62,18 +63,24 @@ public abstract class BaseAutoExitFragment extends BaseFragment {
 
     // 重新开始超时计时
     public void resetFinishDelay() {
+        Log.d(TAG, "时间:resetFinishDelay: ");
         removeFinish();
         startFinishDelay();
     }
 
     // 删除超时计时
     protected void removeFinish() {
+        Log.d(TAG, "时间:removeFinish: ");
         handler.removeCallbacks(exitRunnable);
     }
 
     // 开始超时计时
     protected void startFinishDelay() {
+        Log.d(TAG, "时间:startFinishDelay: ");
         exitTime = getExitTime();
+        if (exitRunnable != null) {
+            handler.removeCallbacks(exitRunnable);
+        }
         exitRunnable = new Runnable() {
             @Override
             public void run() {

+ 4 - 0
app/src/main/java/com/bgy/autosale/ui/base/BaseFragment.java

@@ -7,6 +7,7 @@ import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentTransaction;
 import android.text.TextUtils;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -15,6 +16,7 @@ import android.view.animation.AnimationUtils;
 
 import com.bgy.autosale.utils.PlcLog;
 import com.bgy.autosale.utils.ToastUtil;
+import com.hboxs.base_library.constant.Global;
 
 import java.lang.reflect.Field;
 
@@ -34,6 +36,8 @@ public abstract class BaseFragment extends Fragment {
     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
         mContentView = inflater.inflate(getViewId(), container, false);
         PlcLog.getInstance().e_s(TAG, "进入了 " + this);
+        Log.d(TAG, "BaseFragmentonCreateView: "+TAG);
+        Global.thisFragment=TAG;
         return mContentView;
     }
 

+ 18 - 28
app/src/main/java/com/bgy/autosale/ui/consumer/IceCreamFragment.java

@@ -181,7 +181,7 @@ import top.keepempty.sph.library.SphResultCallback;
  * Created by cjx on 2020-08-21
  * 说明:
  */
-public class IceCreamFragment extends BaseAutoExitFragment implements View.OnClickListener, Animation.AnimationListener ,View.OnTouchListener{
+public class IceCreamFragment extends BaseAutoExitFragment implements View.OnClickListener, Animation.AnimationListener{
 
     // 去除末尾的0
 //    private DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
@@ -669,7 +669,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
         if (!mClickHelper.canClick()) {
             return;
         }
-//        resetFinishDelay();
+        resetFinishDelay();
         int id = v.getId();
         if (id == R.id.dishes_shop_cart_clear) {
             showClearDialog();
@@ -691,7 +691,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
 //            }
             if (!CommunicationHelper.getInstance().canGenerateOrder()) {
                 ToastUtil.getInstance().showText(CommunicationHelper.getInstance().getWhyCanOrderText());
-//                return;//是否开机
+                return;//是否开机
             }
             if (Hawk.get(Name.SHOPPING_TROLLEY, true)) {
                 addShopCart();
@@ -717,7 +717,6 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
         } else if (id == R.id.dishes_kernel_2) {
             selectKernel(1);
         }
-        resetFinishDelay();
     }
 
     private void showChoosePay() {
@@ -754,6 +753,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
             pri = PriceUtil.getDishPriceOne(currentDish);
         }
         showLoading();
+        resetFinishDelay();
         if (App.app.payChannel == Constant.PAY_FREE || manualReason != null) {
             payType = 0;
             manualMake();
@@ -795,7 +795,6 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
             dismissLoading();
             showDialogChoosePay();
         }
-        resetFinishDelay();
     }
 
     private ShoppingTrolleyDialogChoosePay shoppingTrolleyDialogChoosePay;
@@ -1616,7 +1615,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
                 resetIceCreamView();
                 break;
             case "RefreshUI":
-                if (Hawk.get(Name.VALUE_ZERO,false)) {
+                if (Hawk.get(Name.VALUE_ZERO, false)) {
                     tvMoney.setText(UiUtil.getStringRes(R.string.have_money) + Global.hasmoney.setScale(2, RoundingMode.HALF_UP));
                 }
                 break;
@@ -1756,17 +1755,17 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
 //                tvMoney.setText(haveMoney + (Global.hasmoney.doubleValue() + Global.hascoin.doubleValue()) + Hawk.get(Name.UNIT_OF_CURRENCY_TIME, ""));
                 tvMoney.setText(haveMoney + Global.hasmoney.add(Global.hascoin).setScale(2, RoundingMode.HALF_UP) + Hawk.get(Name.UNIT_OF_CURRENCY_TIME, ""));
 
-                coin=Global.hasmoney.add(Global.hascoin).doubleValue();
+                coin = Global.hasmoney.add(Global.hascoin).doubleValue();
                 if (payMixDialog != null && payMixDialog.isShowing()) {
                     if (Global.hasmoney.doubleValue() + Global.hascoin.doubleValue() >= pri) {
 //                        tvMoney.setText(haveMoney + (Global.hasmoney.doubleValue() + Global.hascoin.doubleValue() - pri) + Hawk.get(Name.UNIT_OF_CURRENCY_TIME, ""));
                         tvMoney.setText(haveMoney + (Global.hasmoney.add(Global.hascoin).subtract(new BigDecimal(pri + "").setScale(2, RoundingMode.HALF_UP))) + Hawk.get(Name.UNIT_OF_CURRENCY_TIME, UiUtil.getStringRes(R.string.price_unit)));
                         remainMoney = Global.hasmoney.doubleValue() + Global.hascoin.doubleValue() - pri;
                         payPaperSuccess(); // 收钞完成
-                        Log.d(TAG, "event: payPaperSuccessa "+pri);//商品价格
-                        Log.d(TAG, "event: payPaperSuccessa "+coin);//投入金额
-                        Log.d(TAG, "event: payPaperSuccessb"+remainMoney);//剩余可用金额
-                        Log.d(TAG, "event: payPaperSuccessc"+Global.hasmoney.doubleValue() + Global.hascoin.doubleValue());//商品价格
+                        Log.d(TAG, "event: payPaperSuccessa " + pri);//商品价格
+                        Log.d(TAG, "event: payPaperSuccessa " + coin);//投入金额
+                        Log.d(TAG, "event: payPaperSuccessb" + remainMoney);//剩余可用金额
+                        Log.d(TAG, "event: payPaperSuccessc" + Global.hasmoney.doubleValue() + Global.hascoin.doubleValue());//商品价格
                         EventBus.getDefault().post(new ApiMessageEvent("cashsale",
                                 ByteUtils.decimal2fitHex((long) (coin * 100), 4)
                                         + ";" + ByteUtils.decimal2fitHex((long) 1, 4)));
@@ -1794,14 +1793,14 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
                 break;
             case Name.ENDSESSION:
 //                if (Hawk.get(Name.END_CREDIT_CARD, false)) {
-                    new Handler().postDelayed(new Runnable() {
-                        @Override
-                        public void run() {
-                            if (mMdbCreditCardDialog != null) {
-                                mMdbCreditCardDialog.dismiss();
-                            }
+                new Handler().postDelayed(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (mMdbCreditCardDialog != null) {
+                            mMdbCreditCardDialog.dismiss();
                         }
-                    }, 3000);
+                    }
+                }, 3000);
 //                }
                 break;
             default:
@@ -1867,7 +1866,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
         payMixDialog.show();
         dismissLoading();
         if (Global.hasmoney.doubleValue() + Global.hascoin.doubleValue() >= pri) {
-            coin=Global.hasmoney.add(Global.hascoin).doubleValue();
+            coin = Global.hasmoney.add(Global.hascoin).doubleValue();
 
 //            tvMoney.setText(haveMoney + (Global.hasmoney.doubleValue() + Global.hascoin.doubleValue() - pri) + Hawk.get(Name.UNIT_OF_CURRENCY_TIME, ""));
             tvMoney.setText(haveMoney + (Global.hasmoney.add(Global.hascoin).subtract(new BigDecimal(pri + "").setScale(2, RoundingMode.HALF_UP))) + Hawk.get(Name.UNIT_OF_CURRENCY_TIME, UiUtil.getStringRes(R.string.price_unit)));
@@ -3164,13 +3163,4 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
         return null;
     }
 
-    @Override
-    public boolean onTouch(View view, MotionEvent motionEvent) {
-        switch (motionEvent.getAction()) {
-            case MotionEvent.ACTION_DOWN:
-                resetFinishDelay();
-                return true;
-        }
-        return false;
-    }
 }

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

@@ -121,7 +121,6 @@ public class PaySuccessFragment extends BaseAutoExitFragment implements Callback
             getActivity().getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
         }
         ErrorViewHelper.getInstance().setCanShowErrorView(false, this);
-
         if (getActivity() != null && getActivity() instanceof BaseScanGunActivity) {
             ((BaseScanGunActivity) getActivity()).setScanCodeListener(null);
         }

+ 1 - 1
config.gradle

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