diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODSRECIPE.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODSRECIPE.java index e10aa330..8dfd168a 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODSRECIPE.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_GOODSRECIPE.java @@ -15,7 +15,8 @@ public class BPA_GOODSRECIPE extends ModeBase { public int sort; //物料类型 0:正常物料 1:工序模型 2:果糖 public int materialType; - + //模型描述 + public String processms; //模型名称 public String processname; diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/gongxubuzhou_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/gongxubuzhou_adapter.java new file mode 100644 index 00000000..7ef350e2 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/gongxubuzhou_adapter.java @@ -0,0 +1,55 @@ +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.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; +import com.bonait.bnframework.common.db.res.lcMode; +import com.bonait.bnframework.common.helper.I.MyClickListener; + +import java.util.List; + + +public class gongxubuzhou_adapter extends ArrayAdapter { + /** + * 内部点击事件 + */ + private MyClickListener mListener; + private List datas; + int resource1; + public gongxubuzhou_adapter(@NonNull Context context, int resource, @NonNull List 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_GOODSRECIPE lc = (BPA_GOODSRECIPE) getItem(position);//得到当前项选中item实例 + //为每一个子项加载设定的布局 + View view = LayoutInflater.from(getContext()).inflate(resource1, parent, false); + //分别获取 image view 和 textview 的实例 + + TextView text = view.findViewById(R.id.text); + text.setText(lc.sort+"、"+lc.processms); + text.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //view.setBackground(getContext().getResources().getDrawable(R.mipmap.hgr)); + if(mListener!=null) mListener.clickListener(view,lc); + } + }); + + return view; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java index 5e9e3af4..56d4cfd3 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java @@ -14,18 +14,24 @@ import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.LinearLayout; +import android.widget.ListView; import android.widget.Spinner; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseActivity; +import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.constant.MessageName; import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; 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.helper.I.MyClickListener; import com.bonait.bnframework.common.helper.MyImage; import com.bonait.bnframework.common.message.MessageManager; import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.modules.home.adapter.gongxubuzhou_adapter; +import com.bonait.bnframework.modules.home.adapter.lcsz_adapter; import com.bonait.bnframework.modules.home.fragment.mode.fragment_gx; import com.bonait.bnframework.modules.home.fragment.mode.item_gx; import com.qmuiteam.qmui.widget.QMUITopBar; @@ -45,7 +51,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; -public class DiyActivity extends BaseActivity { +public class DiyActivity extends BaseActivity implements MyClickListener { @BindView(R.id.topbar) QMUITopBar mTopBar; @BindView(R.id.Banner_Main) @@ -59,6 +65,14 @@ public class DiyActivity extends BaseActivity { @BindView(R.id.gxchid) LinearLayout gxchid;//工序子集 + + @BindView(R.id.datatab_gxbz) + ListView datatab_gxbz;//工序步骤 + public gongxubuzhou_adapter gxbz_adapter=null; + /** + * 工序步骤 + */ + public ArrayList bpa_goodsrecipes=new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -67,7 +81,6 @@ public class DiyActivity extends BaseActivity { initTopBar(); initData(); } - private void initData() { //1.初始化轮播图 @@ -91,7 +104,9 @@ public class DiyActivity extends BaseActivity { public void onNothingSelected(AdapterView adapterView) { } }); - //3. + //3.工序步骤 + gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item, (List) bpa_goodsrecipes,this); + datatab_gxbz.setAdapter(gxbz_adapter); } /** * 根据选中工序id显示集合 @@ -127,13 +142,24 @@ public class DiyActivity extends BaseActivity { fragment_gx gongxu=new fragment_gx(this,null,gx); gxchid.addView(gongxu); } - } }catch (Exception ex) { - } } + /** + * 获取选中行的变量 + * @return + */ + int k=1; + public BPA_GOODSRECIPE GetSelectItemFromValue() + { + BPA_GOODSRECIPE pf=new BPA_GOODSRECIPE(); + pf.processms="测试物料"; + pf.sort=k; + k++; + return pf; + } private void initTopBar() { mTopBar.setTitle("DIY模式"); mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() { @@ -143,7 +169,10 @@ public class DiyActivity extends BaseActivity { } }); } - //获取图片存放到list中 + /** + * 获取图片存放到list中 + * @param arrayList + */ private void Drawable_Get(List arrayList) { //从drawable文件夹下获取到事先准备的图片,在这里演示三张图片 Drawable drawable = getResources().getDrawable(R.mipmap.hgr); @@ -156,13 +185,15 @@ public class DiyActivity extends BaseActivity { //调用轮播图设置方法 Banner_Set(Banner_list); } - //将图片存放到轮播图中 + /** + * 将图片存放到轮播图中 + * @param arrayList + */ private void Banner_Set(List arrayList) { //这是设置轮播图的关键位置,setImages(list) 设置轮播图的图片资源 //setImageLoader(一个实体类)用于加载图片到手机页面上显示 Banner_Main.setImages(Banner_list).setImageLoader(new MyImage()).start(); } - /** * 点击事件 * @param view @@ -171,7 +202,8 @@ public class DiyActivity extends BaseActivity { public void onViewClicked(View view) { switch (view.getId()) { case R.id.add_hrgx://添加工序 - + bpa_goodsrecipes.add(GetSelectItemFromValue()); + gxbz_adapter.notifyDataSetChanged(); ToastUtils.info("添加工序"); break; case R.id.update_gx://修改工序 @@ -179,7 +211,9 @@ public class DiyActivity extends BaseActivity { ToastUtils.info("修改工序"); break; case R.id.delete_gx://删除工序 - + BPA_GOODSRECIPE obj= (BPA_GOODSRECIPE)datatab_gxbz.getSelectedItem(); + bpa_goodsrecipes.remove(obj); + gxbz_adapter.notifyDataSetChanged(); ToastUtils.info("删除工序"); break; case R.id.shangyi://上移 @@ -209,4 +243,17 @@ public class DiyActivity extends BaseActivity { protected boolean canDragBack() { return false; } + + @Override + public void clickListener(View v, Object data) { + switch (v.getId()) { + case R.id.text://步骤行点击 + BPA_GOODSRECIPE pf=(BPA_GOODSRECIPE)data; + ToastUtils.info("步骤行点击,"+pf.processms); + break; + } + } + @Override + public void clickListenerNew(View v, int k, Object data) { + } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_diy.xml b/app/src/main/res/layout/activity_diy.xml index 79edb7bc..ab64e09f 100644 --- a/app/src/main/res/layout/activity_diy.xml +++ b/app/src/main/res/layout/activity_diy.xml @@ -98,7 +98,8 @@ android:layout_alignParentBottom="true" android:layout_width="match_parent" android:layout_height="1dp" - android:background="@drawable/qmui_s_list_item_bg_with_border_bottom" /> + android:layout_marginBottom="@dimen/dp_10" + android:background="@color/color3" /> @@ -108,10 +109,8 @@ - - +