From e3059e0361a15e1fec9459cd8c6cf2dc6f4f60f6 Mon Sep 17 00:00:00 2001 From: liup <1454939542@qq.com> Date: Tue, 21 May 2024 09:27:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=B0=83=E8=AF=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 10 +- app/src/main/AndroidManifest.xml | 2 +- .../bonait/bnframework/MainApplication.java | 58 ++ .../bnframework/Service/ModbusHelper.java | 27 +- .../ViewModel/CustomView/item_gx.java | 10 + .../FragmentViewModel/HomeDeviceFragment.java | 110 +--- .../db/util/GoodsProcessDetailDBUtil.java | 4 +- .../db/util/SubAttributeGroupDBUtil.java | 8 +- .../common/utils/DisplayManager.java | 12 + .../ui/activity/DiyProcessActivity.java | 496 +++++++++++++++--- .../ui/activity/EditClassifyActivity.java | 8 +- .../ui/adapter/ClassifyAdapter.java | 3 + .../ui/adapter/DiyStepAdapter.java | 82 +++ .../ui/adapter/LocalGoodsAdapter.java | 2 +- .../adapter/SelectAttributeListAdapter.java | 6 +- .../bnframework/ui/dialog/AddGoodsDialog.java | 7 +- .../ui/dialog/AttributeSelectDialog.java | 188 +++++++ .../ui/dialog/DeviceControlDialog.java | 270 ++++++++++ .../ui/dialog/EditGoodsDialog.java | 27 +- .../ui/fragment/CloudGoodsFragment.java | 2 +- .../ui/fragment/HomeDevicesFragment.java | 127 +++++ .../ui/fragment/HomeFoodsFragment.java | 12 +- .../ui/fragment/LocalGoodsFragment.java | 5 +- .../ui/viewmodel/HomeGoodsViewModel.java | 1 - .../widget/FireView.java} | 30 +- .../bnframework/ui/widget/NewToastUtil.java | 41 +- .../ui/widget/ProcessValueView.java | 197 +++++++ .../ui/widget/SmoothLayoutManager.java | 55 ++ .../drawable/bg_round50_left_green_btn.xml | 21 + .../drawable/bg_round50_right_green_btn.xml | 21 + .../drawable/selector_select_step_text_bg.xml | 15 + .../selector_select_step_text_color.xml | 6 + .../selector_text_click_yellow_round15.xml | 17 + .../main/res/layout/activity_edit_process.xml | 140 +++-- .../dialog/layout/dialog_attribute_select.xml | 81 +++ .../dialog/layout/dialog_delete_classify.xml | 13 + .../dialog/layout/dialog_device_control.xml | 45 ++ .../layout/layout_add_goods_mainfood.xml | 6 +- .../dialog/layout/layout_fire_control.xml | 140 +++++ .../dialog/layout/layout_food_control.xml | 143 +++++ .../dialog/layout/layout_silos_control.xml | 135 +++++ .../dialog/layout/layout_stir_control.xml | 180 +++++++ .../main/res/layout/fragment_home_device.xml | 11 - .../main/res/layout/fragment_home_devices.xml | 36 ++ .../layout/item/layout/item_fire_control.xml | 68 +-- .../layout/item/layout/item_local_goods.xml | 10 +- .../main/res/layout/item/layout/item_step.xml | 57 ++ .../layout/item/layout/view_process_value.xml | 52 ++ .../main/res/layout/view_device_control.xml | 85 +++ app/src/main/res/values/dimens.xml | 3 +- app/src/main/res/values/styles.xml | 8 +- 51 files changed, 2752 insertions(+), 341 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/ui/adapter/DiyStepAdapter.java create mode 100644 app/src/main/java/com/bonait/bnframework/ui/dialog/AttributeSelectDialog.java create mode 100644 app/src/main/java/com/bonait/bnframework/ui/dialog/DeviceControlDialog.java create mode 100644 app/src/main/java/com/bonait/bnframework/ui/fragment/HomeDevicesFragment.java rename app/src/main/java/com/bonait/bnframework/{ViewModel/CustomView/fire_control.java => ui/widget/FireView.java} (93%) create mode 100644 app/src/main/java/com/bonait/bnframework/ui/widget/ProcessValueView.java create mode 100644 app/src/main/java/com/bonait/bnframework/ui/widget/SmoothLayoutManager.java create mode 100644 app/src/main/res/drawable/bg_round50_left_green_btn.xml create mode 100644 app/src/main/res/drawable/bg_round50_right_green_btn.xml create mode 100644 app/src/main/res/drawable/selector_select_step_text_bg.xml create mode 100644 app/src/main/res/drawable/selector_select_step_text_color.xml create mode 100644 app/src/main/res/drawable/selector_text_click_yellow_round15.xml create mode 100644 app/src/main/res/layout/dialog/layout/dialog_attribute_select.xml create mode 100644 app/src/main/res/layout/dialog/layout/dialog_device_control.xml create mode 100644 app/src/main/res/layout/dialog/layout/layout_fire_control.xml create mode 100644 app/src/main/res/layout/dialog/layout/layout_food_control.xml create mode 100644 app/src/main/res/layout/dialog/layout/layout_silos_control.xml create mode 100644 app/src/main/res/layout/dialog/layout/layout_stir_control.xml create mode 100644 app/src/main/res/layout/fragment_home_devices.xml create mode 100644 app/src/main/res/layout/item/layout/item_step.xml create mode 100644 app/src/main/res/layout/item/layout/view_process_value.xml create mode 100644 app/src/main/res/layout/view_device_control.xml diff --git a/app/build.gradle b/app/build.gradle index 9dccfee8..f501acfc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -152,9 +152,9 @@ dependencies { //轮播图 implementation 'com.youth.banner:banner:1.4.10' - //图片加载 - implementation 'com.github.bumptech.glide:glide:4.11.0' - annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' +// //图片加载 +// implementation 'com.github.bumptech.glide:glide:4.11.0' +// annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' implementation 'com.yanzhenjie:permission:2.0.0-rc12' @@ -198,4 +198,8 @@ dependencies { //leak 内存泄漏检测 debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-3' + + //腾讯bugly + //sdk地址 https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=1.0.0 + implementation 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如4.0.3 } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f3a3ebf6..609100f3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,9 +37,9 @@ android:name=".ViewModel.ActivityViewModel.DiyUpdate1Activity" android:screenOrientation="portrait" android:exported="false" /> + res = ReadShort(statusModel.PlcAddress,1); if(res.isSuccess){ - statusModel.Value.setValue(res.Content); +// statusModel.Value.setValue(res.Content); + byte[] bytes = DataConvertLib.shorts2Bytes(res.Content); + if(bytes.length>=2){ + deviceErrorCode = bytes[0] & 0xFF; + } } - - Thread.sleep(ConfigName.TEST?2000:200); }); } + + private int deviceErrorCode = 0; + + public int getDeviceErrorCode() { + return deviceErrorCode; + } + + public void setDeviceErrorCode(int deviceErrorCode) { + this.deviceErrorCode = deviceErrorCode; + } + + public boolean getDisconnect(){ + return isDisconnect; + } } diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/item_gx.java b/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/item_gx.java index 94da7960..da86092f 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/item_gx.java +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/item_gx.java @@ -9,4 +9,14 @@ public class item_gx { public String data; public boolean IsWL=false; + + @Override + public String toString() { + return "item_gx{" + + "name='" + name + '\'' + + ", datatype=" + datatype + + ", data='" + data + '\'' + + ", IsWL=" + IsWL + + '}'; + } } diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java index 539ec96b..3bcac745 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java +++ b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java @@ -1,8 +1,5 @@ package com.bonait.bnframework.ViewModel.FragmentViewModel; -import static com.bonait.bnframework.MainApplication.getContext; -import static com.lzy.okgo.utils.HttpUtils.runOnUiThread; - import android.annotation.SuppressLint; import android.graphics.Color; import android.os.Bundle; @@ -20,22 +17,15 @@ import android.widget.ArrayAdapter; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; import com.apkfuns.logutils.LogUtils; -import com.bonait.bnframework.HBL.DataUtil.DataConvertLib; import com.bonait.bnframework.HBL.DataUtil.ErrorCodeManager; -import com.bonait.bnframework.HBL.DataUtil.NotifyPropVar; import com.bonait.bnframework.HBL.Interface.IRunT; -import com.bonait.bnframework.HBL.Result.OperateResultT; import com.bonait.bnframework.HBL.Thread.ThreadManager; import com.bonait.bnframework.Model.ErrorCodeBean; import com.bonait.bnframework.R; -import com.bonait.bnframework.Service.ControlAdress; import com.bonait.bnframework.Service.ModbusHelper; -import com.bonait.bnframework.Service.PLCModel; import com.bonait.bnframework.common.base.BaseFragment; -import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.utils.DisplayManager; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.databinding.FragmentHomeDeviceBinding; @@ -58,8 +48,7 @@ public class HomeDeviceFragment extends BaseFragment { private List mainFoodList; private int seasoningPos = -1; private int mainFoodPos = -1; - private static final int MSG_UPDATE_STATUS = 1; - private static final int MSG_UPDATE_ERROR_CODE = 2; + private static final int MSG_FRESH_DEVICE = 1000; @@ -69,18 +58,17 @@ public class HomeDeviceFragment extends BaseFragment { public void handleMessage(@NonNull Message msg) { super.handleMessage(msg); switch (msg.what){ - case MSG_UPDATE_STATUS: - boolean status = (boolean) msg.obj; - changeTextDeviceStatus(2,status?"掉线":"在线"); - - break; - case MSG_UPDATE_ERROR_CODE: - int code = (int) msg.obj; + case MSG_FRESH_DEVICE: + if(hasMessages(MSG_FRESH_DEVICE)){ + removeMessages(MSG_FRESH_DEVICE); + } + sendEmptyMessageDelayed(MSG_FRESH_DEVICE,500); for(ErrorCodeBean bean : ErrorCodeManager.getInstance().getDataBeans()){ - if(bean.getCode() == code){ + if(bean.getCode() == ModbusHelper.get().getDeviceErrorCode()){ changeTextDeviceStatus(1,bean.getName()+" "+bean.getDescription()); } } + changeTextDeviceStatus(2,ModbusHelper.get().getConnected()?"在线":"掉线"); break; } } @@ -121,87 +109,13 @@ public class HomeDeviceFragment extends BaseFragment { mainFoodList.add("主料仓4(投料4)"); mainFoodList.add("主料仓5(投料5)"); mainFoodList.add("主料仓6(投料6)"); - handler.post(() -> { - try { - PLCModel statusModel = ModbusHelper.get().controlAddress.get(ControlAdress.状态读取); -// ModbusHelper.get().WriteBool(ModbusHelper.get().getPLC(ControlAdress.状态读取启动).PlcAddress,true); - OperateResultT res = ModbusHelper.get().ReadShort(statusModel.PlcAddress,1); - byte[] bytes = DataConvertLib.shorts2Bytes(res.Content); - if(bytes.length>=2){ - progressFire = bytes[1] & 0xFF; - } - if(!release){ - viewBinding.fireProgress.setValue(progressFire,true); - } + if(handler.hasMessages(MSG_FRESH_DEVICE)){ + handler.removeMessages(MSG_FRESH_DEVICE); + } + handler.sendEmptyMessageDelayed(MSG_FRESH_DEVICE,500); - PLCModel statusModel2 = ModbusHelper.get().controlAddress.get(ControlAdress.搅拌档位); - OperateResultT res2 = ModbusHelper.get().ReadShort(statusModel2.PlcAddress,1); - byte[] bytes2 = DataConvertLib.shorts2Bytes(res2.Content); - progressStir = bytes2[0] & 0xFF; - if(!release){ - viewBinding.stirProgress.setValue(progressStir,true); - } - LogUtils.d("HomeDeviceFragment initData progressFire="+progressFire +" progressStir="+progressStir); - }catch (Exception e){ - LogUtils.d(e.getMessage()+""); - } - }); - NotifyPropVar notifyPropVar1 = (NotifyPropVar)ModbusHelper.get().getPLC(ControlAdress.状态读取).Value; - notify1 = new IRunT() { - @Override - public void Run(short[] shorts) { - byte[] bytes = DataConvertLib.shorts2Bytes(shorts); - String result = DataConvertLib.bytesToString(bytes); - if(ConfigName.LOG_TEST){ - LogUtils.d("HomeDeviceFragment result="+result +" bytes.length="+bytes.length); - } - if(handler!=null){ - if(ErrorCodeManager.getInstance().getDataBeans()!=null){ - int code = 0; - if(bytes.length>=2){ - code = bytes[0] & 0xFF; - if(ConfigName.LOG_TEST){ - LogUtils.d("HomeDeviceFragment code="+code ); - } - } - Message message = new Message(); - message.what = MSG_UPDATE_ERROR_CODE; - message.obj = code; - if(handler.hasMessages(MSG_UPDATE_ERROR_CODE)){ - handler.removeMessages(MSG_UPDATE_ERROR_CODE); - } - handler.sendMessageDelayed(message,500); - } - } - } - }; - if(notifyPropVar1!=null){ - notifyPropVar1.Register(HomeDeviceFragment.class.getSimpleName(), notify1); - } - - NotifyPropVar notifyPropVar = (NotifyPropVar)ModbusHelper.get().getPLC(ControlAdress.掉线标志).Value; - notify = new IRunT() { - @Override - public void Run(Boolean status) { - if(ConfigName.LOG_TEST){ - LogUtils.d("HomeDeviceFragment status="+status ); - } - if(handler!=null){ - Message message = new Message(); - message.what = 1; - message.obj = status; - if(handler.hasMessages(MSG_UPDATE_STATUS)){ - handler.removeMessages(MSG_UPDATE_STATUS); - } - handler.sendMessageDelayed(message,500); - } - } - }; - if(notifyPropVar!=null){ - notifyPropVar.Register(HomeDeviceFragment.class.getSimpleName(), notify); - } } private void initView(){ diff --git a/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsProcessDetailDBUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsProcessDetailDBUtil.java index a88d24ab..0a978243 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsProcessDetailDBUtil.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsProcessDetailDBUtil.java @@ -74,14 +74,14 @@ public class GoodsProcessDetailDBUtil { public static ArrayList getByGroupId(String groupId) { String orderby = QueryDB.Desc_Sort_Up + ',' + QueryDB.Desc_Time_Up; String where = "goodsSubAttributeGroupId=?"; - String[] args = new String[]{"0", groupId}; + String[] args = new String[]{groupId}; ArrayList data = new ArrayList<>(); ArrayList obj = QueryDB.Get(BPA_GOODS_PROCESS_DETAIL.class, where, args, orderby); for (Object item : obj) { BPA_GOODS_PROCESS_DETAIL k = (BPA_GOODS_PROCESS_DETAIL) item; data.add(k); } - LogUtils.d("getByGroupId 根据商品属性组合查询旗下的工序列表 data=" + data.toString()); + LogUtils.d("getByGroupId 根据商品属性组合查询旗下的工序列表 groupId="+groupId+" ;data=" + data.toString()); return data; } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java index 3b5f32ec..23988ee7 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java @@ -94,7 +94,7 @@ public class SubAttributeGroupDBUtil { * @return BPA_GOODS_SUBATTRIBUTE_GROUP */ public static BPA_GOODS_SUBATTRIBUTE_GROUP getById(String id) { - String orderby = QueryDB.Desc_Sort_Up; + String orderby = QueryDB.Desc_Time_Up; String where = "isDelete=? and id=?"; String[] args = new String[]{"0", id}; ArrayList obj = QueryDB.Get(BPA_GOODS_SUBATTRIBUTE_GROUP.class, where, args, orderby); @@ -108,7 +108,7 @@ public class SubAttributeGroupDBUtil { * @return BPA_GOODS_SUBATTRIBUTE_GROUP */ public static BPA_GOODS_SUBATTRIBUTE_GROUP getByName(String name) { - String orderby = QueryDB.Desc_Sort_Up; + String orderby = QueryDB.Desc_Time_Up; String where = "isDelete=? and name=?"; String[] args = new String[]{"0", name}; ArrayList obj = QueryDB.Get(BPA_GOODS_SUBATTRIBUTE_GROUP.class, where, args, orderby); @@ -122,7 +122,7 @@ public class SubAttributeGroupDBUtil { * @return BPA_GOODS_SUBATTRIBUTE_GROUP */ public static BPA_GOODS_SUBATTRIBUTE_GROUP getByGoodIdAndListId(String goodsId,String subAttributeIdList) { - String orderby = QueryDB.Desc_Sort_Up; + String orderby = QueryDB.Desc_Time_Up; String where = "isDelete=? and goodsId=? and subAttributeIdList=?"; String[] args = new String[]{"0",goodsId, subAttributeIdList}; ArrayList obj = QueryDB.Get(BPA_GOODS_SUBATTRIBUTE_GROUP.class, where, args, orderby); @@ -138,7 +138,7 @@ public class SubAttributeGroupDBUtil { * @return ArrayList */ public static ArrayList getByGoodsId(String goodsId) { - String orderby = QueryDB.Desc_Sort_Up; + String orderby = QueryDB.Desc_Time_Up; String where = "isDelete=? and goodsId=?"; String[] args = new String[]{"0",goodsId}; ArrayList data = new ArrayList<>(); diff --git a/app/src/main/java/com/bonait/bnframework/common/utils/DisplayManager.java b/app/src/main/java/com/bonait/bnframework/common/utils/DisplayManager.java index 1805d6bc..64e18e6c 100644 --- a/app/src/main/java/com/bonait/bnframework/common/utils/DisplayManager.java +++ b/app/src/main/java/com/bonait/bnframework/common/utils/DisplayManager.java @@ -461,6 +461,18 @@ public class DisplayManager } } + /** + * 判断是否需要缩放 避免adapter重绘时多次缩放 + * @param view + * @return + */ + public static boolean shouldScale(TextView view){ + if(view.getTextSize()> 34 || view.getTextSize()< 30){ + return true; + } + return false; + } + public static void scaleViewRemote(View view) { scaleView(view,(float) mfDeviceScaleRate); diff --git a/app/src/main/java/com/bonait/bnframework/ui/activity/DiyProcessActivity.java b/app/src/main/java/com/bonait/bnframework/ui/activity/DiyProcessActivity.java index 4dad90b9..453acadb 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/activity/DiyProcessActivity.java +++ b/app/src/main/java/com/bonait/bnframework/ui/activity/DiyProcessActivity.java @@ -2,6 +2,7 @@ package com.bonait.bnframework.ui.activity; import static com.bonait.bnframework.MainApplication.getContext; +import android.annotation.SuppressLint; import android.content.Intent; import android.os.Bundle; import android.view.View; @@ -9,25 +10,30 @@ import android.widget.AdapterView; import android.widget.ArrayAdapter; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.R; -import com.bonait.bnframework.ViewModel.CustomView.fragment_gx; import com.bonait.bnframework.ViewModel.CustomView.item_gx; import com.bonait.bnframework.common.base.BaseActivity; import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_GOODS; -import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; +import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; import com.bonait.bnframework.common.db.mode.BPA_PROCESS; import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel; import com.bonait.bnframework.common.db.util.GoodsDBUtil; -import com.bonait.bnframework.common.utils.AlertDialogUtils; +import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil; import com.bonait.bnframework.common.utils.DisplayManager; +import com.bonait.bnframework.common.utils.ProcessValueUtil; import com.bonait.bnframework.databinding.ActivityEditProcessBinding; -import com.bonait.bnframework.databinding.DialogDeleteClassifyBinding; +import com.bonait.bnframework.ui.adapter.DiyStepAdapter; +import com.bonait.bnframework.ui.dialog.AttributeSelectDialog; +import com.bonait.bnframework.ui.widget.NewToastUtil; +import com.bonait.bnframework.ui.widget.ProcessValueView; import java.util.ArrayList; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -45,7 +51,7 @@ public class DiyProcessActivity extends BaseActivity { /** * 1-6个主料仓名称 */ - ArrayList mainFoods = new ArrayList<>(); + private ArrayList mainFoods = new ArrayList<>(); /** * 商品id @@ -68,7 +74,16 @@ public class DiyProcessActivity extends BaseActivity { /** * 工序步骤 */ - public ArrayList goodsRecipes = new ArrayList<>(); + private ArrayList processDetails = new ArrayList<>(); + + /** + * 左边步骤adapter + */ + private DiyStepAdapter stepAdapter; + /** + * 导入已有属性组合弹窗 + */ + private AttributeSelectDialog attributeSelectDialog; @Override @@ -80,18 +95,161 @@ public class DiyProcessActivity extends BaseActivity { DisplayManager.scaleViewGroup(viewBinding.getRoot()); Intent intent = getIntent(); if(intent != null){ - mainFoods = intent.getStringArrayListExtra("mainFoods"); + if(intent.getStringArrayListExtra("mainFoods")!=null){ + mainFoods = intent.getStringArrayListExtra("mainFoods"); + } goodId = intent.getStringExtra("goodId"); subAttributeGroupId = intent.getStringExtra("subAttributeGroupId"); subAttributeGroupName = intent.getStringExtra("subAttributeGroupName"); } + if(mainFoods.isEmpty()){ + mainFoods.add(""); + mainFoods.add(""); + mainFoods.add(""); + mainFoods.add(""); + mainFoods.add(""); + mainFoods.add(""); + } initView(); - initData(); initTopBar(); } + /** + * 初始化视图 + * + */ + private void initView(){ + BPA_GOODS goods = GoodsDBUtil.getById(goodId); + if(goods!=null){ + viewBinding.title.setText(subAttributeGroupName.isEmpty() ? goods.name:(goods.name+"——"+subAttributeGroupName)); + } + initProcessModel(); + initStepAdapter(); + initBtnListener(); + } + + /** + * 左边步骤列表初始化 + */ + private void initStepAdapter(){ + stepAdapter = new DiyStepAdapter() { + @Override + protected void clickMoveUp(int position) { + int index_up = stepAdapter.getCurrentPosition(); + if (index_up > 0) { + BPA_GOODS_PROCESS_DETAIL obj_up = (BPA_GOODS_PROCESS_DETAIL) processDetails.get(index_up); + processDetails.remove(obj_up); + processDetails.add(index_up - 1, obj_up); + //移动光标 + setSelectPos(index_up - 1); + } else { + NewToastUtil.getInstance().showToast("已经是最顶部!"); + } + } + + @Override + protected void clickMoveDown(int position) { + int index_down = stepAdapter.getCurrentPosition(); + if (index_down < processDetails.size() - 1 && index_down >= 0) { + BPA_GOODS_PROCESS_DETAIL obj_down = (BPA_GOODS_PROCESS_DETAIL) processDetails.get(index_down); + processDetails.remove(obj_down); + processDetails.add(index_down + 1, obj_down); + //移动光标 + setSelectPos(index_down + 1); + } else { + NewToastUtil.getInstance().showToast("已经是最底部!"); + } + } + + @Override + protected void onItemClick(View v, int position) { + updateProcessSpinner(mData.get(position)); + } + }; + processDetails = GoodsProcessDetailDBUtil.getByGroupId(subAttributeGroupId); + stepAdapter.setCurrentPosition(0); + stepAdapter.setNewData(processDetails); + if(!processDetails.isEmpty()){ + updateProcessSpinner(processDetails.get(0)); + } + viewBinding.recycleStep.setItemAnimator(null); + viewBinding.recycleStep.setHasFixedSize(true); +// viewBinding.recycleStep.addItemDecoration(new RecyclerView.ItemDecoration() { +// @Override +// public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { +// super.getItemOffsets(outRect, view, parent, state); +// outRect.right = DimensUtil.getDimens(32); +// } +// }); + viewBinding.recycleStep.setAdapter(stepAdapter); + } + + /** + * 按钮点击监听 + */ + private void initBtnListener(){ + viewBinding.btnAdd.setOnClickListener(view -> { + addProcess(); + }); + viewBinding.btnUpdate.setOnClickListener(view -> { + updateProcess(); + }); + viewBinding.btnDelete.setOnClickListener(view -> { + deleteProcess(); + }); + //模拟炒制 + viewBinding.btnSimulation.setOnClickListener(view -> { + //TODO 跳转 + }); + viewBinding.llInsert.setVisibility(View.GONE); + viewBinding.btnInsert.setOnClickListener(view -> { + if(viewBinding.llInsert.getVisibility() == View.VISIBLE){ + viewBinding.llInsert.setVisibility(View.GONE); + viewBinding.llInsert.animate() + .translationY(viewBinding.llInsert.getHeight()) + .setDuration(300) + .start(); + }else{ + viewBinding.llInsert.setVisibility(View.VISIBLE); + viewBinding.llInsert.animate() + .translationY(0) + .setDuration(300) + .start(); + } + }); + viewBinding.btnInsertUp.setOnClickListener(view -> { + insertUpProcess(); + }); + viewBinding.btnInsertDown.setOnClickListener(view -> { + insertDownProcess(); + }); + viewBinding.btnCopyProcess.setOnClickListener(view -> { + if(attributeSelectDialog == null){ + attributeSelectDialog = new AttributeSelectDialog(); + } + Bundle bundle = new Bundle(); + bundle.putString("goodId",goodId); + bundle.putString("groupId",subAttributeGroupId); + attributeSelectDialog.setArguments(bundle); + attributeSelectDialog.setListener(new AttributeSelectDialog.DialogCallBack() { + @Override + public void submit() { + processDetails = GoodsProcessDetailDBUtil.getByGroupId(subAttributeGroupId); + stepAdapter.setCurrentPosition(0); + stepAdapter.setNewData(processDetails); + if(!processDetails.isEmpty()){ + updateProcessSpinner(processDetails.get(0)); + } + } + }); + attributeSelectDialog.show(getSupportFragmentManager(),"导入工序dialog"); + }); + } - private void initData(){ + /** + * 初始化工序模型 + */ + private void initProcessModel(){ //初始化工序 ArrayList data = QueryDB.GetProcessALL(); int i = 0; @@ -112,39 +270,212 @@ public class DiyProcessActivity extends BaseActivity { @Override public void onItemSelected(AdapterView adapterView, View view, int i, long l) { String id = processMap.get(viewBinding.spinnerProcess.getSelectedItem().toString()); - SelectItemFrom(id); + selectItemFrom(id); } @Override public void onNothingSelected(AdapterView adapterView) { } }); - SelectItemFrom(id); + selectItemFrom(id); + } - //3.工序步骤 -// gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item1, (List) bpa_goodsrecipes, null); -// datatab_gxbz.setAdapter(gxbz_adapter); -// datatab_gxbz.setOnItemClickListener(new AdapterView.OnItemClickListener() { -// @Override -// public void onItemClick(AdapterView parent, View view, int position, long l) { -// // TODO Auto-generated method stub -// gxbz_adapter.setSelectedPosition(position); -// gxbz_adapter.notifyDataSetInvalidated(); -// -// SetSelectGX(bpa_goodsrecipes.get(position));//单击工序行,显示变量 -// } -// }); + /** + * 添加工序 + */ + private void addProcess(){ + BPA_GOODS_PROCESS_DETAIL goodsrecipe = getSelectItemFromValue(); + if (goodsrecipe != null) { + BPA_GOODS_PROCESS_DETAIL processDetail = getSelectItemFromValue(); + GoodsProcessDetailDBUtil.add(processDetail); + processDetails.add(processDetail); + stepAdapter.setCurrentPosition(processDetails.size()-1); + stepAdapter.notifyDataSetChanged(); + viewBinding.recycleStep.smoothScrollToPosition(processDetails.size()-1); + }else { + NewToastUtil.getInstance().showToast("参数错误!"); + } } - private void initView(){ -// SubAttributeGroupDBUtil.getByGoodIdAndListId(goodId,subAttributeGroupId); - BPA_GOODS goods = GoodsDBUtil.getById(goodId); - viewBinding.title.setText(goods==null?(subAttributeGroupName+""):(goods.name+subAttributeGroupName)); + /** + * 向上插入工序 + */ + private void insertUpProcess(){ + BPA_GOODS_PROCESS_DETAIL goodSrecipeUp = getSelectItemFromValue(); + if (goodSrecipeUp != null) { + int index_update = stepAdapter.getCurrentPosition(); + if (index_update >= 0 && processDetails.size()>0) { + BPA_GOODS_PROCESS_DETAIL processDetail = getSelectItemFromValue(); + GoodsProcessDetailDBUtil.add(processDetail); + processDetails.add(index_update,processDetail); + stepAdapter.setCurrentPosition(index_update); + stepAdapter.notifyDataSetChanged(); + viewBinding.recycleStep.smoothScrollToPosition(index_update); + }else { + NewToastUtil.getInstance().showToast("请先选择步骤!"); + } + } + } + /** + * 向下插入工序 + */ + private void insertDownProcess(){ + BPA_GOODS_PROCESS_DETAIL goodSrecipeUp = getSelectItemFromValue(); + if (goodSrecipeUp != null) { + int index_update = stepAdapter.getCurrentPosition(); + if (index_update >= 0 && !processDetails.isEmpty()) { + BPA_GOODS_PROCESS_DETAIL processDetail = getSelectItemFromValue(); + GoodsProcessDetailDBUtil.add(processDetail); + processDetails.add(index_update+1,processDetail); + stepAdapter.setCurrentPosition(index_update+1); + stepAdapter.notifyDataSetChanged(); + viewBinding.recycleStep.smoothScrollToPosition(index_update+1); + }else { + NewToastUtil.getInstance().showToast("请先选择步骤!"); + } + } } - private void initTopBar(){ + /** + * 修改工序 + */ + private void updateProcess(){ + int index_update = stepAdapter.getCurrentPosition(); + if (index_update >= 0 && index_update < processDetails.size()) { + BPA_GOODS_PROCESS_DETAIL obj_update = (BPA_GOODS_PROCESS_DETAIL) processDetails.get(index_update); + String selectname = viewBinding.spinnerProcess.getSelectedItem().toString(); + if (!obj_update.processname.equals(selectname)) { + NewToastUtil.getInstance().showToast("请先选择步骤!"); + return; + } + BPA_GOODS_PROCESS_DETAIL processDetail = getSelectItemFromValue(); + GoodsProcessDetailDBUtil.update(processDetail); + processDetails.set(index_update, getSelectItemFromValue()); + stepAdapter.notifyDataSetChanged(); + NewToastUtil.getInstance().showToast("修改步骤[" + (index_update + 1) + ":" + obj_update.processname + "]成功!"); + } else { + NewToastUtil.getInstance().showToast("请先选择步骤!"); + } + } + /** + * 删除工序 + */ + private void deleteProcess(){ + int index_delete = stepAdapter.getCurrentPosition(); + if (index_delete >= 0 && index_delete < processDetails.size()) { + BPA_GOODS_PROCESS_DETAIL processDetail = (BPA_GOODS_PROCESS_DETAIL) processDetails.get(index_delete); + processDetails.remove(processDetail); + GoodsProcessDetailDBUtil.delete(processDetail); + stepAdapter.notifyDataSetChanged(); + //移动光标 + if (index_delete - 1 >= 0) { + setSelectPos(index_delete - 1); + } + NewToastUtil.getInstance().showToast("删除步骤[" + processDetail.processname + "]成功!"); + } else { + NewToastUtil.getInstance().showToast("请先选择步骤!"); + } + } + + /** + * 获取右边工序的变量 + * + * @return + */ + public BPA_GOODS_PROCESS_DETAIL getSelectItemFromValue() { + BPA_GOODS_PROCESS_DETAIL processDetail = new BPA_GOODS_PROCESS_DETAIL(); + try { + processDetail.goodsSubAttributeGroupId = subAttributeGroupId; + String name = viewBinding.spinnerProcess.getSelectedItem().toString(); + boolean IsVerify = true; + StringBuilder description = new StringBuilder(); + // 延迟,100|延迟,100|延迟,100|延迟,100| + StringBuilder data = new StringBuilder(); + StringBuilder desc = new StringBuilder(); + if (name.contains("液体料")) { + processDetail.materialType = 0; + for (int i = 0; i < viewBinding.llProcessValue.getChildCount(); i++) { + ProcessValueView viw = (ProcessValueView) viewBinding.llProcessValue.getChildAt(i); + String values = viw.GetValues(); + if (!values.isEmpty()) { + data.append(viw.model.name).append(",").append(values).append("|"); + desc.append(values).append(","); + } + } + + if (data.length() == 0) { + IsVerify = false; + description.append("物料不能为空,请至少勾选一个物料"); + } + } else { + processDetail.materialType = 1; + String mainFoodName = ""; + int position = -1;//几号位 + for (int i = 0; i < viewBinding.llProcessValue.getChildCount(); i++) { + ProcessValueView viw = (ProcessValueView) viewBinding.llProcessValue.getChildAt(i); + String values = viw.GetValues(); + if (values.isEmpty()) { + IsVerify = false; + description.append(viw.model.name).append("不能为空"); + } else { + data.append(viw.model.name).append(",").append(values).append("|"); + desc.append(values).append(","); + } + + if(viw.model.name.contains("位置")){ + position = Integer.parseInt(values.replace("号位","")); + } + if(viw.model.name.contains("主料名称")){ + mainFoodName = values; + } + } + if(position>0){ + LogUtils.d(TAG+" getSelectItemFromValue 修改主料名称 old mainFoods="+mainFoods.toString()); + mainFoods.set(position-1,mainFoodName); + LogUtils.d(TAG+" getSelectItemFromValue 修改主料名称 new mainFoods="+mainFoods.toString()); + } + } + if (IsVerify) { + processDetail.processname = name; + processDetail.processms = name + "(" + desc.substring(0, desc.length() - 1) + ")"; + processDetail.processvalue = data.substring(0, data.length() - 1); + LogUtils.d("修改工序 pf="+processDetail.toString()); + return processDetail; + } else { + NewToastUtil.getInstance().showToast(description.toString()); + return null; + } + } catch (Exception ex) { + return null; + } + } + + /** + * 移动光标 选中步骤 + * @param index + */ + @SuppressLint("NotifyDataSetChanged") + public void setSelectPos(int index) { + stepAdapter.setCurrentPosition(index); + stepAdapter.notifyDataSetChanged(); + viewBinding.recycleStep.smoothScrollToPosition(index); + updateProcessSpinner(stepAdapter.getData().get(index)); + } + + /** + * 栏目 + */ + private void initTopBar(){ + viewBinding.topbar.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.topbj1)); + viewBinding.topbar.setTitle("编辑工序"); + viewBinding.topbar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); } /** @@ -152,21 +483,26 @@ public class DiyProcessActivity extends BaseActivity { * * @param id */ - public void SelectItemFrom(String id) { + public void selectItemFrom(String id) { try { viewBinding.llProcessValue.removeAllViews(); ArrayList mode = QueryDB.GetProcessModelProcessID(id); + LogUtils.d(TAG+" selectItemFrom id="+id +" mode="+mode.toString() ); if (!mode.isEmpty())//工序 { + LogUtils.d("SelectItemFrom 1"); for (BPA_PROCESSModel item : mode) { item_gx gx = new item_gx(); gx.datatype = item.datatype; gx.name = item.name; gx.data = item.data; gx.IsWL = false; - fragment_gx gongxu = new fragment_gx(this, null, gx); + ProcessValueView view = new ProcessValueView(this, null, gx); + if(item.datatype == 2){ + view.setListener(spinnerSelectListener); + } LogUtils.d("SelectItemFrom gx="+gx.toString()); - viewBinding.llProcessValue.addView(gongxu); + viewBinding.llProcessValue.addView(view); } } else //物料 { @@ -176,12 +512,66 @@ public class DiyProcessActivity extends BaseActivity { gx.datatype = 0;//液体料都是数字 gx.name = item2.name; gx.IsWL = true; - fragment_gx gongxu = new fragment_gx(this, null, gx); + ProcessValueView gongxu = new ProcessValueView(this, null, gx); LogUtils.d("SelectItemFrom gx="+gx.toString()); viewBinding.llProcessValue.addView(gongxu); } } } catch (Exception ex) { + LogUtils.d("SelectItemFrom ex="+ex.getMessage()); + ex.printStackTrace(); + } + } + + /** + * 右边工序变量选项监听 + */ + private ProcessValueView.SpinnerSelectCallBack spinnerSelectListener = new ProcessValueView.SpinnerSelectCallBack() { + + @Override + public void onSelect(int position,String name) { + for (int i = 0; i < viewBinding.llProcessValue.getChildCount(); i++) { + ProcessValueView processValueView = (ProcessValueView) viewBinding.llProcessValue.getChildAt(i); + if(processValueView.model.name.equals("主料名称")){ + if(!mainFoods.isEmpty() && mainFoods.size()>position){ + processValueView.setMainFoodName(mainFoods.get(position)); + } + } + } + } + + + }; + + /** + * 根据选中步骤显示变量 + * + * @param processDetail + */ + public void updateProcessSpinner(BPA_GOODS_PROCESS_DETAIL processDetail) { + try { + //1.根据工序名称显示工序集合 + viewBinding.spinnerProcess.setSelection(processMapIndex.get(processDetail.processname)); + String id = processMap.get(viewBinding.spinnerProcess.getSelectedItem().toString()); + selectItemFrom(id); + //2.根据工序变量集合-获取变量名称和值 + HashMap formulation = ProcessValueUtil.dealProcessValue(processDetail.processvalue); + + for (int i = 0; i < viewBinding.llProcessValue.getChildCount(); i++) { + ProcessValueView processValueView = (ProcessValueView) viewBinding.llProcessValue.getChildAt(i); + String res = formulation.get(processValueView.model.name); + if (res != null) { + processValueView.SetValues(res); + }else { + if(processValueView.model.name.equals("主料名称")){ + processValueView.setMainFoodName(mainFoods.get(0)); + } + } + } + + LogUtils.e("SetSelectGX formulation="+formulation.toString()); + } catch (Exception ex) { + NewToastUtil.getInstance().showToastRedColor(this,"异常:"+ex.getMessage(),ex.getMessage()); } } @@ -192,42 +582,12 @@ public class DiyProcessActivity extends BaseActivity { super.onActivityResult(requestCode, resultCode, data); LogUtils.d(TAG+" onActivityResult requestCode="+requestCode+" resultCode="+resultCode+" data="+data); if (requestCode == REQUEST_RECORD_ACTIVITY&& resultCode==RESULT_OK) { - if(data!=null){ - - if(data.getSerializableExtra("goodsRecipes")!=null){ - goodsRecipes.clear(); - try { - goodsRecipes =(ArrayList) data.getSerializableExtra("goodsRecipes"); - }catch (Exception e){ - e.printStackTrace(); - } - } + //录制页面返回 是否替换所有工序 + if (data!=null && data.getBooleanExtra("update",false)){ + processDetails.clear(); + processDetails.addAll(GoodsProcessDetailDBUtil.getByGroupId(subAttributeGroupId)); + stepAdapter.notifyDataSetChanged(); } - AlertDialogUtils.showCancelAndConfirmDialog(this, R.layout.dialog_delete_classify, (layoutView, xCom) -> { - DialogDeleteClassifyBinding binding = DialogDeleteClassifyBinding.bind(layoutView); - DisplayManager.scaleViewGroup(binding.getRoot()); - binding.title.setText("修改工序"); - binding.edit.setText("是否删除所有工序,并替换为录制的工序?"); - binding.submit.setOnClickListener(view1 -> { -// if(GoodsClassifyDBUtil.deleteById(classifyId)){ -// AttributeDBUtil.deleteByClassifyId(classifyId); -// GoodsDBUtil.deleteByClassifyId(classifyId); -// SubAttributeGroupDBUtil.deleteByClassifyId(classifyId); -// SubAttributeDBUtil.deleteByClassifyId(classifyId); -// -// classifyList.remove(classifyName); -// classifyNameList.clear(); -// classifyNameList.addAll(classifyList.keySet()); -// spinnerAdapter.notifyDataSetChanged(); -// selectClassify(classifyPosition-1);//更新数据 -// ToastUtils.info("删除["+classifyName+"]成功!"); -// xCom.dismissX(); -// }else { -// ToastUtils.info("删除["+classifyName+"]失败!"); -// } -// gxbz_adapter.notifyDataSetChanged(); - }); - }); } } } diff --git a/app/src/main/java/com/bonait/bnframework/ui/activity/EditClassifyActivity.java b/app/src/main/java/com/bonait/bnframework/ui/activity/EditClassifyActivity.java index 14fd2555..d80defea 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/activity/EditClassifyActivity.java +++ b/app/src/main/java/com/bonait/bnframework/ui/activity/EditClassifyActivity.java @@ -7,7 +7,6 @@ import android.view.MotionEvent; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; -import android.widget.Toast; import androidx.annotation.Nullable; @@ -316,6 +315,9 @@ public class EditClassifyActivity extends BaseActivity { DisplayManager.scaleViewGroup(binding.getRoot()); binding.title.setText("删除分类名称"); binding.edit.setText("是否删除["+classifyName+"]分类下所有商品及属性?"); + binding.cancel.setOnClickListener(view1 ->{ + xCom.dismissX(); + }); binding.submit.setOnClickListener(view1 -> { if(GoodsClassifyDBUtil.deleteById(classifyId)){ AttributeDBUtil.deleteByClassifyId(classifyId); @@ -394,7 +396,7 @@ public class EditClassifyActivity extends BaseActivity { String classifyId = classifyList.get(viewBinding.spinnerClassify.getSelectedItem().toString()); String goodName = SubAttributeGroupDBUtil.isIncludeByClassify(classifyId,bean.name); if(!goodName.isEmpty()){ - NewToastUtil.showToast(this,"商品["+goodName+"]正在使用["+bean.name+"]属性,请先删除对应商品", Toast.LENGTH_SHORT); + NewToastUtil.getInstance().showToast("商品["+goodName+"]正在使用["+bean.name+"]属性,请先删除对应商品"); return; } } @@ -460,7 +462,7 @@ public class EditClassifyActivity extends BaseActivity { String classifyId = classifyList.get(viewBinding.spinnerClassify.getSelectedItem().toString()); String goodName = SubAttributeGroupDBUtil.isIncludeByClassify(classifyId,bean.name); if(!goodName.isEmpty()){ - NewToastUtil.showToast(this,"商品["+goodName+"]正在使用["+bean.name+"]属性,请先删除对应商品", Toast.LENGTH_SHORT); + NewToastUtil.getInstance().showToast("商品["+goodName+"]正在使用["+bean.name+"]属性,请先删除对应商品"); return; } SubAttributeDBUtil.delete(bean); diff --git a/app/src/main/java/com/bonait/bnframework/ui/adapter/ClassifyAdapter.java b/app/src/main/java/com/bonait/bnframework/ui/adapter/ClassifyAdapter.java index 3b9fc001..261e763e 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/adapter/ClassifyAdapter.java +++ b/app/src/main/java/com/bonait/bnframework/ui/adapter/ClassifyAdapter.java @@ -30,6 +30,9 @@ public abstract class ClassifyAdapter extends BaseAdapter34||holder.binding.name.getTextSize()<30){ DisplayManager.scaleViewGroup(holder.binding.getRoot()); } diff --git a/app/src/main/java/com/bonait/bnframework/ui/adapter/DiyStepAdapter.java b/app/src/main/java/com/bonait/bnframework/ui/adapter/DiyStepAdapter.java new file mode 100644 index 00000000..1adec460 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/ui/adapter/DiyStepAdapter.java @@ -0,0 +1,82 @@ +package com.bonait.bnframework.ui.adapter; + +import android.annotation.SuppressLint; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.bonait.bnframework.common.base.BaseAdapter; +import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL; +import com.bonait.bnframework.common.utils.DisplayManager; +import com.bonait.bnframework.databinding.ItemStepBinding; + +/** + * @author: liup + * @description: 商品列表 + * @date: 2024/5/8 15:36. + */ +public abstract class DiyStepAdapter extends BaseAdapter { + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new ViewHolder(ItemStepBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, @SuppressLint("RecyclerView") int position) { + try { + if(DisplayManager.shouldScale(holder.binding.name)){ + DisplayManager.scaleViewGroup(holder.binding.getRoot()); + } + holder.binding.root.setSelected(mCurrentPosition == position); + holder.binding.removeUp.setVisibility(mCurrentPosition == position?View.VISIBLE:View.GONE); + holder.binding.removeDown.setVisibility(mCurrentPosition == position?View.VISIBLE:View.GONE); + holder.binding.name.setText("1."+mData.get(position).processname); + holder.binding.root.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int last = mCurrentPosition; + mCurrentPosition = position; + notifyItemChanged(last); + notifyItemChanged(mCurrentPosition); + onItemClick(view,position); + } + }); + holder.binding.removeDown.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + clickMoveDown(position); + } + }); + holder.binding.removeUp.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + clickMoveUp(position); + } + }); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + public static class ViewHolder extends RecyclerView.ViewHolder { + private ItemStepBinding binding; + + + public ViewHolder(ItemStepBinding view) { + super(view.getRoot()); + binding = view; + } + } + + protected abstract void clickMoveUp(int position); + protected abstract void clickMoveDown(int position); +} + + diff --git a/app/src/main/java/com/bonait/bnframework/ui/adapter/LocalGoodsAdapter.java b/app/src/main/java/com/bonait/bnframework/ui/adapter/LocalGoodsAdapter.java index 4641193d..ebbf14ea 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/adapter/LocalGoodsAdapter.java +++ b/app/src/main/java/com/bonait/bnframework/ui/adapter/LocalGoodsAdapter.java @@ -32,7 +32,7 @@ public abstract class LocalGoodsAdapter extends BaseAdapter28||holder.binding.name.getTextSize()<24){ + if(holder.binding.name.getTextSize()> 34 || holder.binding.name.getTextSize()< 30){ DisplayManager.scaleViewGroup(holder.binding.getRoot()); } holder.binding.add.setVisibility(View.GONE); diff --git a/app/src/main/java/com/bonait/bnframework/ui/adapter/SelectAttributeListAdapter.java b/app/src/main/java/com/bonait/bnframework/ui/adapter/SelectAttributeListAdapter.java index 049fa11f..e8e5e12f 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/adapter/SelectAttributeListAdapter.java +++ b/app/src/main/java/com/bonait/bnframework/ui/adapter/SelectAttributeListAdapter.java @@ -97,7 +97,7 @@ public class SelectAttributeListAdapter extends ArrayAdapter { } } String groupName = list.length()>0?list.substring(0,list.length()-1):""; - LogUtils.d(" getSubAttributeList groupName="+groupName); + LogUtils.d(" getSubAttributeNameList groupName="+groupName); return groupName; } @@ -108,11 +108,11 @@ public class SelectAttributeListAdapter extends ArrayAdapter { StringBuilder list = new StringBuilder(); for (SelectSubAttributeAdapter adapter:subAttributeAdapters){ if(adapter.getCurrentPosition() >= 0 && adapter.getData().size()>adapter.getCurrentPosition()){ - list.append(adapter.getData().get(adapter.getCurrentPosition()).name).append(","); + list.append(adapter.getData().get(adapter.getCurrentPosition()).id).append(","); } } String groupName = list.length()>0?list.substring(0,list.length()-1):""; - LogUtils.d(" getSubAttributeList groupName="+groupName); + LogUtils.d(" getSubAttributeIdList groupids="+groupName); return groupName; } } diff --git a/app/src/main/java/com/bonait/bnframework/ui/dialog/AddGoodsDialog.java b/app/src/main/java/com/bonait/bnframework/ui/dialog/AddGoodsDialog.java index de7985a5..a5f62381 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/dialog/AddGoodsDialog.java +++ b/app/src/main/java/com/bonait/bnframework/ui/dialog/AddGoodsDialog.java @@ -13,7 +13,6 @@ import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.AdapterView; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -163,7 +162,7 @@ public class AddGoodsDialog extends DialogFragment { case 2: if(classifyList.isEmpty() || classifyPosition < 0 || classifyPosition>=classifyList.size()){ if(getContext()!=null){ - NewToastUtil.showToast(getContext(),"请选择分类", Toast.LENGTH_SHORT); + NewToastUtil.getInstance().showToast("请选择分类"); } return; } @@ -182,13 +181,13 @@ public class AddGoodsDialog extends DialogFragment { LogUtils.d(TAG+" name="+name); if(name.isEmpty()){ if(getContext()!=null){ - NewToastUtil.showToast(getContext(),"名称不能为空", Toast.LENGTH_SHORT); + NewToastUtil.getInstance().showToast("名称不能为空"); } return; } if(GoodsDBUtil.getByName(name)!=null){ if(getContext()!=null){ - NewToastUtil.showToast(getContext(),"已有菜品,请换一个名称", Toast.LENGTH_SHORT); + NewToastUtil.getInstance().showToast("已有菜品,请换一个名称"); } return; } diff --git a/app/src/main/java/com/bonait/bnframework/ui/dialog/AttributeSelectDialog.java b/app/src/main/java/com/bonait/bnframework/ui/dialog/AttributeSelectDialog.java new file mode 100644 index 00000000..86d2e184 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/ui/dialog/AttributeSelectDialog.java @@ -0,0 +1,188 @@ +package com.bonait.bnframework.ui.dialog; + +import android.content.DialogInterface; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.os.Bundle; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.DialogFragment; + +import com.apkfuns.logutils.LogUtils; +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE; +import com.bonait.bnframework.common.db.mode.BPA_GOODS; +import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL; +import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP; +import com.bonait.bnframework.common.db.util.AttributeDBUtil; +import com.bonait.bnframework.common.db.util.GoodsDBUtil; +import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil; +import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil; +import com.bonait.bnframework.common.utils.AlertDialogUtils; +import com.bonait.bnframework.common.utils.DisplayManager; +import com.bonait.bnframework.databinding.DialogAttributeSelectBinding; +import com.bonait.bnframework.databinding.DialogDeleteClassifyBinding; +import com.bonait.bnframework.ui.adapter.SelectAttributeListAdapter; +import com.bonait.bnframework.ui.widget.NewToastUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author: liup + * @description: + * @date: 2024/5/17 13:42. + */ +public class AttributeSelectDialog extends DialogFragment { + private String TAG = " AttributeSelectDialog =>"; + private DialogAttributeSelectBinding viewBinding; + private String goodId = ""; + private String groupId = ""; + private BPA_GOODS goods; + /** + * 属性列表 + */ + private List attributeList = new ArrayList<>(); + /** + * 属性组合 + */ + private SelectAttributeListAdapter selectAttributeListAdapter; + private DialogCallBack listener; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setStyle(STYLE_NORMAL, R.style.DialogLeft); + if (getArguments() != null) { + goodId = getArguments().getString("goodId"); + groupId = getArguments().getString("groupId"); + } + goods = GoodsDBUtil.getById(goodId); + if (goods != null) { + attributeList = AttributeDBUtil.getByClassify(goods.classifyId); + } + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + viewBinding = DialogAttributeSelectBinding.inflate(inflater, container, false); + DisplayManager.scaleViewGroup(viewBinding.getRoot()); + return viewBinding.getRoot(); + } + + @Override + public void onStart() { + super.onStart(); + if (getDialog() != null) { + Window window = getDialog().getWindow(); + assert window != null; + window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + WindowManager.LayoutParams params = window.getAttributes(); + params.gravity = Gravity.CENTER; + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + window.setAttributes(params); + } + updateAttributeData(); + initListener(); + } + + @Override + public void onDismiss(@NonNull DialogInterface dialog) { + super.onDismiss(dialog); + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + } + + /** + * 刷新属性数据 + */ + public void updateAttributeData(){ + LogUtils.d(TAG+" updateAttributeData"); + selectAttributeListAdapter = new SelectAttributeListAdapter(getContext(), R.layout.item_select_attribute_list,attributeList); + viewBinding.listAttribute.setAdapter(selectAttributeListAdapter); + } + + public void setListener(DialogCallBack listener){ + this.listener = listener; + } + + private void initListener(){ + viewBinding.btnClose.setOnClickListener(view -> { + dismiss(); + }); + viewBinding.btnClose2.setOnClickListener(view -> { + dismiss(); + }); + viewBinding.btnSubmit.setOnClickListener(view -> { + if(!selectAttributeListAdapter.isAllSelected()){ + if(getContext()!=null){ + NewToastUtil.getInstance().showToast("请选择每行对应的子属性"); + } + return; + } + BPA_GOODS_SUBATTRIBUTE_GROUP currentGroupBean = SubAttributeGroupDBUtil.getById(groupId); + if(currentGroupBean!=null){ + if(selectAttributeListAdapter.getSubAttributeIdList().equals(currentGroupBean.subAttributeIdList)){ + NewToastUtil.getInstance().showToast("当前正在编辑此组合,无法导入"); + return; + } + } + BPA_GOODS_SUBATTRIBUTE_GROUP group = SubAttributeGroupDBUtil.getByGoodIdAndListId(goodId,selectAttributeListAdapter.getSubAttributeIdList()); + if(group == null){ + NewToastUtil.getInstance().showToast("还未创建该组合,无法导入"); + return; + } + + List list = GoodsProcessDetailDBUtil.getByGroupId(group.id); + if(!list.isEmpty()){ + AlertDialogUtils.showCancelAndConfirmDialog((AppCompatActivity) getActivity(), R.layout.dialog_delete_classify, (layoutView, xCom) -> { + DialogDeleteClassifyBinding binding = DialogDeleteClassifyBinding.bind(layoutView); + DisplayManager.scaleViewGroup(binding.getRoot()); + binding.title.setText("导入工序"); + binding.edit.setText("导入后将覆盖当前所有工序,请确认"); + binding.cancel.setOnClickListener(view1 ->{ + xCom.dismissX(); + }); + binding.submit.setOnClickListener(view1 -> { + for (BPA_GOODS_PROCESS_DETAIL bean: list){ + BPA_GOODS_PROCESS_DETAIL newBean = new BPA_GOODS_PROCESS_DETAIL(); + newBean.goodsSubAttributeGroupId = groupId; + newBean.materialID = bean.materialID; + newBean.processms = bean.processms; + newBean.processname = bean.processname; + newBean.processvalue = bean.processvalue; + newBean.materialType = bean.materialType; + newBean.value = bean.value; + newBean.sort = bean.sort; + GoodsProcessDetailDBUtil.add(newBean); + } + xCom.dismissX(); + dismiss(); + if(listener!=null){ + listener.submit(); + } + }); + }); + }else { + NewToastUtil.getInstance().showToast("该组合没有工序,无法导入"); + } + }); + } + + public interface DialogCallBack{ + void submit(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/ui/dialog/DeviceControlDialog.java b/app/src/main/java/com/bonait/bnframework/ui/dialog/DeviceControlDialog.java new file mode 100644 index 00000000..aee1dbcd --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/ui/dialog/DeviceControlDialog.java @@ -0,0 +1,270 @@ +package com.bonait.bnframework.ui.dialog; + +import android.content.DialogInterface; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.os.Bundle; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; + +import com.apkfuns.logutils.LogUtils; +import com.bonait.bnframework.HBL.Thread.ThreadManager; +import com.bonait.bnframework.R; +import com.bonait.bnframework.Service.ModbusHelper; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_SILOS; +import com.bonait.bnframework.common.utils.DisplayManager; +import com.bonait.bnframework.databinding.DialogDeviceControlBinding; +import com.bonait.bnframework.ui.widget.NewToastUtil; +import com.litao.slider.NiftySlider; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author: liup + * @description: + * @date: 2024/5/20 17:51. + */ +public class DeviceControlDialog extends DialogFragment { + private String TAG = " DeviceControlDialog =>"; + private DialogDeviceControlBinding viewBinding; + private DeviceCallBack callBack; + /** + * 1加热 2调料 3主料 4搅拌 + */ + private int type = 0; + /** + * 火力档位 + */ + private int progressFire; + /** + * 搅拌档位 + */ + private int progressStir; + /** + * 料仓号 + */ + private int seasoningPos=-1; + /** + * 料仓列表 + */ + private List seasoningList = new ArrayList<>(); + /** + * 主料仓列表 + */ + private List mainFoodList = new ArrayList<>(); + + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setStyle(STYLE_NORMAL, R.style.DialogLeft); + if(getArguments()!=null){ + type = getArguments().getInt("type"); + } + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + viewBinding = DialogDeviceControlBinding.inflate(inflater, container, false); + DisplayManager.scaleViewGroup(viewBinding.getRoot()); + return viewBinding.getRoot(); + } + + @Override + public void onStart() { + super.onStart(); + if (getDialog() != null) { + Window window = getDialog().getWindow(); + assert window != null; + window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + WindowManager.LayoutParams params = window.getAttributes(); + params.gravity = Gravity.CENTER; + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + window.setAttributes(params); + } + initView(); + } + + private void initView(){ + viewBinding.layoutFire.getRoot().setVisibility(type==1?View.VISIBLE:View.GONE); + viewBinding.layoutSilos.getRoot().setVisibility(type==2?View.VISIBLE:View.GONE); + viewBinding.layoutFood.getRoot().setVisibility(type==3?View.VISIBLE:View.GONE); + viewBinding.layoutStir.getRoot().setVisibility(type==4?View.VISIBLE:View.GONE); + } + + private void initData(){ + seasoningList = new ArrayList<>(); + for(BPA_SILOS silos: QueryDB.GetSilosALL()){ + List materials = QueryDB.GetMaterialBySilosID(silos.id); + if(!materials.isEmpty()){ + String name = QueryDB.GetMaterialBySilosID(silos.id).get(0).name; + if(name!=null && !name.isEmpty()){ + seasoningList.add("液体"+silos.num+"("+name+")"); + }else { + seasoningList.add("液体"+silos.num+"(未设置)"); + } + }else { + seasoningList.add("液体"+silos.num+"(未设置)"); + } + } + mainFoodList = new ArrayList<>(); + mainFoodList.add("主料仓1"); + mainFoodList.add("主料仓2"); + mainFoodList.add("主料仓3"); + mainFoodList.add("主料仓4"); + mainFoodList.add("主料仓5"); + mainFoodList.add("主料仓6"); + } + + /** + * 加热模块 + */ + private void initFire(){ + //开始加热 + viewBinding.layoutFire.btnStartFire.setOnClickListener(view->{ + NewToastUtil.getInstance().showToast("启动加热 档位:"+progressFire); + ThreadManager.get().execute(new Thread(() -> ModbusHelper.get().Heating(progressFire,true))); + }); + //停止加热 + viewBinding.layoutFire.btnStopFire.setOnClickListener(view->{ + NewToastUtil.getInstance().showToast("停止加热"); + ThreadManager.get().execute(new Thread(() -> ModbusHelper.get().Heating(progressFire,false))); + }); + //档位条加减 + viewBinding.layoutFire.btnFireUp.setOnClickListener(view->{ + if(progressFire<10){ + progressFire++; + } + viewBinding.layoutFire.fireProgress.setValue(progressFire,true); + }); + viewBinding.layoutFire.btnFireDown.setOnClickListener(view->{ + if(progressFire>0){ + progressFire--; + } + viewBinding.layoutFire.fireProgress.setValue(progressFire,true); + }); + viewBinding.layoutFire.fireProgress.setValue(0,false); + //档位条 + viewBinding.layoutFire.fireProgress.setOnValueChangeListener(new NiftySlider.OnValueChangeListener() { + @Override + public void onValueChange(@NonNull NiftySlider niftySlider, float v, boolean b) { + viewBinding.layoutFire.fireProgress.setThumbText((int) v + ""); + progressFire = (int) v; + } + }); + } + + /** + * 液料模块 + */ + private void initSilos(){ + //加水 + viewBinding.layoutSilos.addWater.setOnClickListener(view->{ + String waterValue = viewBinding.layoutSilos.editWater.getText().toString(); + if(!waterValue.isEmpty()){ + NewToastUtil.getInstance().showToast("开始加水 "+waterValue+"g"); + ThreadManager.get().execute(new Thread(() -> { + ModbusHelper.get().addWater(Integer.parseInt(viewBinding.layoutSilos.editWater.getText().toString()),false); + })); + }else { + NewToastUtil.getInstance().showToast("值不能为空!"); + } + }); + //勾芡 + viewBinding.layoutSilos.addQianWater.setOnClickListener(view->{ + String value = viewBinding.layoutSilos.editQianWater.getText().toString(); + if(!value.isEmpty()){ + NewToastUtil.getInstance().showToast("开始勾芡 "+value+"g"); + ThreadManager.get().execute(new Thread(() -> { + ModbusHelper.get().addThickenWater(Integer.parseInt(viewBinding.layoutSilos.editQianWater.getText().toString()), false); + })); + }else { + NewToastUtil.getInstance().showToast("值不能为空!"); + } + }); + //调料 + viewBinding.layoutSilos.addQianWater.setOnClickListener(view->{ + String value2 = viewBinding.layoutSilos.editSeasoningWater.getText().toString(); + if(seasoningPos>=0){ + if(!value2.isEmpty()){ + NewToastUtil.getInstance().showToast("添加调料 "+(seasoningPos+1)+"号仓 "+value2+"g"); + ThreadManager.get().execute(new Thread(() -> { + ModbusHelper.get().addMaterial(Integer.parseInt(value2),(seasoningPos+1),false); + })); + }else { + NewToastUtil.getInstance().showToast("值不能为空!"); + } + }else { + NewToastUtil.getInstance().showToast("请选择仓号!"); + } + }); + ArrayAdapter adapter1 = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item_text_size26, seasoningList); + adapter1.setDropDownViewResource(R.layout.spinner_dropdown_item_text_size26); + viewBinding.layoutSilos.spinnerSeasoningWater.setAdapter(adapter1); + + viewBinding.layoutSilos.spinnerSeasoningWater.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + view.performClick(); + return false; + } + }); + viewBinding.layoutSilos.spinnerSeasoningWater.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView adapterView, View view, int i, long l) { + LogUtils.d(" ----- onItemSelected i="+i); + seasoningPos = i; + } + + @Override + public void onNothingSelected(AdapterView adapterView) { + } + }); + } + + /** + * 主料模块 + */ + private void initFood(){ + //开始加热 + + } + + /** + * 搅拌模块 + */ + private void initStir(){ + + } + + @Override + public void onDismiss(@NonNull DialogInterface dialog) { + super.onDismiss(dialog); + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + } + + public interface DeviceCallBack{ + void onClickEvent(int type,String value); + } + +} diff --git a/app/src/main/java/com/bonait/bnframework/ui/dialog/EditGoodsDialog.java b/app/src/main/java/com/bonait/bnframework/ui/dialog/EditGoodsDialog.java index 88318770..879be356 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/dialog/EditGoodsDialog.java +++ b/app/src/main/java/com/bonait/bnframework/ui/dialog/EditGoodsDialog.java @@ -12,7 +12,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -129,7 +128,7 @@ public class EditGoodsDialog extends DialogFragment { */ @SuppressLint("NonConstantResourceId") @OnClick({R.id.btn_close1, R.id.btn_close2,R.id.btn_close3, - R.id.btn_next1,R.id.btn_next2,R.id.btn_next3,R.id.btn_last1,R.id.btn_last3, + R.id.btn_next1,R.id.btn_next2,R.id.btn_to_cook,R.id.btn_last1,R.id.btn_edit_process, R.id.good_image,R.id.btn_last2}) public void onViewClicked(View view) { switch (view.getId()) { @@ -143,7 +142,7 @@ public class EditGoodsDialog extends DialogFragment { String name = viewBinding.layoutName.editName.getText().toString(); if(name.isEmpty()){ if(getContext()!=null){ - NewToastUtil.showToast(getContext(),"名称不能为空", Toast.LENGTH_SHORT); + NewToastUtil.getInstance().showToast("名称不能为空"); } return; } @@ -162,16 +161,16 @@ public class EditGoodsDialog extends DialogFragment { case R.id.btn_next2: if(!selectAttributeListAdapter.isAllSelected()){ if(getContext()!=null){ - NewToastUtil.showToast(getContext(),"请选择每行对应的子属性", Toast.LENGTH_SHORT); + NewToastUtil.getInstance().showToast("请选择每行对应的子属性"); } return; } changePage(3); break; - case R.id.btn_last3: + case R.id.btn_to_cook: jumpToCook(); break; - case R.id.btn_next3: + case R.id.btn_edit_process: jumpToEdit(); break; case R.id.btn_last2: @@ -235,11 +234,18 @@ public class EditGoodsDialog extends DialogFragment { subattributeGroup.goodsId = goods.id; subattributeGroup.maketime = 0; subattributeGroup.name = ""; + subattributeGroup.subAttributeIdList = ""; if(selectAttributeListAdapter != null && selectAttributeListAdapter.datas!=null && !selectAttributeListAdapter.datas.isEmpty()){ subattributeGroup.name = selectAttributeListAdapter.getSubAttributeNameList(); subattributeGroup.subAttributeIdList = selectAttributeListAdapter.getSubAttributeIdList(); } SubAttributeGroupDBUtil.add(subattributeGroup); + }else { + if(selectAttributeListAdapter != null && selectAttributeListAdapter.datas!=null && !selectAttributeListAdapter.datas.isEmpty()){ + subattributeGroup.name = selectAttributeListAdapter.getSubAttributeNameList(); + subattributeGroup.subAttributeIdList = selectAttributeListAdapter.getSubAttributeIdList(); + } + SubAttributeGroupDBUtil.update(subattributeGroup); } } @@ -262,7 +268,7 @@ public class EditGoodsDialog extends DialogFragment { if(!processvalue.isEmpty()){ HashMap params = ProcessValueUtil.dealProcessValue(processvalue); if(!params.isEmpty()){ - int position = 0;//几号位 + int position = -1;//几号位 String name = "";//主料名称 for (HashMap.Entry entry : params.entrySet()) { String key = entry.getKey(); @@ -273,7 +279,9 @@ public class EditGoodsDialog extends DialogFragment { position = Integer.parseInt(value.replace("号位","")); } } - updateName(position,name); + if(position>=0){ + updateName(position,name); + } } } } @@ -285,6 +293,7 @@ public class EditGoodsDialog extends DialogFragment { * 更新单个主料仓名称 */ private void updateName(int position,String name){ + LogUtils.d(TAG+" updateName position="+position+" ;name="+name); switch (position){ case 1: viewBinding.layoutMainfoods.editName1.setText(name); @@ -330,7 +339,7 @@ public class EditGoodsDialog extends DialogFragment { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putStringArrayListExtra("mainFoods",mainFoods); intent.putExtra("goodId",goods.id); - intent.putExtra("subAttributeGroupId",selectAttributeListAdapter.getSubAttributeIdList()); + intent.putExtra("subAttributeGroupId",subattributeGroup.id); intent.putExtra("subAttributeGroupName",selectAttributeListAdapter.getSubAttributeNameList()); startActivity(intent); dismiss(); diff --git a/app/src/main/java/com/bonait/bnframework/ui/fragment/CloudGoodsFragment.java b/app/src/main/java/com/bonait/bnframework/ui/fragment/CloudGoodsFragment.java index d1a9c84b..c0adba92 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/fragment/CloudGoodsFragment.java +++ b/app/src/main/java/com/bonait/bnframework/ui/fragment/CloudGoodsFragment.java @@ -32,7 +32,7 @@ import java.util.Objects; /** * @author: liup - * @description: + * @description: 云端菜谱 * @date: 2024/5/9 9:48. */ public class CloudGoodsFragment extends BaseFragment { diff --git a/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeDevicesFragment.java b/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeDevicesFragment.java new file mode 100644 index 00000000..603b0f0c --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeDevicesFragment.java @@ -0,0 +1,127 @@ +package com.bonait.bnframework.ui.fragment; + +import android.annotation.SuppressLint; +import android.graphics.Color; +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.text.Spannable; +import android.text.SpannableStringBuilder; +import android.text.style.ForegroundColorSpan; +import android.view.LayoutInflater; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.bonait.bnframework.HBL.DataUtil.ErrorCodeManager; +import com.bonait.bnframework.Model.ErrorCodeBean; +import com.bonait.bnframework.R; +import com.bonait.bnframework.Service.ModbusHelper; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.utils.DisplayManager; +import com.bonait.bnframework.databinding.FragmentHomeDevicesBinding; + +/** + * @author: liup + * @description: 设备信息 + * @date: 2024/5/17 16:48. + */ +public class HomeDevicesFragment extends BaseFragment { + protected FragmentHomeDevicesBinding viewBinding; + private static final int MSG_FRESH_DEVICE = 1000; + + @SuppressLint("HandlerLeak") + private Handler handler = new Handler(Looper.getMainLooper()){ + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + switch (msg.what){ + case MSG_FRESH_DEVICE: + if(hasMessages(MSG_FRESH_DEVICE)){ + removeMessages(MSG_FRESH_DEVICE); + } + sendEmptyMessageDelayed(MSG_FRESH_DEVICE,500); + for(ErrorCodeBean bean : ErrorCodeManager.getInstance().getDataBeans()){ + if(bean.getCode() == ModbusHelper.get().getDeviceErrorCode()){ + changeTextDeviceStatus(1,bean.getName()+" "+bean.getDescription()); + } + } + changeTextDeviceStatus(2,ModbusHelper.get().getConnected()?"在线":"掉线"); + break; + } + } + }; + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_home_device, null); + viewBinding = FragmentHomeDevicesBinding.bind(root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + DisplayManager.scaleViewGroup(viewBinding.getRoot()); + initView(); + } + + private void initView(){ + viewBinding.device.btnMainFood.setOnClickListener(view->{ + + }); + viewBinding.device.btnSilos.setOnClickListener(view->{ + + }); + viewBinding.device.btnStir.setOnClickListener(view->{ + + }); + viewBinding.device.btnFire.setOnClickListener(view->{ + + }); + } + + /** + * 设备状态更新 + * @param position + * @param desc + */ + private void changeTextDeviceStatus(int position,String desc){ + if(position == 1){ + String content = "设备信息: "+desc; + SpannableStringBuilder spannable = new SpannableStringBuilder(content); + spannable.setSpan(new ForegroundColorSpan(Color.parseColor("#795548")), 6, content.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);//SPAN_EXCLUSIVE_INCLUSIVE前面不包括后面包括 + viewBinding.deviceErrorCode.setText(spannable); + }else { + String content = "设备状态: "+desc; + SpannableStringBuilder spannable = new SpannableStringBuilder(content); + spannable.setSpan(new ForegroundColorSpan(Color.parseColor("#795548")), 5, content.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);//SPAN_EXCLUSIVE_INCLUSIVE前面不包括后面包括 + viewBinding.deviceErrorCode.setText(spannable); + viewBinding.deviceConnect.setText(spannable); + } + } + + @Override + public void onResume() { + super.onResume(); + handler.sendEmptyMessageDelayed(MSG_FRESH_DEVICE,500); + } + + @Override + public void onPause() { + super.onPause(); + if(handler!=null){ + handler.removeCallbacksAndMessages(null); + } + } + + @Override + public void onDestroy() { + super.onDestroy(); + if(handler != null){ + handler.removeCallbacksAndMessages(null); + handler = null; + } + } +} diff --git a/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java b/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java index d5b62bd4..f2d0ca91 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java +++ b/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java @@ -50,14 +50,22 @@ public class HomeFoodsFragment extends BaseFragment { private HomeGoodsViewModel viewModel; + private boolean connect = false; + private Handler handler = new Handler(Looper.getMainLooper()){ @Override public void handleMessage(@NonNull Message msg) { super.handleMessage(msg); switch (msg.what){ case 1: - viewBinding.topbar.removeAllRightViews(); - viewBinding.topbar.addRightTextButton("设备状态:"+(ModbusHelper.get().getConnected() ? "已连接" : "未连接"),R.id.status_image); + if(connect != ModbusHelper.get().getConnected() ){ + viewBinding.topbar.removeAllRightViews(); + if(ModbusHelper.get().getConnected()){ + viewBinding.topbar.addRightTextButton("设备状态:未连接",R.id.status_image); + }else { + viewBinding.topbar.addRightTextButton("设备状态:已连接",R.id.status_image); + } + } if(hasMessages(1)){ removeMessages(1); } diff --git a/app/src/main/java/com/bonait/bnframework/ui/fragment/LocalGoodsFragment.java b/app/src/main/java/com/bonait/bnframework/ui/fragment/LocalGoodsFragment.java index e02842c2..031d7dc6 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/fragment/LocalGoodsFragment.java +++ b/app/src/main/java/com/bonait/bnframework/ui/fragment/LocalGoodsFragment.java @@ -43,7 +43,7 @@ import java.util.ArrayList; /** * @author: liup - * @description: + * @description: 本地菜谱 * @date: 2024/5/9 9:48. */ public class LocalGoodsFragment extends BaseFragment { @@ -126,6 +126,9 @@ public class LocalGoodsFragment extends BaseFragment { DisplayManager.scaleViewGroup(binding.getRoot()); binding.title.setText("删除菜品"); binding.edit.setText("是否删除["+bean.name+"]下所有属性组合配方?"); + binding.cancel.setOnClickListener(view1 ->{ + xCom.dismissX(); + }); binding.submit.setOnClickListener(view1 -> { GoodsProcessDetailDBUtil.deleteByGoodsId(bean.id); SubAttributeGroupDBUtil.deleteByGoodsId(bean.id); diff --git a/app/src/main/java/com/bonait/bnframework/ui/viewmodel/HomeGoodsViewModel.java b/app/src/main/java/com/bonait/bnframework/ui/viewmodel/HomeGoodsViewModel.java index d1d34304..1e447d49 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/viewmodel/HomeGoodsViewModel.java +++ b/app/src/main/java/com/bonait/bnframework/ui/viewmodel/HomeGoodsViewModel.java @@ -122,7 +122,6 @@ public class HomeGoodsViewModel extends ViewModel { if(!SubAttributeGroupDBUtil.isExist(goods.id,goodsTechnologyActionListBean.getGoodsAttributeId())){ BPA_GOODS_SUBATTRIBUTE_GROUP group = new BPA_GOODS_SUBATTRIBUTE_GROUP(); group.name = goodsTechnologyActionListBean.getGoodsAttributeId();// - group.id = goodsTechnologyActionListBean.getGoodsAttributeId(); group.goodsId = goods.id; groupList.add(goodsTechnologyActionListBean.getGoodsAttributeId()); SubAttributeGroupDBUtil.add(group); diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/fire_control.java b/app/src/main/java/com/bonait/bnframework/ui/widget/FireView.java similarity index 93% rename from app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/fire_control.java rename to app/src/main/java/com/bonait/bnframework/ui/widget/FireView.java index 08899f42..31f24881 100644 --- a/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/fire_control.java +++ b/app/src/main/java/com/bonait/bnframework/ui/widget/FireView.java @@ -1,4 +1,4 @@ -package com.bonait.bnframework.ViewModel.CustomView; +package com.bonait.bnframework.ui.widget; import android.content.Context; import android.util.AttributeSet; @@ -10,7 +10,6 @@ import android.widget.LinearLayout; import androidx.annotation.Nullable; import com.bonait.bnframework.R; -import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.helper.I.MyClickListener; import java.util.ArrayList; @@ -20,7 +19,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; -public class fire_control extends LinearLayout { +public class FireView extends LinearLayout { @BindView(R.id.colse) ImageView colse; @BindView(R.id.hl1) @@ -58,8 +57,16 @@ public class fire_control extends LinearLayout { */ public MyClickListener mListener=null; private View root; + /** + * 是否可以点击 + */ + private boolean enableClick = false; + + public void setEnableClick(boolean enableClick){ + this.enableClick = enableClick; + } - public fire_control(Context context, @Nullable AttributeSet attrs) { + public FireView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); root=LayoutInflater.from(context).inflate(R.layout.item_fire_control, this); ButterKnife.bind(this, root); @@ -78,18 +85,6 @@ public class fire_control extends LinearLayout { ImageViews.add(hl8); ImageViews.add(hl9); ImageViews.add(hl10); -// if(ConfigName.getInstance().HeatingGear.get(ConfigName.getInstance().HuoLi)!=null) -// { -// int k= ConfigName.getInstance().HeatingGear.get(ConfigName.getInstance().HuoLi); -// for (int i = 0; i(k-1)) -// { -// ImageViews.get(i).setVisibility(View.GONE); -// } -// } -// } - //设置 关闭 SetLevel(0); } @@ -97,6 +92,9 @@ public class fire_control extends LinearLayout { @OnClick({R.id.colse, R.id.hl1,R.id.hl2,R.id.hl3,R.id.hl4,R.id.hl5,R.id.hl6,R.id.hl7,R.id.hl8,R.id.hl9,R.id.hl10}) public void onViewClicked(View view) { + if(!enableClick){ + return; + } switch (view.getId()) { case R.id.colse://选择菜谱按钮点击 if(Status) diff --git a/app/src/main/java/com/bonait/bnframework/ui/widget/NewToastUtil.java b/app/src/main/java/com/bonait/bnframework/ui/widget/NewToastUtil.java index 40fe5e83..fa93f623 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/widget/NewToastUtil.java +++ b/app/src/main/java/com/bonait/bnframework/ui/widget/NewToastUtil.java @@ -11,6 +11,7 @@ import android.widget.Toast; import androidx.core.content.ContextCompat; +import com.bonait.bnframework.MainApplication; import com.bonait.bnframework.R; import com.bonait.bnframework.common.utils.DimensUtil; import com.bonait.bnframework.common.utils.DisplayManager; @@ -23,18 +24,36 @@ import com.bonait.bnframework.databinding.ViewLayoutToastBinding; */ public class NewToastUtil { - public static void showToast(Context context,String message,int duration){ - Toast toast = new Toast(context); + private static NewToastUtil instance; + private Toast toast; + + public static synchronized NewToastUtil getInstance(){ + if(instance == null){ + synchronized (NewToastUtil.class){ + if(instance == null){ + instance = new NewToastUtil(); + } + } + } + return instance; + } + + public void showToast(String message){ + if(toast != null){ + toast.cancel(); + } + toast = new Toast(MainApplication.getContext()); +// toast.cancel(); String content = message; if(message.length() > 50){ content = message.substring(0,50)+"..."; } - View layout = LayoutInflater.from(context).inflate(R.layout.view_layout_toast,null); + View layout = LayoutInflater.from(MainApplication.getContext()).inflate(R.layout.view_layout_toast,null); ViewLayoutToastBinding binding = ViewLayoutToastBinding.bind(layout); DisplayManager.scaleViewGroup(binding.getRoot()); binding.toastText.setText(content); toast.setGravity(Gravity.BOTTOM,0,DimensUtil.getDimens(180)); - toast.setDuration(duration); + toast.setDuration(Toast.LENGTH_SHORT); toast.setView(layout); toast.show(); } @@ -45,10 +64,12 @@ public class NewToastUtil { * @param context * @param message * @param colorText - * @param duration */ - public void showToastTextColor(Context context,String message,String colorText,int color,int duration){ - Toast toast = new Toast(context); + public void showToastRedColor(Context context,String message,String colorText){ + if(toast == null){ + toast = new Toast(MainApplication.getContext()); + } + toast.cancel(); String content = message; if(message.length() > 50){ content = message.substring(0,50)+"..."; @@ -57,13 +78,13 @@ public class NewToastUtil { ViewLayoutToastBinding binding = ViewLayoutToastBinding.bind(layout); DisplayManager.scaleViewGroup(binding.getRoot()); SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(content); - int index = content.indexOf(colorText); + int index = colorText==null?0:content.indexOf(colorText); if(index>0){ - spannableStringBuilder.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, color)),index,index+colorText.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE); + spannableStringBuilder.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.red_primary)),index,index+colorText.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE); } binding.toastText.setText(spannableStringBuilder); toast.setGravity(Gravity.BOTTOM,0,DimensUtil.getDimens(180)); - toast.setDuration(duration); + toast.setDuration(Toast.LENGTH_SHORT); toast.setView(layout); toast.show(); } diff --git a/app/src/main/java/com/bonait/bnframework/ui/widget/ProcessValueView.java b/app/src/main/java/com/bonait/bnframework/ui/widget/ProcessValueView.java new file mode 100644 index 00000000..059630c0 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/ui/widget/ProcessValueView.java @@ -0,0 +1,197 @@ +package com.bonait.bnframework.ui.widget; + +import android.content.Context; +import android.text.InputType; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.RelativeLayout; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.ViewModel.CustomView.item_gx; +import com.bonait.bnframework.common.utils.DisplayManager; +import com.bonait.bnframework.databinding.ViewProcessValueBinding; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map; + +import butterknife.ButterKnife; + +/** + * @author: liup + * @description: + * @date: 2024/5/16 17:53. + */ +public class ProcessValueView extends RelativeLayout { + + private ViewProcessValueBinding viewBinding; + public item_gx model; + private Map editsp_map = new LinkedHashMap<>(); + private SpinnerSelectCallBack listener; + + public ProcessValueView(Context context, AttributeSet attrs,item_gx mode) { + super(context, attrs); + View root= LayoutInflater.from(context).inflate(R.layout.view_process_value, this); + ButterKnife.bind(this, root); + viewBinding = ViewProcessValueBinding.bind(root); + DisplayManager.scaleViewGroup(viewBinding.getRoot()); + model = mode; + Init(); + } + + public void setMainFoodName(String name){ + if(model.name.equals("主料名称")){ + viewBinding.edit.setText(name); + } + } + + public void setListener(SpinnerSelectCallBack listener){ + this.listener = listener; + } + + public void Init() + { + viewBinding.name.setText(model.name.trim()); + if(model.IsWL) + { + viewBinding.check.setVisibility(View.VISIBLE); + }else + { + viewBinding.check.setVisibility(View.GONE); + } + viewBinding.check.setChecked(false); + switch (model.datatype) + { + case 0://数字 + viewBinding.spinner.setVisibility(View.GONE); + viewBinding.edit.setVisibility(View.VISIBLE); + if(model.IsWL) + { + viewBinding.edit.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); + }else + { + viewBinding.edit.setInputType(InputType.TYPE_CLASS_NUMBER); + } + viewBinding.edit.setText("0".toCharArray(), 0, "0".length()); + break; + case 1://字符串 + viewBinding.spinner.setVisibility(View.GONE); + viewBinding.edit.setVisibility(View.VISIBLE); + viewBinding.edit.setInputType(InputType.TYPE_CLASS_TEXT); + break; + case 2://选项 + viewBinding.spinner.setVisibility(View.VISIBLE); + viewBinding.edit.setVisibility(View.GONE); + if(!model.data.isEmpty() && model.data.contains("、")) + { + String[] res = model.data.split("[、]"); + int index=1; + for (String item: res) + { + editsp_map.put(item,index); + index++; + } + }else + { + editsp_map.put(model.data,1); + } + ArrayAdapter adapter2 = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(editsp_map.keySet())); + adapter2.setDropDownViewResource(R.layout.spinner_dropdown_item); + viewBinding.spinner.setAdapter(adapter2); + viewBinding.spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView adapterView, View view, int i, long l) { + if(listener!=null && viewBinding.spinner.getSelectedItem().toString().contains("号位")){ + listener.onSelect(i,viewBinding.spinner.getSelectedItem().toString()); + } + } + + @Override + public void onNothingSelected(AdapterView adapterView) { + + } + }); + break; + } + } + /** + * 获取选择变量 + * @return + */ + public String GetValues() + { + String ResStu=""; + switch (model.datatype) + { + case 0://数字 + String text= viewBinding.edit.getText().toString(); + if(text.isEmpty()) + { + text="0"; + } + + if(model.IsWL) + { + double val=Double.parseDouble(text); + if(viewBinding.check.isChecked()) + { + ResStu=String.format("%.1f", val); + } + }else + { + int val=Integer.parseInt(text); + ResStu=String.valueOf(val); + } + break; + case 1://字符串 + if(model.IsWL) + { + if(viewBinding.check.isChecked()) + { + ResStu=viewBinding.edit.getText().toString(); + } + }else + { + ResStu=viewBinding.edit.getText().toString(); + } + break; + case 2://选项 + ResStu=viewBinding.spinner.getSelectedItem().toString(); + break; + } + return ResStu; + } + + /** + * 设置变量 + * @param value + */ + public void SetValues(String value) + { + switch (model.datatype) + { + case 0://数字 + case 1://字符串 + viewBinding.edit.setText(value); + if(model.IsWL) + { + viewBinding.check.setChecked(true); + } + break; + case 2://选项 + Object res= editsp_map.get(value); + if(res!=null) + { + viewBinding.spinner.setSelection((int)res-1); + } + break; + } + } + + public interface SpinnerSelectCallBack{ + void onSelect(int position,String name); + } +} diff --git a/app/src/main/java/com/bonait/bnframework/ui/widget/SmoothLayoutManager.java b/app/src/main/java/com/bonait/bnframework/ui/widget/SmoothLayoutManager.java new file mode 100644 index 00000000..0fee2b36 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/ui/widget/SmoothLayoutManager.java @@ -0,0 +1,55 @@ +package com.bonait.bnframework.ui.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.util.DisplayMetrics; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.LinearSmoothScroller; +import androidx.recyclerview.widget.RecyclerView; + +import com.bonait.bnframework.R; + +/** + * @author: liup + * @description: 滚动偏移量 + * @date: 2024/5/17 9:42. + */ +public class SmoothLayoutManager extends LinearLayoutManager { + + public SmoothLayoutManager(Context context) { + super(context); + } + + public SmoothLayoutManager(Context context, int orientation, boolean reverseLayout) { + super(context, orientation, reverseLayout); + } + + public SmoothLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + @Override + public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) { + Context context = recyclerView.getContext(); + LinearSmoothScroller smoothScroller = new LinearSmoothScroller(context) { + @Override + public int calculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, + int snapPreference) { + return boxStart - viewStart + context.getResources().getDimensionPixelSize(R.dimen.dp_50); + } + +// @Override +// public int getVerticalSnapPreference() { +// return SNAP_TO_START; +// } + + @Override + protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) { + return 50f / displayMetrics.densityDpi; + } + }; + smoothScroller.setTargetPosition(position); + startSmoothScroll(smoothScroller); + } +} diff --git a/app/src/main/res/drawable/bg_round50_left_green_btn.xml b/app/src/main/res/drawable/bg_round50_left_green_btn.xml new file mode 100644 index 00000000..b02aedc3 --- /dev/null +++ b/app/src/main/res/drawable/bg_round50_left_green_btn.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_round50_right_green_btn.xml b/app/src/main/res/drawable/bg_round50_right_green_btn.xml new file mode 100644 index 00000000..3f51aaa5 --- /dev/null +++ b/app/src/main/res/drawable/bg_round50_right_green_btn.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_select_step_text_bg.xml b/app/src/main/res/drawable/selector_select_step_text_bg.xml new file mode 100644 index 00000000..47b55dc4 --- /dev/null +++ b/app/src/main/res/drawable/selector_select_step_text_bg.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_select_step_text_color.xml b/app/src/main/res/drawable/selector_select_step_text_color.xml new file mode 100644 index 00000000..5736cf44 --- /dev/null +++ b/app/src/main/res/drawable/selector_select_step_text_color.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_text_click_yellow_round15.xml b/app/src/main/res/drawable/selector_text_click_yellow_round15.xml new file mode 100644 index 00000000..4dafe980 --- /dev/null +++ b/app/src/main/res/drawable/selector_text_click_yellow_round15.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_edit_process.xml b/app/src/main/res/layout/activity_edit_process.xml index f8d09243..e3c6b09b 100644 --- a/app/src/main/res/layout/activity_edit_process.xml +++ b/app/src/main/res/layout/activity_edit_process.xml @@ -68,7 +68,7 @@ app:layout_constraintTop_toBottomOf="@id/line1" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" - android:layout_marginLeft="@dimen/dp_290" + android:layout_marginLeft="@dimen/dp_320" android:background="@color/color3" /> @@ -82,7 +82,7 @@ android:text="步骤:" android:layout_marginTop="@dimen/dp_10" android:textColor="#567722" - android:layout_marginLeft="@dimen/dp_20" + android:layout_marginLeft="@dimen/dp_10" /> + + android:orientation="vertical" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toBottomOf="@id/tv_1" + app:layoutManager="com.bonait.bnframework.ui.widget.SmoothLayoutManager" + /> @@ -162,58 +165,93 @@ android:text="模拟炒制" /> - + - - - - - + android:layout_marginLeft="@dimen/dp_60" + /> + + + - - - - + android:orientation="vertical" + android:visibility="visible" + > + + + + + + + + + + + + diff --git a/app/src/main/res/layout/dialog/layout/dialog_attribute_select.xml b/app/src/main/res/layout/dialog/layout/dialog_attribute_select.xml new file mode 100644 index 00000000..a04d0f63 --- /dev/null +++ b/app/src/main/res/layout/dialog/layout/dialog_attribute_select.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog/layout/dialog_delete_classify.xml b/app/src/main/res/layout/dialog/layout/dialog_delete_classify.xml index e24c0d17..f6dcdad1 100644 --- a/app/src/main/res/layout/dialog/layout/dialog_delete_classify.xml +++ b/app/src/main/res/layout/dialog/layout/dialog_delete_classify.xml @@ -39,6 +39,19 @@ android:paddingRight="@dimen/dp_10" android:layout_gravity="center" /> +