Kaynağa Gözat

1.新增称重取消按钮
2.新增柜门查看必须登录

JaycePC 1 hafta önce
ebeveyn
işleme
8068891721

+ 6 - 1
app/src/main/java/xn/hxp/ui/MainActivity.java

@@ -124,7 +124,12 @@ public class MainActivity extends BaseActivity {
         registerReceiver(timeTickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
 
         viewBinding.versionName.setText("版本号:" + AppUtils.getAppVersionName());
-        viewBinding.cabinetVP.registerLifecycleObserver(getLifecycle()).setAdapter(new CabinetBannerAdapter()).create(ruleBeanList);
+        viewBinding.cabinetVP.registerLifecycleObserver(getLifecycle()).setAdapter(new CabinetBannerAdapter(new CabinetBannerAdapter.VerifyCallBack() {
+            @Override
+            public void login() {
+                basicConfLog();
+            }
+        })).create(ruleBeanList);
         viewBinding.test.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {

+ 30 - 11
app/src/main/java/xn/hxp/ui/adapter/CabinetBannerAdapter.java

@@ -18,11 +18,21 @@ import java.util.List;
 import java.util.Map;
 
 import xn.hxp.R;
+import xn.hxp.app.ChemicalApp;
 import xn.hxp.ui.inquiry.InquiryActivity;
 import xn.hxp.utils.UiManager;
 
 public class CabinetBannerAdapter extends BaseBannerAdapter<RuleBean> {
     private final StringBuffer stringBuffer = new StringBuffer();
+    private VerifyCallBack callBack;
+
+    public CabinetBannerAdapter(VerifyCallBack callBack) {
+        this.callBack = callBack;
+    }
+
+    public interface VerifyCallBack {
+        void login();
+    }
 
     @Override
     protected void bindData(BaseViewHolder<RuleBean> holder, RuleBean data, int position, int pageSize) {
@@ -38,12 +48,16 @@ public class CabinetBannerAdapter extends BaseBannerAdapter<RuleBean> {
         doorRLL.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                CabinetDoorVo cabinetDoor = cabinetDoorList.get(0);
-                Map<String, Object> map = new HashMap<>();
-                map.put("logIn", 1);
-                map.put("cabinetId", cabinetDoor.getCabinetId());
-                map.put("doorId", cabinetDoor.getDoorUniqueId());
-                UiManager.INSTANCE.switcher(holder.itemView.getContext(), map, InquiryActivity.class);
+                if (ChemicalApp.userData != null) {
+                    CabinetDoorVo cabinetDoor = cabinetDoorList.get(0);
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("logIn", 1);
+                    map.put("cabinetId", cabinetDoor.getCabinetId());
+                    map.put("doorId", cabinetDoor.getDoorUniqueId());
+                    UiManager.INSTANCE.switcher(holder.itemView.getContext(), map, InquiryActivity.class);
+                } else {
+                    callBack.login();
+                }
             }
         });
         // 右柜门布局
@@ -51,11 +65,16 @@ public class CabinetBannerAdapter extends BaseBannerAdapter<RuleBean> {
         doorRLR.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                CabinetDoorVo cabinetDoor = cabinetDoorList.get(1);
-                Map<String, Object> map = new HashMap<>();
-                map.put("cabinetId", cabinetDoor.getCabinetId());
-                map.put("doorId", cabinetDoor.getDoorUniqueId());
-                UiManager.INSTANCE.switcher(holder.itemView.getContext(), map, InquiryActivity.class);
+                if (ChemicalApp.userData != null) {
+                    CabinetDoorVo cabinetDoor = cabinetDoorList.get(1);
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("logIn", 1);
+                    map.put("cabinetId", cabinetDoor.getCabinetId());
+                    map.put("doorId", cabinetDoor.getDoorUniqueId());
+                    UiManager.INSTANCE.switcher(holder.itemView.getContext(), map, InquiryActivity.class);
+                } else {
+                    callBack.login();
+                }
             }
         });
         if (null != cabinetDoorList && !cabinetDoorList.isEmpty()) {

+ 9 - 29
app/src/main/java/xn/hxp/weidith/ble/BluetoothWeighDialog.java

@@ -15,6 +15,7 @@ import android.widget.Toast;
 import androidx.appcompat.app.AppCompatDialog;
 
 import com.blankj.utilcode.util.ActivityUtils;
+import com.blankj.utilcode.util.ClickUtils;
 import com.blankj.utilcode.util.SPUtils;
 import com.blankj.utilcode.util.ThreadUtils;
 import com.bumptech.glide.Glide;
@@ -119,35 +120,14 @@ public class BluetoothWeighDialog extends AppCompatDialog {
                 }
             });
         }
-//        BleTool.INSTANCE.setBleCallback(new BleTool.BleCallback() {
-//            @Override
-//            public void onSuccess() {
-//
-//            }
-//
-//            @Override
-//            public void onNotifyFailure(Exception exception) {
-//                dialogCallBack.cancel(BluetoothWeighDialog.this, exception.getMessage());
-//            }
-//
-//            @Override
-//            public void onChanged(String weight) {
-//                try {
-//                    double w = Double.parseDouble(weight);
-//                    hxpChemicalVo.setWeigh(w);
-//                    binding.weighTV.setText(weight + "g");
-//                } catch (Exception e) {
-//                    ThreadUtils.runOnUiThread(() -> Toast.makeText(ActivityUtils.getTopActivity(), "蓝牙称值异常! " + weight, Toast.LENGTH_SHORT).show());
-//                }
-//                if (binding.weightRL.getVisibility() != View.VISIBLE) {
-//                    binding.weightRL.setVisibility(View.VISIBLE);
-//                }
-//                if (binding.loadingLAV.getVisibility() == View.VISIBLE) {
-//                    binding.loadingLAV.cancelAnimation();
-//                    binding.loadingLAV.setVisibility(View.GONE);
-//                }
-//            }
-//        });
+
+        // 取消
+        binding.cancelBT.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
+            @Override
+            public void onDebouncingClick(View v) {
+                dialogCallBack.cancel(BluetoothWeighDialog.this, "取消称重!");
+            }
+        });
         // 确认
         binding.confirmBT.setOnClickListener(v -> {
             Editable netWtETText = binding.netWtET.getText();

+ 28 - 9
app/src/main/res/layout/dialog_bluetooth_weigh.xml

@@ -165,13 +165,32 @@
         </RelativeLayout>
     </RelativeLayout>
 
-    <Button
-        android:id="@+id/confirm_BT"
-        android:layout_width="250px"
-        android:layout_height="70px"
-        android:layout_marginTop="35px"
-        android:background="@drawable/selector_input_select_bt"
-        android:text="确定"
-        android:textColor="@color/white"
-        android:textSize="30px" />
+
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="90dp"
+        android:orientation="horizontal">
+
+        <Button
+            android:id="@+id/cancel_BT"
+            android:layout_width="250px"
+            android:layout_height="70px"
+            android:layout_marginHorizontal="20dp"
+            android:layout_marginTop="35px"
+            android:background="@drawable/bg_closes"
+            android:text="取消"
+            android:textSize="30px" />
+
+        <Button
+            android:id="@+id/confirm_BT"
+            android:layout_width="250px"
+            android:layout_height="70px"
+            android:layout_marginHorizontal="20dp"
+            android:layout_marginTop="35px"
+            android:background="@drawable/selector_input_select_bt"
+            android:text="确定"
+            android:textColor="@color/white"
+            android:textSize="30px" />
+    </LinearLayout>
+
 </LinearLayout>