|
|
@@ -0,0 +1,625 @@
|
|
|
+package com.uas.uas_mes_zb_p.fragment;
|
|
|
+
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.support.annotation.Nullable;
|
|
|
+import android.support.v7.widget.DefaultItemAnimator;
|
|
|
+import android.support.v7.widget.DividerItemDecoration;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
+import android.util.Log;
|
|
|
+import android.util.SparseBooleanArray;
|
|
|
+import android.view.Gravity;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.view.Window;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.CheckBox;
|
|
|
+import android.widget.CompoundButton;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.PopupWindow;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
+import com.chad.library.adapter.base.BaseViewHolder;
|
|
|
+import com.uas.uas_mes_zb_p.R;
|
|
|
+import com.uas.uas_mes_zb_p.activity.FunctionActivity;
|
|
|
+import com.uas.uas_mes_zb_p.bean.CheckProdcodeBean;
|
|
|
+import com.uas.uas_mes_zb_p.bean.JsonStorateBean;
|
|
|
+import com.uas.uas_mes_zb_p.bean.TakeApartThePalletBean;
|
|
|
+import com.uas.uas_mes_zb_p.global.GloableParams;
|
|
|
+import com.uas.uas_mes_zb_p.util.CommonUtil;
|
|
|
+import com.uas.uas_mes_zb_p.util.FastjsonUtil;
|
|
|
+import com.uas.uas_mes_zb_p.util.HttpCallback;
|
|
|
+import com.uas.uas_mes_zb_p.util.HttpParams;
|
|
|
+import com.uas.uas_mes_zb_p.util.VollyRequest;
|
|
|
+import com.uas.uas_mes_zb_p.view.ClearableEditText;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import razerdp.basepopup.BasePopupWindow;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by cjh-sail on 2023-02-15
|
|
|
+ * 拆分(无库存)
|
|
|
+ */
|
|
|
+public class TakeApartThePalletFragment extends BaseFragment{
|
|
|
+
|
|
|
+ private RecyclerView ra_data;
|
|
|
+ private SelectAdapter selectAdapter;
|
|
|
+ private ArrayList<TakeApartThePalletBean> takeApartThePalletlist;
|
|
|
+ private String va_ids;
|
|
|
+ private PopupWindow editPW;
|
|
|
+ private IpAndPortAdapter andPortAdapter;
|
|
|
+ private List<CheckProdcodeBean> delists;
|
|
|
+ private String pd_prodcode;
|
|
|
+ private CheckBox ck_all;
|
|
|
+ private Button btn_commit;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fragment_takeapartthepallet;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ FunctionActivity.setTitle(getString(R.string.title_materialchange));
|
|
|
+ ((FunctionActivity) getActivity()).setListIconIvVisible(false);
|
|
|
+ ra_data = root.findViewById(R.id.ra_data);
|
|
|
+ ck_all = root.findViewById(R.id.ck_all);
|
|
|
+ btn_commit = root.findViewById(R.id.btn_commit);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ takeApartThePalletlist = new ArrayList<>();
|
|
|
+
|
|
|
+ selectAdapter = new SelectAdapter(takeApartThePalletlist);
|
|
|
+
|
|
|
+ ra_data.addItemDecoration(new DividerItemDecoration(mActivity, LinearLayout.VERTICAL));
|
|
|
+ ra_data.setLayoutManager(new LinearLayoutManager(mActivity));
|
|
|
+ //设置Item增加、移除动画
|
|
|
+ ra_data.setItemAnimator(new DefaultItemAnimator());
|
|
|
+ setAdapter(takeApartThePalletlist);
|
|
|
+ ra_data.setAdapter(selectAdapter);
|
|
|
+ Bundle bundle = getArguments();
|
|
|
+ if (bundle != null) {
|
|
|
+ va_ids = bundle.getString("pi_id");
|
|
|
+ }
|
|
|
+
|
|
|
+ setDataarry();
|
|
|
+// getNewNameData();
|
|
|
+ }
|
|
|
+ public void setDataarry(){
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ JSONObject object_1 = new JSONObject();
|
|
|
+ JSONObject object_2 = new JSONObject();
|
|
|
+ JSONObject object_3 = new JSONObject();
|
|
|
+ JSONObject object_4 = new JSONObject();
|
|
|
+ JSONObject object_5 = new JSONObject();
|
|
|
+ JSONObject object_6 = new JSONObject();
|
|
|
+ try {
|
|
|
+ object_1.put("pd_pdno", "2");
|
|
|
+ object_1.put("pd_id", "11");
|
|
|
+ object_1.put("pd_prodcode", "AA00760H0H04100490-150-NNN000-SY");
|
|
|
+ object_1.put("pr_detail", "生益S1000H(TG150) 耐CAF FR-4");
|
|
|
+ object_1.put("pr_spec", "0.76mm H/Hoz 不含铜 41*49");
|
|
|
+ object_1.put("pd_outqty", "3049");
|
|
|
+
|
|
|
+
|
|
|
+ object_2.put("pd_pdno", "3");
|
|
|
+ object_2.put("pd_id", "11");
|
|
|
+ object_2.put("pd_prodcode", "DB-39217");
|
|
|
+ object_2.put("pr_detail", "加工上板机铝板");
|
|
|
+ object_2.put("pr_spec", "10mm*40mm*940mm");
|
|
|
+ object_2.put("pd_outqty", "1315.995");
|
|
|
+
|
|
|
+ object_3.put("pd_pdno", "4");
|
|
|
+ object_3.put("pd_id", "13");
|
|
|
+ object_3.put("pd_prodcode", "DB-39217");
|
|
|
+ object_3.put("pr_detail", "加工上板机铝板");
|
|
|
+ object_3.put("pr_spec", "10mm*40mm*940mm");
|
|
|
+ object_3.put("pd_outqty", "1315.995");
|
|
|
+
|
|
|
+ object_4.put("pd_pdno", "5");
|
|
|
+ object_4.put("pd_id", "11");
|
|
|
+ object_4.put("pd_prodcode", "DB-39217");
|
|
|
+ object_4.put("pr_detail", "加工上板机铝板");
|
|
|
+ object_4.put("pr_spec", "10mm*40mm*940mm");
|
|
|
+ object_4.put("pd_outqty", "1315.995");
|
|
|
+
|
|
|
+ object_5.put("pd_pdno", "1");
|
|
|
+ object_5.put("pd_id", "11");
|
|
|
+ object_5.put("pd_prodcode", "EM-832408jfaghafo");
|
|
|
+ object_5.put("pr_detail", "涡轮增压");
|
|
|
+ object_5.put("pr_spec", "速度快,耗油");
|
|
|
+ object_5.put("pd_outqty", "10");
|
|
|
+
|
|
|
+ object_6.put("pd_pdno", "1");
|
|
|
+ object_6.put("pd_id", "11");
|
|
|
+ object_6.put("pd_prodcode", "EM-822222222jfaghafo");
|
|
|
+ object_6.put("pr_detail", "涡轮增压2");
|
|
|
+ object_6.put("pr_spec", "速度快2,耗油");
|
|
|
+ object_6.put("pd_outqty", "12");
|
|
|
+ jsonArray.add(object_1);
|
|
|
+ jsonArray.add(object_2);
|
|
|
+ jsonArray.add(object_3);
|
|
|
+ jsonArray.add(object_4);
|
|
|
+ jsonArray.add(object_5);
|
|
|
+ jsonArray.add(object_6);
|
|
|
+ jsonObject.put("items", jsonArray);
|
|
|
+
|
|
|
+ JSONArray dataArray = FastjsonUtil.getJSONArray(jsonObject.toString(), "items");
|
|
|
+ handleFeededData(dataArray);
|
|
|
+ handleRecycleFeededData(dataArray);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //选择下拉框获取项目名称
|
|
|
+ public void getNewNameData(){
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_ADDRESSTAIL_GETPRODIODETAILT)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .addParam("pi_id", va_ids)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(), "items");
|
|
|
+ handleFeededData(dataArray);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void handleFeededData(JSONArray dataArray) {
|
|
|
+ TakeApartThePalletBean bean;
|
|
|
+ takeApartThePalletlist.clear();
|
|
|
+ for (Object index : dataArray) {
|
|
|
+ JSONObject data = (JSONObject) index;
|
|
|
+ bean= new TakeApartThePalletBean(
|
|
|
+ data.getString("pd_pdno"),
|
|
|
+ data.getString("pd_id"),
|
|
|
+ data.getString("pd_prodcode"),
|
|
|
+ data.getString("pr_detail"),
|
|
|
+ data.getString("pr_spec"),
|
|
|
+ data.getString("pd_outqty"));
|
|
|
+ takeApartThePalletlist.add(bean);
|
|
|
+ }
|
|
|
+ setAdapter(takeApartThePalletlist);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private void setAdapter(ArrayList<TakeApartThePalletBean> mList) {
|
|
|
+ selectAdapter = new SelectAdapter(mList);
|
|
|
+ ra_data.setAdapter(selectAdapter);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ ck_all.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
+ if (isChecked){
|
|
|
+// myAdapter.setItemChecked(mFeededList.size(), true);
|
|
|
+// myAdapter.setSelectable(true);
|
|
|
+// myAdapter.notifyItemChanged(mFeededList.size());
|
|
|
+// myAdapter.notifyDataSetChanged();
|
|
|
+ for (int i2=0;i2<takeApartThePalletlist.size();i2++){
|
|
|
+ selectAdapter.setItemChecked(i2, true);
|
|
|
+ selectAdapter.notifyItemChanged(i2);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+// myAdapter.setItemChecked(mFeededList.size(), false);
|
|
|
+// myAdapter.setSelectable(false);
|
|
|
+// myAdapter.notifyItemChanged(mFeededList.size());
|
|
|
+// myAdapter.notifyDataSetChanged();
|
|
|
+ for (int i2=0;i2<takeApartThePalletlist.size();i2++){
|
|
|
+ selectAdapter.setItemChecked(i2, false);
|
|
|
+ selectAdapter.notifyItemChanged(i2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Log.i("选择","isChecked");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ btn_commit.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ getDataid();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ public void getDataid(){
|
|
|
+ ArrayList<TakeApartThePalletBean> selectedItem = selectAdapter.getSelectedItem();
|
|
|
+ ArrayList<JsonStorateBean> list=new ArrayList<>();
|
|
|
+
|
|
|
+ for (int i=0;i<selectedItem.size();i++){
|
|
|
+ TakeApartThePalletBean takeApartThePalletBean = selectedItem.get(i);
|
|
|
+ JsonStorateBean jsonStorateBean=new JsonStorateBean(
|
|
|
+ takeApartThePalletBean.getPd_id(),
|
|
|
+ takeApartThePalletBean.getPd_prodcode(),
|
|
|
+ takeApartThePalletBean.getPd_outqty());
|
|
|
+ list.add(jsonStorateBean);
|
|
|
+ }
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ jsonArray.add(list);
|
|
|
+ Log.i("params===未处理",jsonArray.toString());
|
|
|
+ String substring = jsonArray.toString().substring(0, jsonArray.toString().length() - 1);//去除尾部
|
|
|
+ String substring1 = substring.substring(1, substring.length());//去除首部
|
|
|
+ Log.i("params===处理后",substring1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数修改量
|
|
|
+ */
|
|
|
+ private void initEditPopupWindow(ArrayList<TakeApartThePalletBean> mList,int i) {
|
|
|
+ View contView = LayoutInflater.from(mActivity).inflate(R.layout.index_edit_pup, null);
|
|
|
+ ClearableEditText edit_et = (ClearableEditText) contView.findViewById(R.id.edit_et);
|
|
|
+ TextView sure_tv = (TextView) contView.findViewById(R.id.sure_tv);
|
|
|
+ TextView cancle_tv = (TextView) contView.findViewById(R.id.cancle_tv);
|
|
|
+ editPW = new PopupWindow(contView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ editPW.setTouchable(true);
|
|
|
+ editPW.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ editPW.setOnDismissListener(new BasePopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ View parentView =mActivity.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
|
|
|
+ editPW.showAtLocation(parentView, Gravity.CENTER, 0, 0);
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
|
|
|
+ //确定
|
|
|
+ sure_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (edit_et.getText().toString().trim().isEmpty()){
|
|
|
+ CommonUtil.toastNoRepeat(mActivity,"请输入数量");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mList.get(i).setPd_outqty(edit_et.getText().toString().trim());
|
|
|
+ selectAdapter.notifyDataSetChanged();
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //取消
|
|
|
+ cancle_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 选择物料资料
|
|
|
+ */
|
|
|
+ private void initRecyclePopupWindow(ArrayList<TakeApartThePalletBean> mList,int i) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ View contView = LayoutInflater.from(mActivity).inflate(R.layout.index_recycleview_pup, null);
|
|
|
+ ClearableEditText edit_et = (ClearableEditText) contView.findViewById(R.id.edit_et);
|
|
|
+ RecyclerView rv_ip_port_data = contView.findViewById(R.id.rv_ip_port_data);
|
|
|
+ TextView sure_tv = (TextView) contView.findViewById(R.id.sure_tv);
|
|
|
+ TextView cancle_tv = (TextView) contView.findViewById(R.id.cancle_tv);
|
|
|
+
|
|
|
+ editPW = new PopupWindow(contView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ editPW.setTouchable(true);
|
|
|
+ editPW.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ editPW.setOnDismissListener(new BasePopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ View parentView =mActivity.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
|
|
|
+ editPW.showAtLocation(parentView, Gravity.CENTER, 0, 0);
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
|
|
|
+ andPortAdapter = new IpAndPortAdapter(delists);
|
|
|
+ rv_ip_port_data.addItemDecoration(new DividerItemDecoration(mActivity, LinearLayout.VERTICAL));
|
|
|
+ rv_ip_port_data.setLayoutManager(new LinearLayoutManager(mActivity));
|
|
|
+ andPortAdapter.setmList(delists);
|
|
|
+ rv_ip_port_data.setAdapter(andPortAdapter);
|
|
|
+
|
|
|
+ andPortAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ List<CheckProdcodeBean> ipAndPortBeans = andPortAdapter.getmList();
|
|
|
+ pd_prodcode = ipAndPortBeans.get(position).getPd_prodcode();
|
|
|
+
|
|
|
+ for (int s = 0; s < ipAndPortBeans.size(); s++) {
|
|
|
+ ipAndPortBeans.get(s).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndPortBeans.get(position).setChecked(true);
|
|
|
+ andPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //确定
|
|
|
+ sure_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (pd_prodcode.isEmpty()){
|
|
|
+ CommonUtil.toastNoRepeat(mActivity,"请选择规格");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mList.get(i).setPd_prodcode(pd_prodcode);
|
|
|
+ selectAdapter.notifyDataSetChanged();
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //取消
|
|
|
+ cancle_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ private void handleRecycleFeededData(JSONArray dataArray) {
|
|
|
+ delists = new ArrayList<>();
|
|
|
+ CheckProdcodeBean bean;
|
|
|
+ delists.clear();
|
|
|
+ for (Object index : dataArray) {
|
|
|
+ JSONObject data = (JSONObject) index;
|
|
|
+ bean= new CheckProdcodeBean(
|
|
|
+ data.getString("pd_pdno"),
|
|
|
+ data.getString("pd_id"),
|
|
|
+ data.getString("pd_prodcode"),
|
|
|
+ data.getString("pr_detail"),
|
|
|
+ data.getString("pr_spec"),
|
|
|
+ data.getString("pd_outqty"));
|
|
|
+ delists.add(bean);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ private void closeListPopupWindow() {
|
|
|
+ if (editPW != null) {
|
|
|
+ editPW.dismiss();
|
|
|
+ editPW = null;
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 1f);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onHiddenChanged(boolean hidden) {
|
|
|
+ super.onHiddenChanged(hidden);
|
|
|
+ if (hidden) {
|
|
|
+ ((FunctionActivity) getActivity()).setListIconIvVisible(false);
|
|
|
+ } else {
|
|
|
+ FunctionActivity.setTitle(getString(R.string.title_materialchange));
|
|
|
+ ((FunctionActivity) getActivity()).setListIconIvVisible(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 表格数据适配器
|
|
|
+ */
|
|
|
+ public class SelectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
+
|
|
|
+ private ArrayList<TakeApartThePalletBean> mList = new ArrayList<>();
|
|
|
+
|
|
|
+ private SparseBooleanArray mSelectedPositions = new SparseBooleanArray();
|
|
|
+ private boolean mIsSelectable = false;
|
|
|
+
|
|
|
+
|
|
|
+ public SelectAdapter(ArrayList<TakeApartThePalletBean> list) {
|
|
|
+ if (list == null) {
|
|
|
+ throw new IllegalArgumentException("model Data must not be null");
|
|
|
+ }
|
|
|
+ mList = list;
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新adpter的数据和选择状态
|
|
|
+ public void updateDataSet(ArrayList<TakeApartThePalletBean> list) {
|
|
|
+ this.mList = list;
|
|
|
+ mSelectedPositions = new SparseBooleanArray();
|
|
|
+// ab.setTitle("已选择" + 0 + "项");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //获得选中条目的结果
|
|
|
+ public ArrayList<TakeApartThePalletBean> getSelectedItem() {
|
|
|
+ ArrayList<TakeApartThePalletBean> selectList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < mList.size(); i++) {
|
|
|
+ if (isItemChecked(i)) {
|
|
|
+ selectList.add(mList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return selectList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
|
+ View itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.takeapartthepallet_item, viewGroup, false);
|
|
|
+ return new ListItemViewHolder(itemView);
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置给定位置条目的选择状态
|
|
|
+ private void setItemChecked(int position, boolean isChecked) {
|
|
|
+ mSelectedPositions.put(position, isChecked);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据位置判断条目是否选中
|
|
|
+ private boolean isItemChecked(int position) {
|
|
|
+ return mSelectedPositions.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据位置判断条目是否可选
|
|
|
+ private boolean isSelectable() {
|
|
|
+ return mIsSelectable;
|
|
|
+ }
|
|
|
+ //设置给定位置条目的可选与否的状态
|
|
|
+ private void setSelectable(boolean selectable) {
|
|
|
+ mIsSelectable = selectable;
|
|
|
+ }
|
|
|
+
|
|
|
+ //绑定界面,设置监听
|
|
|
+ @Override
|
|
|
+ public void onBindViewHolder(final RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") final int i) {
|
|
|
+ //设置条目状态
|
|
|
+ ((ListItemViewHolder) holder).tv_pd_pdno.setText(mList.get(i).getPd_pdno());
|
|
|
+ ((ListItemViewHolder) holder).tv_pd_prodcode.setText(mList.get(i).getPd_prodcode());
|
|
|
+ ((ListItemViewHolder) holder).tv_pr_detail.setText(mList.get(i).getPr_detail());
|
|
|
+ ((ListItemViewHolder) holder).tv_pr_spec.setText(mList.get(i).getPr_spec());
|
|
|
+ ((ListItemViewHolder) holder).tv_pd_outqty.setText(mList.get(i).getPd_outqty());
|
|
|
+ ((ListItemViewHolder) holder).checkBox.setChecked(isItemChecked(i));
|
|
|
+ ((ListItemViewHolder) holder).tv_pd_outqty.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+
|
|
|
+ initEditPopupWindow(mList,i);
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ((ListItemViewHolder) holder).tv_pd_prodcode.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ initRecyclePopupWindow(mList,i);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //checkBox的监听
|
|
|
+ ((ListItemViewHolder) holder).checkBox.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (isItemChecked(i)) {
|
|
|
+ setItemChecked(i, false);
|
|
|
+ } else {
|
|
|
+ setItemChecked(i, true);
|
|
|
+ }
|
|
|
+// for (int i2=0;i2<mList.size();i2++){
|
|
|
+// setItemChecked(i2, true);
|
|
|
+// }
|
|
|
+
|
|
|
+// ab.setTitle("已选择" + getSelectedItem().size() + "项");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //条目view的监听
|
|
|
+ ((ListItemViewHolder) holder).itemView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (isItemChecked(i)) {
|
|
|
+ setItemChecked(i, false);
|
|
|
+ } else {
|
|
|
+ setItemChecked(i, true);
|
|
|
+ }
|
|
|
+ notifyItemChanged(i);
|
|
|
+// ab.setTitle("已选择" + getSelectedItem().size() + "项");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getItemCount() {
|
|
|
+ return mList == null ? 0 : mList.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ public class ListItemViewHolder extends RecyclerView.ViewHolder{
|
|
|
+ //ViewHolder
|
|
|
+ CheckBox checkBox;
|
|
|
+ TextView tv_pd_pdno;
|
|
|
+ TextView tv_pd_prodcode;
|
|
|
+ TextView tv_pr_detail;
|
|
|
+ TextView tv_pr_spec;
|
|
|
+ TextView tv_pd_outqty;
|
|
|
+
|
|
|
+ ListItemViewHolder(View view) {
|
|
|
+ super(view);
|
|
|
+ this.tv_pd_pdno = (TextView) view.findViewById(R.id.tv_pd_pdno);
|
|
|
+ this.tv_pd_prodcode = (TextView) view.findViewById(R.id.tv_pd_prodcode);
|
|
|
+ this.tv_pr_detail = (TextView) view.findViewById(R.id.tv_pr_detail);
|
|
|
+ this.tv_pr_spec = (TextView) view.findViewById(R.id.tv_pr_spec);
|
|
|
+ this.tv_pd_outqty = (TextView) view.findViewById(R.id.tv_pd_outqty);
|
|
|
+ this.checkBox = (CheckBox) view.findViewById(R.id.select_checkbox);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ *选择
|
|
|
+ */
|
|
|
+ private class IpAndPortAdapter extends BaseQuickAdapter<CheckProdcodeBean, BaseViewHolder> {
|
|
|
+ private List<CheckProdcodeBean> mmmmList;
|
|
|
+
|
|
|
+ public List<CheckProdcodeBean> getmList() {
|
|
|
+ return mmmmList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setmList(List<CheckProdcodeBean> mList) {
|
|
|
+ this.mmmmList = mList;
|
|
|
+ }
|
|
|
+ public CheckProdcodeBean getBeanByPositon(int position){
|
|
|
+ return mmmmList.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ private IpAndPortAdapter(@Nullable List<CheckProdcodeBean> data) {
|
|
|
+ super(R.layout.fuzzy_ipandport_item, data);
|
|
|
+ this.mmmmList = data;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ protected void convert(BaseViewHolder helper, CheckProdcodeBean item) {
|
|
|
+ helper.setText(R.id.macode_ip__Tv,item.getPd_prodcode()+"-"+item.getPd_outqty()+"-"+item.getPr_spec());
|
|
|
+ LinearLayout line_true = helper.itemView.findViewById(R.id.line_true);
|
|
|
+ if (item.getChecked()) {
|
|
|
+ line_true.setSelected(true);
|
|
|
+ } else {
|
|
|
+ line_true.setSelected(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|