|
@@ -1,6 +1,7 @@
|
|
|
package com.example.chemical.ui.plan;
|
|
|
|
|
|
import android.content.Intent;
|
|
|
+import android.database.DataSetObserver;
|
|
|
import android.os.Bundle;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
@@ -14,30 +15,31 @@ import androidx.activity.result.contract.ActivityResultContracts;
|
|
|
import androidx.annotation.NonNull;
|
|
|
import androidx.annotation.Nullable;
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
-import androidx.fragment.app.FragmentManager;
|
|
|
import androidx.viewpager2.widget.ViewPager2;
|
|
|
|
|
|
+import com.blankj.utilcode.util.ActivityUtils;
|
|
|
import com.blankj.utilcode.util.LogUtils;
|
|
|
import com.blankj.utilcode.util.TimeUtils;
|
|
|
+import com.blankj.utilcode.util.ToastUtils;
|
|
|
import com.bumptech.glide.Glide;
|
|
|
import com.example.chemical.ChemicalApp;
|
|
|
import com.example.chemical.databinding.ActivityPlanAddBinding;
|
|
|
-import com.example.chemical.receiver.ScanKeyEventHelper;
|
|
|
import com.example.chemical.ui.SplashActivity;
|
|
|
import com.example.chemical.ui.common.BaseCountDownActivity;
|
|
|
import com.example.chemical.ui.plan.add.AddActivity;
|
|
|
import com.example.chemical.ui.plan.locker.LockerAdapter;
|
|
|
import com.example.chemical.ui.plan.room.RoomTool;
|
|
|
+import com.example.chemical.ui.plan.room.bean.input_add.InventoryItemBean;
|
|
|
+import com.example.chemical.ui.plan.room.bean.locker.CabinetLayerSelect;
|
|
|
+import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetVo;
|
|
|
import com.example.chemical.ui.plan.room.dao.HxpCabinetDAO;
|
|
|
import com.example.chemical.ui.plan.room.dao.HxpDoorDAO;
|
|
|
import com.example.chemical.ui.plan.room.dao.HxpInventoryDAO;
|
|
|
import com.example.chemical.ui.plan.room.dao.HxpLayerDAO;
|
|
|
+import com.example.chemical.ui.plan.unlock.UnlockActivity;
|
|
|
import com.example.chemical.utils.UiManager;
|
|
|
import com.rc.httpcore.HttpConfig;
|
|
|
import com.rc.httpcore.bean.ChemicalInfoBean;
|
|
|
-import com.example.chemical.ui.plan.room.bean.input_add.InventoryItemBean;
|
|
|
-import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetVo;
|
|
|
-import com.example.chemical.ui.plan.room.bean.locker.CabinetLayerSelect;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
@@ -45,9 +47,6 @@ import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
|
|
|
-import kotlin.Unit;
|
|
|
-import kotlin.jvm.functions.Function1;
|
|
|
-
|
|
|
/**
|
|
|
* 待录入页面
|
|
|
*/
|
|
@@ -56,8 +55,6 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
|
|
|
protected ActivityPlanAddBinding binding;
|
|
|
// 柜子fragmentAdapter
|
|
|
protected LockerAdapter lockerAdapter;
|
|
|
- // 二维码/条形码扫描工具
|
|
|
- private ScanKeyEventHelper scanKeyEventHelper;
|
|
|
// 实验室基本信息
|
|
|
protected ChemicalInfoBean chemicalInfo;
|
|
|
// 服务端实验室所有柜子信息
|
|
@@ -105,18 +102,6 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
|
|
|
binding.nextBT.setOnClickListener(view -> binding.lockerVP2.setCurrentItem(binding.lockerVP2.getCurrentItem() + 1, true));
|
|
|
binding.lastBT.setOnClickListener(view -> binding.lockerVP2.setCurrentItem(binding.lockerVP2.getCurrentItem() - 1, true));
|
|
|
|
|
|
- scanKeyEventHelper = new ScanKeyEventHelper(new Function1<String, Unit>() {
|
|
|
- @Override
|
|
|
- public Unit invoke(String s) {
|
|
|
- if (binding.inputRL.getVisibility() == View.GONE) {
|
|
|
- showToast("请先选择化学品柜层!");
|
|
|
- return null;
|
|
|
- }
|
|
|
- Log.d("结果", s);
|
|
|
- return null;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
// 待存储
|
|
|
intentActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
|
|
|
@Override
|
|
@@ -125,7 +110,6 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
|
|
|
planAddActivityHelp.updateInventoryUi();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
|
|
|
// 手动录入化学品
|
|
@@ -133,8 +117,20 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
|
|
|
|
|
|
planAdapter = new PlanAdapter(this, inventoryItemBeanList);
|
|
|
binding.planLV.setAdapter(planAdapter);
|
|
|
+ planAdapter.registerDataSetObserver(dataSetObserver);
|
|
|
|
|
|
- LogUtils.json(hxpInventoryDAO.getAll());
|
|
|
+ // 确认入库
|
|
|
+ binding.subAdd.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ List<InventoryItemBean> inventoryItemBeans = hxpInventoryDAO.getAll();
|
|
|
+ if (null == inventoryItemBeans || inventoryItemBeans.isEmpty()) {
|
|
|
+ ToastUtils.showLong("请录入化学品!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ActivityUtils.startActivity(UnlockActivity.class);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -181,7 +177,7 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
|
|
|
|
|
|
@Override
|
|
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
|
|
- scanKeyEventHelper.analysisKeyEvent(event);
|
|
|
+ // https://labcontrol.nwafu.edu.cn/api/?code=5020641&type=9
|
|
|
return super.dispatchKeyEvent(event);
|
|
|
}
|
|
|
|
|
@@ -197,8 +193,24 @@ public class PlanAddActivity extends BaseCountDownActivity<ActivityPlanAddBindin
|
|
|
protected void onDestroy() {
|
|
|
fragmentCallBack = null;
|
|
|
super.onDestroy();
|
|
|
+ planAdapter.unregisterDataSetObserver(dataSetObserver);
|
|
|
intentActivityResultLauncher.unregister();
|
|
|
}
|
|
|
|
|
|
+ DataSetObserver dataSetObserver = new DataSetObserver() {
|
|
|
+ @Override
|
|
|
+ public void onChanged() {
|
|
|
+ super.onChanged();
|
|
|
+ if (null == inventoryItemBeanList || inventoryItemBeanList.isEmpty()) {
|
|
|
+ planAddActivityHelp.updateInventoryUi();
|
|
|
+ }
|
|
|
+ int size = 0;
|
|
|
+ for (int i = 0; i < inventoryItemBeanList.size(); i++) {
|
|
|
+ InventoryItemBean inventoryItemBean = inventoryItemBeanList.get(i);
|
|
|
+ size = size + inventoryItemBean.getSize();
|
|
|
+ }
|
|
|
+ binding.sizeTV.setText("总数:" + size);
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
}
|