@@ -98,7 +98,6 @@ public class MainInit { | |||
//初始化DB数据 | |||
InitDBdata(); | |||
DataBus.getInstance().GetLc();//获取料仓数据 | |||
ConfigData.getInstance().LoadingCloud();//加载云端数据 | |||
//设置连接到有线网络 | |||
@@ -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<lcMode> lcModes=new ArrayList<>(); | |||
public lc_adapter lcadapter=null; | |||
/** | |||
* 获取料仓数据 | |||
* @return | |||
*/ | |||
public void GetLc() | |||
{ | |||
try { | |||
lcModes=new ArrayList<>(); | |||
//获取料仓数据 | |||
ArrayList<BPA_SILOS> bpa_silos = QueryDB.GetSilosALL(); | |||
//加载materials数据 | |||
if (bpa_silos.size() > 0) { | |||
for (BPA_SILOS silo : bpa_silos) { | |||
List<BPA_MATERIAL> 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<lcMode> ResGetLc() | |||
{ | |||
ArrayList<lcMode> lc=new ArrayList<>(); | |||
@@ -120,171 +89,107 @@ public class DataBus { | |||
return lc; | |||
} | |||
/** | |||
* 商品制作列表 | |||
*/ | |||
public ArrayList<ResGoodsMake> GoodsMake = new ArrayList<ResGoodsMake>(); | |||
/** | |||
* 加满物料 | |||
* 增加一个订单商品 | |||
* @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<String> 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<BPA_GOODS> 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<BPA_GOODS> good=new ArrayList<>(); | |||
if (name.isEmpty()) | |||
{ | |||
good=QueryDB.GetGoodsALL(); | |||
}else | |||
try | |||
{ | |||
for (int m=0;m<GoodsMake.size();m++) | |||
{ | |||
good= QueryDB.GetGoodsLike(name); | |||
} | |||
for (BPA_GOODS k : good) { | |||
Goods.add((BPA_GOODS) k); | |||
} | |||
if(GoodsMake.get(m).subOrder.id.equals(suborderID)) | |||
{ | |||
if(GoodsMake.get(m).subOrder.status==0) | |||
{ | |||
GoodsMake.get(m).subOrder.status=1; | |||
QueryDB.UpdateSubOrder(GoodsMake.get(m).subOrder); | |||
} | |||
if (spadapter!=null) | |||
{ | |||
DataBus.getInstance().spadapter.refresh(); | |||
GoodsMake.get(m).makeStatus= MakeStatus.制作中; | |||
GoodsMake.get(m).makeMs=makeMs; | |||
GoodsMake.get(m).makeProcess=(count/ GoodsMake.get(m).recipes.size())*100; | |||
return; | |||
} | |||
} | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
}catch(Exception e){ | |||
} | |||
} | |||
/** | |||
* 商品扫码等待制作列表 | |||
*/ | |||
public List<ResGoodsMake> GoodsSMMake = new ArrayList<ResGoodsMake>(); | |||
/** | |||
* 扫码商品订单制作 | |||
*/ | |||
//public order_adapter orderadapter; | |||
/** | |||
* 商品制作列表 | |||
*/ | |||
public List<ResGoodsMake> GoodsMake = new ArrayList<ResGoodsMake>(); | |||
/** | |||
* 商品制作完成列表 | |||
*/ | |||
public List<ResGoodsMake> GoodsMakeOver = new ArrayList<ResGoodsMake>(); | |||
/** | |||
* 商品制作 | |||
*/ | |||
//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_LOG> bpa_logs = new ArrayList<BPA_LOG>(); | |||
/** | |||
* 订单操作日志 | |||
*/ | |||
public List<BPA_ALERTLOG> bpa_alertlogs = new ArrayList<BPA_ALERTLOG>(); | |||
/** | |||
* 扫码订单 | |||
*/ | |||
public OrderA OrderSM = new OrderA(); | |||
//endregion | |||
//region 配方数据 | |||
/** | |||
* 详细配方 | |||
@@ -28,4 +28,6 @@ public interface MessageName { | |||
String ClickMakeGoodNew="ClickMakeGoodNew";//点击商品 | |||
String MakeMainGoodResh="MakeMainGoodResh"; | |||
} |
@@ -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<BPA_GOODSRECIPENAME> data = new ArrayList<>(); | |||
ArrayList<Object> 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")); | |||
@@ -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 已超时 | |||
@@ -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; | |||
/** | |||
* 商品制作配方 | |||
*/ | |||
@@ -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"); | |||
} | |||
} | |||
@@ -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<RecyclerView.ViewHolder> { | |||
private final LayoutInflater mLayoutInflater; | |||
private Context context; | |||
List<lcMode> 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); | |||
} | |||
} | |||
} |
@@ -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<BPA_SUBORDER> { | |||
/** | |||
* 内部点击事件 | |||
*/ | |||
private MyClickListener mListener; | |||
private ArrayList<BPA_SUBORDER> datas; | |||
int resource1; | |||
public loadinggood_adapter(@NonNull Context context, int resource, @NonNull ArrayList<BPA_SUBORDER> 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; | |||
} | |||
} |
@@ -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<RecyclerView.ViewHolder> { | |||
private final LayoutInflater mLayoutInflater; | |||
private Context context; | |||
List<BPA_GOODS> 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); | |||
} | |||
} | |||
} |
@@ -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<BPA_GOODSTYPE> 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(); | |||
} | |||
} | |||
}); | |||
} | |||
@@ -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; | |||
@@ -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销毁"); | |||
} | |||
@@ -61,7 +61,17 @@ | |||
android:layout_height="match_parent" | |||
android:orientation="vertical" | |||
android:layout_marginBottom="20dp"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<ListView | |||
android:id="@+id/datatab_paiduishangping" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_marginTop="3dp" | |||
android:divider="#00000000" | |||
android:dividerHeight="3dp" /> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
</LinearLayout> | |||
@@ -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"> | |||
<androidx.recyclerview.widget.RecyclerView | |||
android:id="@+id/recycler_view" | |||
android:layout_height="match_parent"> | |||
<ScrollView | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content"/> | |||
android:layout_height="match_parent"> | |||
<androidx.recyclerview.widget.RecyclerView | |||
android:id="@+id/recycler_view" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content"/> | |||
</ScrollView> | |||
</LinearLayout> |