@@ -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; | |||
@@ -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<BPA_GOODSRECIPE> { | |||
/** | |||
* 内部点击事件 | |||
*/ | |||
private MyClickListener mListener; | |||
private List<BPA_GOODSRECIPE> datas; | |||
int resource1; | |||
public gongxubuzhou_adapter(@NonNull Context context, int resource, @NonNull List<BPA_GOODSRECIPE> 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; | |||
} | |||
} |
@@ -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_GOODSRECIPE> 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_GOODSRECIPE>) 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) { | |||
} | |||
} |
@@ -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" /> | |||
<LinearLayout android:layout_width="match_parent" | |||
android:layout_height="400dp"> | |||
@@ -108,10 +109,8 @@ | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_height="match_parent" | |||
android:orientation="vertical"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
@@ -138,6 +137,14 @@ | |||
android:textColor="@color/black" | |||
android:textSize="14dp"/> | |||
</LinearLayout> | |||
<ListView | |||
android:id="@+id/datatab_gxbz" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:divider="#00000000" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginBottom="@dimen/dp_40" | |||
android:dividerHeight="3dp" /> | |||
</LinearLayout> | |||
<Button | |||
@@ -157,14 +164,19 @@ | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content"> | |||
<!--边框分割细线--> | |||
<LinearLayout | |||
<RelativeLayout | |||
android:layout_alignParentLeft="true" | |||
android:layout_marginTop="@dimen/dp_40" | |||
android:layout_marginBottom="@dimen/dp_40" | |||
android:layout_width="1dp" | |||
android:layout_height="match_parent" | |||
android:background="@drawable/qmui_s_list_item_bg_with_border_bottom" /> | |||
android:layout_width="@dimen/dp_10" | |||
android:layout_height="match_parent"> | |||
<LinearLayout | |||
android:layout_width="1dp" | |||
android:layout_height="match_parent" | |||
android:layout_centerInParent="true" | |||
android:layout_marginTop="@dimen/dp_40" | |||
android:layout_marginBottom="@dimen/dp_40" | |||
android:background="@color/color3" /> | |||
</RelativeLayout> | |||
<LinearLayout | |||
android:layout_marginLeft="@dimen/dp_10" | |||
@@ -79,8 +79,8 @@ | |||
<View | |||
android:layout_width="match_parent" | |||
android:layout_height="1px" | |||
android:background="?android:attr/listDivider"/> | |||
android:layout_height="2px" | |||
android:background="@color/color3"/> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
@@ -127,9 +127,8 @@ | |||
<View | |||
android:layout_width="match_parent" | |||
android:layout_height="1px" | |||
android:background="?android:attr/listDivider"/> | |||
android:layout_height="2px" | |||
android:background="@color/color3"/> | |||
<RelativeLayout | |||
android:id="@+id/rl_tow_button" | |||
@@ -0,0 +1,18 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:orientation="horizontal" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://schemas.android.com/apk/res/android "> | |||
<TextView | |||
android:id="@+id/text" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_alignParentLeft="true" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:text="序号" | |||
android:textSize="12dp" | |||
android:textColor="@color/black"/> | |||
</RelativeLayout> |