From ac7bb70c73ecce367bb9f7d5d51f847287c5bcdc Mon Sep 17 00:00:00 2001 From: fyf Date: Sat, 7 Oct 2023 17:26:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=95=8C=E9=9D=A29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonait/bnframework/business/MainInit.java | 1 - .../bnframework/common/constant/DataBus.java | 241 +++++---------- .../common/constant/MessageName.java | 2 + .../bonait/bnframework/common/db/QueryDB.java | 24 ++ .../common/db/mode/BPA_SUBORDER.java | 2 + .../common/db/res/ResGoodsMake.java | 6 + .../common/tabbar/MainNavigateTabBar.java | 6 + .../modules/home/adapter/lc_adapter.java | 288 ------------------ .../home/adapter/loadinggood_adapter.java | 62 ++++ .../modules/home/adapter/sp_adapter.java | 134 -------- .../home/fragment/MakeGoodFragment.java | 25 ++ .../fragment/from/ImageChooseActivity.java | 1 - .../from/fragment/Jcsjgl_wl_fragment.java | 6 +- .../main/res/layout/fragment_make_good.xml | 12 +- .../res/layout/item/layout/item_right_lc.xml | 13 +- 15 files changed, 223 insertions(+), 600 deletions(-) delete mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/adapter/lc_adapter.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java delete mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/adapter/sp_adapter.java diff --git a/app/src/main/java/com/bonait/bnframework/business/MainInit.java b/app/src/main/java/com/bonait/bnframework/business/MainInit.java index 93f3443b..f885d748 100644 --- a/app/src/main/java/com/bonait/bnframework/business/MainInit.java +++ b/app/src/main/java/com/bonait/bnframework/business/MainInit.java @@ -98,7 +98,6 @@ public class MainInit { //初始化DB数据 InitDBdata(); - DataBus.getInstance().GetLc();//获取料仓数据 ConfigData.getInstance().LoadingCloud();//加载云端数据 //设置连接到有线网络 diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java index 22efeb87..9f5af486 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java @@ -19,14 +19,14 @@ import com.bonait.bnframework.common.db.res.ResGoodsRecipe; import com.bonait.bnframework.common.db.res.Res_PLCADDRESS1; import com.bonait.bnframework.common.db.res.SilosLsjyMode; import com.bonait.bnframework.common.db.res.StatusMode; +import com.bonait.bnframework.common.db.res.UserLogEnum; import com.bonait.bnframework.common.db.res.lcMode; import com.bonait.bnframework.common.db.res.wdszMode; import com.bonait.bnframework.common.helper.I.MyClickListener; +import com.bonait.bnframework.common.helper.MessageLog; import com.bonait.bnframework.common.helper.mode.OrderA; import com.bonait.bnframework.common.helper.mode.ResultA; -import com.bonait.bnframework.modules.home.adapter.lc_adapter; import com.bonait.bnframework.modules.home.adapter.lsjy_adapter; -import com.bonait.bnframework.modules.home.adapter.sp_adapter; import com.bonait.bnframework.modules.home.adapter.wdsz_adapter; import com.bonait.bnframework.modules.home.fragment.mode.sdkz_control; import com.bonait.bnframework.modules.home.fragment.mode.tab_control; @@ -56,47 +56,16 @@ public class DataBus { } //endregion - - //region 跳转页面 //endregion //region 数据中心 - /** - * 料仓数据Model - */ - public List lcModes=new ArrayList<>(); - public lc_adapter lcadapter=null; + /** * 获取料仓数据 + * @return */ - public void GetLc() - { - try { - lcModes=new ArrayList<>(); - //获取料仓数据 - ArrayList bpa_silos = QueryDB.GetSilosALL(); - //加载materials数据 - if (bpa_silos.size() > 0) { - for (BPA_SILOS silo : bpa_silos) { - List m = QueryDB.GetMaterialBySilosID(silo.id); - if (m.size() > 0) { - lcModes.add(new lcMode(silo.id, silo.num, m.get(0).name, silo.silosmargin, silo.siloszl, m.get(0).id,m.get(0).type, silo.warningValue, silo.thrsoleValue,silo.name.isEmpty()?"":silo.name)); - } else { - lcModes.add(new lcMode(silo.id, silo.num, "未设置", silo.silosmargin, silo.siloszl, "",0, silo.warningValue, silo.thrsoleValue,silo.name.isEmpty()?"":silo.name)); - } - } - } - if (lcadapter!=null) - { - lcadapter.refresh(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - public ArrayList ResGetLc() { ArrayList lc=new ArrayList<>(); @@ -120,171 +89,107 @@ public class DataBus { return lc; } + + /** + * 商品制作列表 + */ + public ArrayList GoodsMake = new ArrayList(); /** - * 加满物料 + * 增加一个订单商品 + * @param suborder */ - public void TopUp(int index) + public void AddGoodsMake(BPA_SUBORDER suborder) { - if(index>=0 && lcModes.size()>=0) + try { - int zl= lcModes.get(index).siloszl; - lcModes.get(index).silosmargin=zl<=0?10000:zl; - QueryDB.UpdateYL(lcModes.get(index).id,lcModes.get(index).silosmargin); - if (lcadapter!=null) + ArrayList suorderlist=new ArrayList<>(); + for (ResGoodsMake item:GoodsMake) + { + if(item.makeStatus==MakeStatus.制作完成) + { + suorderlist.add(item.subOrder.id); + } + } + for (String item:suorderlist) { - lcadapter.refresh(); + DeleteGoodsMake(item); } + + ResGoodsMake make=new ResGoodsMake(); + make.recipes=QueryDB.GetGoodsSreciperecipeList(suborder.recipeID); + make.good=QueryDB.GetGoodsId(suborder.goodsID); + make.goodsrecipename=QueryDB.GetGoodsRecipeNameId(suborder.recipeID); + make.subOrder=suborder; + make.makeStatus= MakeStatus.等待制作; + make.makeMs="等待下发物料!"; + make.makeProcess=0; + GoodsMake.add(make); + MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + make.good.name + "]准备配料!"); + + }catch(Exception e){ + MessageLog.ShowInfo( "增加订单异常!"+e.getMessage()); } } /** - * 商品数据 - */ - public List Goods=new ArrayList<>(); - public sp_adapter spadapter=null; - /** - * 选中菜品 - */ - public BPA_GOODS SelectGood=null; - /** - * 选择菜品事件 - */ - public MyClickListener mListener=null; - /** - * 获取商品数据 + * 根据子订单id,物料id修改制作进度 + * @param suborderID + * @param makeMs + * @param count */ - public void GetGoods(String name) + public void UpdateGoodsMake(String suborderID,String makeMs,int count,int key,Boolean bz) { - try { - Goods.clear(); - ArrayList good=new ArrayList<>(); - if (name.isEmpty()) - { - good=QueryDB.GetGoodsALL(); - }else + try + { + for (int m=0;m GoodsSMMake = new ArrayList(); - /** - * 扫码商品订单制作 - */ - //public order_adapter orderadapter; - /** - * 商品制作列表 - */ - public List GoodsMake = new ArrayList(); - /** - * 商品制作完成列表 - */ - public List GoodsMakeOver = new ArrayList(); - /** - * 商品制作 - */ - //public makegood_adapter goodmakeadapter; - /** - * 获取是否可以下单 + * 根据子订单id,设置订单制作完成 */ - public boolean GetIsPlaceAnOrder() + public void DeleteGoodsMake(String suborderID) { try { - if(GoodsMake.size()<=0) - { - return true; - }else + ResGoodsMake good=null; + for (ResGoodsMake item:GoodsMake) { - boolean issucess=true; - for (ResGoodsMake item:GoodsMake) + if(item.subOrder.id.equals(suborderID)) { - if(item.makeStatus!= MakeStatus.制作完成) - { - issucess=false; - } + item.makeStatus=MakeStatus.制作完成; + item.makeMs=""; + item.makeProcess=100; + item.subOrder.status=2; + QueryDB.UpdateSubOrder(item.subOrder); + good=item; } - return issucess; } + if(good!=null) + { + GoodsMake.remove(good); + } }catch(Exception e){ - return true; } } - - - /** - * 员工操作日志 - */ - public List bpa_logs = new ArrayList(); - /** - * 订单操作日志 - */ - public List bpa_alertlogs = new ArrayList(); - /** - * 扫码订单 - */ - public OrderA OrderSM = new OrderA(); //endregion - //region 配方数据 /** * 详细配方 diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java b/app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java index 55f03954..1ac230fa 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java @@ -28,4 +28,6 @@ public interface MessageName { String ClickMakeGoodNew="ClickMakeGoodNew";//点击商品 + String MakeMainGoodResh="MakeMainGoodResh"; + } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java index 57ea41fb..d9e420ac 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java @@ -1189,6 +1189,29 @@ public class QueryDB { return null; } } + + /** + * 商品ID查询配方关联表 + * + * @param id + * @return + */ + public static BPA_GOODSRECIPENAME GetGoodsRecipeNameId(String id) { + try { + String orderby = Desc_Time_Up;//出料顺序 + String where = "isDelete=? and id=?"; + String[] args = new String[]{"0", id}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_GOODSRECIPENAME.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_GOODSRECIPENAME) k); + } + return data.size()>0?data.get(0):null; + } catch (Exception e) { + Log.d("商品ID查询配方信息", "商品ID查询配方信息异常: " + e.getMessage()); + return null; + } + } //endregion //region BPA_GOODSRECIPE 商品配方明细表 @@ -3138,6 +3161,7 @@ public class QueryDB { //私有 ((BPA_SUBORDER) data).orderID = cursor.getString((int) cursor.getColumnIndex("orderID")); ((BPA_SUBORDER) data).goodsID = cursor.getString((int) cursor.getColumnIndex("goodsID")); + ((BPA_SUBORDER) data).recipeID = cursor.getString((int) cursor.getColumnIndex("recipeID")); ((BPA_SUBORDER) data).number = cursor.getInt((int) cursor.getColumnIndex("number")); ((BPA_SUBORDER) data).status = cursor.getInt((int) cursor.getColumnIndex("status")); ((BPA_SUBORDER) data).goodImg = cursor.getString((int) cursor.getColumnIndex("goodImg")); diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SUBORDER.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SUBORDER.java index fc42c2b4..5627b172 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SUBORDER.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SUBORDER.java @@ -9,6 +9,8 @@ public class BPA_SUBORDER extends ModeBase{ public String orderID; //商品ID public String goodsID; + //配方ID + public String recipeID; //数量:例如 *1 *2 public int number; //状态:0 未开始 1 制作中 2 已制作 3 已超时 diff --git a/app/src/main/java/com/bonait/bnframework/common/db/res/ResGoodsMake.java b/app/src/main/java/com/bonait/bnframework/common/db/res/ResGoodsMake.java index 4c577d99..288aba36 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/res/ResGoodsMake.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/res/ResGoodsMake.java @@ -1,6 +1,7 @@ package com.bonait.bnframework.common.db.res; import com.bonait.bnframework.common.db.mode.BPA_GOODS; +import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPENAME; import com.bonait.bnframework.common.db.mode.BPA_SUBORDER; import java.util.ArrayList; @@ -12,6 +13,11 @@ public class ResGoodsMake { * 商品数据 */ public BPA_GOODS good; + + /** + * 商品的配方名称表 + */ + public BPA_GOODSRECIPENAME goodsrecipename; /** * 商品制作配方 */ diff --git a/app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java b/app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java index 11c96103..300241ba 100644 --- a/app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java +++ b/app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java @@ -20,6 +20,8 @@ import androidx.fragment.app.FragmentTransaction; import com.bonait.bnframework.R; import com.bonait.bnframework.common.constant.DataBus; +import com.bonait.bnframework.common.constant.MessageName; +import com.bonait.bnframework.common.message.MessageManager; import java.util.ArrayList; import java.util.List; @@ -362,6 +364,10 @@ public class MainNavigateTabBar extends LinearLayout implements View.OnClickList DataBus.getInstance().GetWdsz(); //刷新手动控制 + }else if (index==3) + { + //刷新商品 + MessageManager.getInstance().sendMessage(MessageName.MakeMainGoodResh, "Good"); } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/lc_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/lc_adapter.java deleted file mode 100644 index 4b4a0005..00000000 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/lc_adapter.java +++ /dev/null @@ -1,288 +0,0 @@ -package com.bonait.bnframework.modules.home.adapter; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.content.Context; -import android.content.ContextWrapper; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.LinearLayout; - -import com.bonait.bnframework.R; -import com.bonait.bnframework.business.ExecuteTheRecipe; -import com.bonait.bnframework.common.constant.DataBus; -import com.bonait.bnframework.common.db.res.lcMode; -import com.bonait.bnframework.common.helper.I.IWriteCallBack; -import com.bonait.bnframework.common.utils.AlertDialogUtils; -import com.bonait.bnframework.common.utils.ToastUtils; -import com.qmuiteam.qmui.widget.dialog.QMUIDialog; -import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; -import com.qmuiteam.qmui.widget.textview.QMUILinkTextView; -import com.suke.widget.SwitchButton; - -import java.util.List; - - -public class lc_adapter extends RecyclerView.Adapter { - - private final LayoutInflater mLayoutInflater; - - private Context context; - - List lcModes = DataBus.getInstance().lcModes; - - public lc_adapter(Context context) { - this.context = context; - mLayoutInflater = LayoutInflater.from(context); - } - - @NonNull - @Override - public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - View inflate = mLayoutInflater.inflate(R.layout.item_liaochang, parent, false); - return new MyLCViewHolder(inflate); - - } - - @Override - public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { - try { - if (holder instanceof MyLCViewHolder) { - MyLCViewHolder myViewHolder = (MyLCViewHolder) holder; - myViewHolder.name.setText(lcModes.get(position).materialName); - int bfb=0; - int yl=lcModes.get(position).silosmargin; - int zl=lcModes.get(position).siloszl; - if(zl==0) - { - bfb=0; - }else - { - bfb=((yl*100)/zl)>=100?100:((yl*100)/zl); - } - myViewHolder.type.setText((lcModes.get(position).materiallx==0?"液料":"酱料")); - //手动开关 - myViewHolder.m_click_layout.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - String kg= myViewHolder.imageView.getTag().toString(); - if(kg.equals("关闭")) - { - kg="打开"; - }else - { - kg="关闭"; - } -// String title = "料仓操作提示!"; -// String message = "请问客官确定要将["+lcModes.get(position).materialName+"]"+kg+"?"; - String finalKg = kg; - - if(finalKg.equals("打开")) - { - //打开 - myViewHolder.imageView.setTag(finalKg); - myViewHolder.imageView.setImageDrawable(context.getResources().getDrawable(R.mipmap.shuiguan_g)); - - ExecuteTheRecipe.WritePLC("料仓"+(position+1)+"手动开关", true, null); - ToastUtils.info("料仓"+(position+1)+"开关," + finalKg); - }else - { - //关闭 - myViewHolder.imageView.setTag(finalKg); - myViewHolder.imageView.setImageDrawable(context.getResources().getDrawable(R.mipmap.shuiguan_k2)); - - ExecuteTheRecipe.WritePLC("料仓"+(position+1)+"手动开关", false, null); - ToastUtils.info("料仓"+(position+1)+"开关," + finalKg); - } -// AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { -// @Override -// public void onClick(QMUIDialog dialog, int index) { -// -// dialog.dismiss(); -// } -// }); - } - }); - - myViewHolder.name.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - String kg= myViewHolder.imageView.getTag().toString(); - if(kg.equals("关闭")) - { - kg="打开"; - }else - { - kg="关闭"; - } -// String title = "料仓操作提示!"; -// String message = "请问客官确定要将["+lcModes.get(position).materialName+"]"+kg+"?"; - String finalKg = kg; - - if(finalKg.equals("打开")) - { - //打开 - myViewHolder.imageView.setTag(finalKg); - myViewHolder.imageView.setImageDrawable(context.getResources().getDrawable(R.mipmap.shuiguan_g)); - - ExecuteTheRecipe.WritePLC("料仓"+(position+1)+"手动开关", true, null); - ToastUtils.info("料仓"+(position+1)+"开关," + finalKg); - }else - { - //关闭 - myViewHolder.imageView.setTag(finalKg); - myViewHolder.imageView.setImageDrawable(context.getResources().getDrawable(R.mipmap.shuiguan_k2)); - - ExecuteTheRecipe.WritePLC("料仓"+(position+1)+"手动开关", false, null); - ToastUtils.info("料仓"+(position+1)+"开关," + finalKg); - } -// AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { -// @Override -// public void onClick(QMUIDialog dialog, int index) { -// -// dialog.dismiss(); -// } -// }); - } - }); - - myViewHolder.imageView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - String kg= myViewHolder.imageView.getTag().toString(); - if(kg.equals("关闭")) - { - kg="打开"; - }else - { - kg="关闭"; - } -// String title = "料仓操作提示!"; -// String message = "请问客官确定要将["+lcModes.get(position).materialName+"]"+kg+"?"; - String finalKg = kg; - - if(finalKg.equals("打开")) - { - //打开 - myViewHolder.imageView.setTag(finalKg); - myViewHolder.imageView.setImageDrawable(context.getResources().getDrawable(R.mipmap.shuiguan_g)); - - ExecuteTheRecipe.WritePLC("料仓"+(position+1)+"手动开关", true, null); - ToastUtils.info("料仓"+(position+1)+"开关," + finalKg); - }else - { - //关闭 - myViewHolder.imageView.setTag(finalKg); - myViewHolder.imageView.setImageDrawable(context.getResources().getDrawable(R.mipmap.shuiguan_k2)); - - ExecuteTheRecipe.WritePLC("料仓"+(position+1)+"手动开关", false, null); - ToastUtils.info("料仓"+(position+1)+"开关," + finalKg); - } -// AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { -// @Override -// public void onClick(QMUIDialog dialog, int index) { -// -// dialog.dismiss(); -// } -// }); - } - }); - - //myViewHolder.bfb.setText(bfb+"%"); -// myViewHolder.add.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// String title = "料仓操作提示!"; -// String message = "请问客官确定要将["+lcModes.get(position).materialName+"]加满吗?"; -// AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { -// @Override -// public void onClick(QMUIDialog dialog, int index) { -// DataBus.getInstance().TopUp(position); -// dialog.dismiss(); -// } -// }); -// } -// }); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * 料仓加满 - * @param index - */ - public void show_jm(int index) - { - //按钮点击 - String title = "料仓操作提示!"; - String message = "请问客官确定要将["+lcModes.get(index).materialName+"]加满吗?"; - AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog dialog, int index) { - DataBus.getInstance().TopUp(index); - dialog.dismiss(); - } - }); - } - - private Activity findActivity(@NonNull Context context) { - if (context instanceof Activity) { - return (Activity) context; - } else if (context instanceof ContextWrapper) { - return findActivity(((ContextWrapper) context).getBaseContext()); - } else { - return null; - } - } - - /** - * 刷新 - * - * @param - */ - public void refresh() { - Activity activity = findActivity(context); - if (activity != null) { - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - try { - notifyDataSetChanged(); - } catch (Exception e) { - - } - } - }); - } - } - - @Override - public int getItemCount() { - return lcModes.size(); - } - - public static class MyLCViewHolder extends RecyclerView.ViewHolder { - //ImageView add;//加满按钮 - QMUILinkTextView type;//物料类型 - QMUILinkTextView name;//物料名称 - //QMUILinkTextView bfb;//料仓余量百分比 - ImageView imageView; - LinearLayout m_click_layout; - - public MyLCViewHolder(View view) { - super(view); - //add=view.findViewById(R.id.add); - type=view.findViewById(R.id.type); - name=view.findViewById(R.id.name); - //bfb=view.findViewById(R.id.bfb); - m_click_layout=view.findViewById(R.id.m_click_layout); - imageView=view.findViewById(R.id.imageView); - } - } -} diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java new file mode 100644 index 00000000..c4bafdb8 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java @@ -0,0 +1,62 @@ +package com.bonait.bnframework.modules.home.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_SUBORDER; +import com.bonait.bnframework.common.helper.I.MyClickListener; + +import java.util.ArrayList; +import java.util.List; + +public class loadinggood_adapter extends ArrayAdapter { + /** + * 内部点击事件 + */ + private MyClickListener mListener; + private ArrayList datas; + int resource1; + public loadinggood_adapter(@NonNull Context context, int resource, @NonNull ArrayList objects, MyClickListener listener) { + super(context, resource, objects); + mListener = listener; + datas=objects; + this.resource1=resource; + } + //每个子项被滚动到屏幕内的时候会被调用 + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + BPA_SUBORDER bpa_suborder = (BPA_SUBORDER) getItem(position);//得到当前项选中item实例 + //为每一个子项加载设定的布局 + View view = LayoutInflater.from(getContext()).inflate(resource1, parent, false); + //分别获取 image view 和 textview 的实例 +// TextView name = view.findViewById(R.id.name); +// Button button = view.findViewById(R.id.button_item); +// // 设置要显示的图片和文字 +// name.setText(bpa_material.name); +// name.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// if(mListener!=null) mListener.clickListener(view,bpa_material); +// } +// }); +// +// button.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// if(mListener!=null) mListener.clickListener(view,bpa_material); +// } +// }); + return view; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/sp_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/sp_adapter.java deleted file mode 100644 index 62fc6e48..00000000 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/sp_adapter.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.bonait.bnframework.modules.home.adapter; - -import android.app.Activity; -import android.content.Context; -import android.content.ContextWrapper; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.RelativeLayout; - -import com.bonait.bnframework.R; -import com.bonait.bnframework.common.constant.DataBus; -import com.bonait.bnframework.common.db.mode.BPA_GOODS; -import com.bonait.bnframework.common.helper.I.MyClickListener; -import com.bonait.bnframework.common.image.MyBitmapUtils; -import com.bonait.bnframework.common.utils.AlertDialogUtils; -import com.qmuiteam.qmui.widget.dialog.QMUIDialog; -import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; -import com.qmuiteam.qmui.widget.textview.QMUILinkTextView; - -import java.util.List; - -public class sp_adapter extends RecyclerView.Adapter { - - private final LayoutInflater mLayoutInflater; - - private Context context; - - List goods = DataBus.getInstance().Goods; - - /** - * 点击事件 - */ - public MyClickListener mListener=null; - - public sp_adapter(Context context) { - this.context = context; - mLayoutInflater = LayoutInflater.from(context); - } - - @NonNull - @Override - public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - View inflate = mLayoutInflater.inflate(R.layout.item_sp, parent, false); - return new MyLCViewHolder1(inflate); - - } - - @Override - public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { - try { - if (holder instanceof MyLCViewHolder1) { - MyLCViewHolder1 myViewHolder = (MyLCViewHolder1) holder; - if(goods.get(position).url!=null) - { - new MyBitmapUtils().disPlay(myViewHolder.img,goods.get(position).url); - } - //myViewHolder.img.setBackground(context.getResources().getDrawable(R.mipmap.hgr)); - myViewHolder.name.setText(goods.get(position).name); - myViewHolder.img.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - //按钮点击 - String title = "选择菜品操作提示!"; - String message = "请问客官确定要选择["+goods.get(position).name+"],开始制作吗?"; - AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog dialog, int index) { - if(mListener!=null) - { - mListener.clickListener(view,goods.get(position)); - } - dialog.dismiss(); - } - }); - } - }); - - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - private Activity findActivity(@NonNull Context context) { - if (context instanceof Activity) { - return (Activity) context; - } else if (context instanceof ContextWrapper) { - return findActivity(((ContextWrapper) context).getBaseContext()); - } else { - return null; - } - } - - /** - * 刷新 - * - * @param - */ - public void refresh() { - Activity activity = findActivity(context); - if (activity != null) { - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - try { - notifyDataSetChanged(); - } catch (Exception e) { - - } - } - }); - } - } - - @Override - public int getItemCount() { - return goods.size(); - } - - public static class MyLCViewHolder1 extends RecyclerView.ViewHolder { - ImageView img;//图片按钮 - QMUILinkTextView name;//名称 - - public MyLCViewHolder1(View view) { - super(view); - img=view.findViewById(R.id.img); - name=view.findViewById(R.id.name); - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java index fd86769a..2e0163d1 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java @@ -11,6 +11,7 @@ import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; +import android.widget.ListView; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseFragment; @@ -27,6 +28,7 @@ import com.bonait.bnframework.common.linktab.makegood.MakeGoodRightAdapter; import com.bonait.bnframework.common.message.MessageLooper; import com.bonait.bnframework.common.message.MessageManager; import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.modules.home.adapter.wl_adapter; import com.litao.slider.NiftySlider; import com.orhanobut.logger.Logger; import com.qmuiteam.qmui.widget.QMUITopBarLayout; @@ -61,6 +63,12 @@ public class MakeGoodFragment extends BaseFragment { */ ArrayList goodstypes=new ArrayList<>(); + /** + * 商品制作列表 + */ + @BindView(R.id.datatab_paiduishangping) + ListView datatab_paiduishangping; + private Context context; public MakeGoodFragment() { @@ -132,6 +140,13 @@ public class MakeGoodFragment extends BaseFragment { } }); } + + public void LoadingGood() + { +// wl_adapter adapter = new wl_adapter(context, R.layout.wl_item, bpa_materials, this); +// datatab_paiduishangping.setAdapter(adapter); + } + /** * 初始化TopBar */ @@ -148,6 +163,16 @@ public class MakeGoodFragment extends BaseFragment { } } }); + + //刷新主页商品 + MessageManager.getInstance().registerMessageReceiver(getActivity(), MessageName.MakeMainGoodResh, new MessageLooper.OnMessageListener() { + @Override + public void onMessage(Object msg) { + if (msg != null) { + Initdata(); + } + } + }); } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageChooseActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageChooseActivity.java index 594bf105..58b2d2c3 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageChooseActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageChooseActivity.java @@ -19,7 +19,6 @@ import com.bonait.bnframework.common.message.MessageManager; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.common.view.MyLayoutManager; import com.bonait.bnframework.modules.home.adapter.image_sp_adapter; -import com.bonait.bnframework.modules.home.adapter.sp_adapter; import com.bonait.bnframework.modules.home.fragment.mode.image_sp; import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.QMUITopBarLayout; diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_wl_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_wl_fragment.java index 8b7e8ef3..283f8a93 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_wl_fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/Jcsjgl_wl_fragment.java @@ -187,9 +187,9 @@ public class Jcsjgl_wl_fragment extends BaseFragment implements MyClickListener @Override public void onDestroy() { super.onDestroy(); - if (DataBus.getInstance().mListener != null) { - DataBus.getInstance().mListener.clickListenerNew(this.getView(), 0, ""); - } +// if (DataBus.getInstance().mListener != null) { +// DataBus.getInstance().mListener.clickListenerNew(this.getView(), 0, ""); +// } Logger.d("我的fragment销毁"); } diff --git a/app/src/main/res/layout/fragment_make_good.xml b/app/src/main/res/layout/fragment_make_good.xml index 7c69d1e0..d3e22ffa 100644 --- a/app/src/main/res/layout/fragment_make_good.xml +++ b/app/src/main/res/layout/fragment_make_good.xml @@ -61,7 +61,17 @@ android:layout_height="match_parent" android:orientation="vertical" android:layout_marginBottom="20dp"> - + + + diff --git a/app/src/main/res/layout/item/layout/item_right_lc.xml b/app/src/main/res/layout/item/layout/item_right_lc.xml index ed00d54d..1acb5935 100644 --- a/app/src/main/res/layout/item/layout/item_right_lc.xml +++ b/app/src/main/res/layout/item/layout/item_right_lc.xml @@ -3,9 +3,14 @@ android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="wrap_content"> - + + android:layout_height="match_parent"> + + + \ No newline at end of file