|
|
@@ -0,0 +1,712 @@
|
|
|
+package com.uas.ruiziuasmes.activity;
|
|
|
+
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
+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.text.TextUtils;
|
|
|
+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.view.inputmethod.EditorInfo;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.ArrayAdapter;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.CheckBox;
|
|
|
+import android.widget.CompoundButton;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.PopupWindow;
|
|
|
+import android.widget.Spinner;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+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.ruiziuasmes.R;
|
|
|
+import com.uas.ruiziuasmes.bean.DeviceListBean;
|
|
|
+import com.uas.ruiziuasmes.bean.LineCodeEntity;
|
|
|
+import com.uas.ruiziuasmes.global.GloableParams;
|
|
|
+import com.uas.ruiziuasmes.tools.SharedPreUtil;
|
|
|
+import com.uas.ruiziuasmes.util.CommonUtil;
|
|
|
+import com.uas.ruiziuasmes.util.Constants;
|
|
|
+import com.uas.ruiziuasmes.util.FastjsonUtil;
|
|
|
+import com.uas.ruiziuasmes.util.HttpCallback;
|
|
|
+import com.uas.ruiziuasmes.util.HttpParams;
|
|
|
+import com.uas.ruiziuasmes.util.LogUtil;
|
|
|
+import com.uas.ruiziuasmes.util.StringUtil;
|
|
|
+import com.uas.ruiziuasmes.util.VollyRequest;
|
|
|
+import com.uas.ruiziuasmes.view.ClearableEditText;
|
|
|
+
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import razerdp.basepopup.BasePopupWindow;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by sw on 2024-11-23
|
|
|
+ */
|
|
|
+public class BatchMaintenanceEquipmentActivity extends BaseActivity {
|
|
|
+
|
|
|
+ private TextView tv_wulixianbie;
|
|
|
+ private ClearableEditText cet_shebeibianhao;
|
|
|
+ private ImageView iv_search;
|
|
|
+ private Spinner s_maintain_type;
|
|
|
+ private Button bt_maintain;
|
|
|
+ private RecyclerView rv_date_list;
|
|
|
+
|
|
|
+ private IpAndwuliPortAdapter ipAndwuliPortAdapter;
|
|
|
+ private ArrayList<LineCodeEntity> wulilist;
|
|
|
+ private ClearableEditText edit_et;
|
|
|
+ private RecyclerView rv_line_ip_port_data;
|
|
|
+ private PopupWindow editPW;
|
|
|
+
|
|
|
+ private String li_code;
|
|
|
+ private List<String> mSearchTypes;
|
|
|
+ private String mSearchType;
|
|
|
+ private ArrayAdapter mTypeArrayAdapter;
|
|
|
+ private SelectAdapter myAdapter;
|
|
|
+ private ArrayList<DeviceListBean> mFeededList;
|
|
|
+
|
|
|
+ private String caller = "";
|
|
|
+ private Button btn_actionbar_withback;
|
|
|
+
|
|
|
+ private LinearLayout ll_quanxuan;
|
|
|
+ private CheckBox cb_quanxuan;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ setContentView(R.layout.act_batch_maintenance_equipment);
|
|
|
+
|
|
|
+ btn_actionbar_withback = (Button) findViewById(R.id.btn_actionbar_withback);
|
|
|
+ ImageView btn_actionbar_scan_iv = (ImageView) findViewById(R.id.btn_actionbar_scan_iv);
|
|
|
+ TextView actionbarTextVeiw = (TextView) findViewById(R.id.actionbar);
|
|
|
+ actionbarTextVeiw.setText("设备批量保养");
|
|
|
+ btn_actionbar_scan_iv.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ tv_wulixianbie = findViewById(R.id.tv_wulixianbie);
|
|
|
+ iv_search = findViewById(R.id.iv_search);
|
|
|
+ cet_shebeibianhao = findViewById(R.id.cet_shebeibianhao);
|
|
|
+ s_maintain_type = findViewById(R.id.s_maintain_type);
|
|
|
+ rv_date_list = findViewById(R.id.rv_date_list);
|
|
|
+ bt_maintain = findViewById(R.id.bt_maintain);
|
|
|
+
|
|
|
+ ll_quanxuan = (LinearLayout) findViewById(R.id.ll_quanxuan);
|
|
|
+ cb_quanxuan = (CheckBox)findViewById(R.id.cb_quanxuan);
|
|
|
+ cet_shebeibianhao.requestFocus();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ wulilist = new ArrayList<>();
|
|
|
+ cb_quanxuan.setChecked(false);
|
|
|
+
|
|
|
+ cb_quanxuan.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
+ if (buttonView.isPressed()) {
|
|
|
+ if (isChecked) {
|
|
|
+ caller = "";
|
|
|
+ for (int i1 = 0; i1 < mFeededList.size(); i1++) {
|
|
|
+ caller += mFeededList.get(i1).getDE_CODE() + ",";
|
|
|
+ mFeededList.get(i1).setSelect(true);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ caller = "";
|
|
|
+ for (int i1 = 0; i1 < mFeededList.size(); i1++) {
|
|
|
+ mFeededList.get(i1).setSelect(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ myAdapter.updateDataSet(mFeededList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ btn_actionbar_withback.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ iv_search.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ initwuliPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ cet_shebeibianhao.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
+ if (actionId == EditorInfo.IME_ACTION_DONE
|
|
|
+ || actionId == EditorInfo.IME_ACTION_SEND
|
|
|
+ || (event != null && event.getAction() == KeyEvent.ACTION_DOWN
|
|
|
+ && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
+ String shebei = cet_shebeibianhao.getText().toString().trim();
|
|
|
+ getDeviceListInof(shebei,tv_wulixianbie.getText().toString().trim());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ bt_maintain.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ saveDevicesInfo();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveDevicesInfo() {
|
|
|
+ String mSearchType = SharedPreUtil.getString(BatchMaintenanceEquipmentActivity.this, Constants.FLAG.DEVICES_MAINTAIN, "dianjian");
|
|
|
+ String mSTypes = "";
|
|
|
+ if ("dianjian".equals(mSearchType)) {
|
|
|
+ mSTypes = "点检";
|
|
|
+ } else if ("ribaoyang".equals(mSearchType)) {
|
|
|
+ mSTypes = "日保养";
|
|
|
+ } else if ("zhoubaoyang".equals(mSearchType)) {
|
|
|
+ mSTypes = "周保养";
|
|
|
+ } else if ("yuebaoyang".equals(mSearchType)) {
|
|
|
+ mSTypes = "月保养";
|
|
|
+ } else if ("nianbaoyang".equals(mSearchType)) {
|
|
|
+ mSTypes = "年保养";
|
|
|
+ } else if ("xiaozhun".equals(mSearchType)) {
|
|
|
+ mSTypes = "校准";
|
|
|
+ }
|
|
|
+
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_MAINTENANCE)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .addParam("caller",mSTypes)
|
|
|
+ .addParam("de_code",caller.length() > 1 ? caller.substring(0, caller.length() - 1) : caller)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ CommonUtil.toastNoRepeat(BatchMaintenanceEquipmentActivity.this, "保养成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(BatchMaintenanceEquipmentActivity.this, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ mSearchTypes = new ArrayList<>();
|
|
|
+
|
|
|
+ mSearchTypes.add("点检");
|
|
|
+ mSearchTypes.add("日保养");
|
|
|
+ mSearchTypes.add("周保养");
|
|
|
+ mSearchTypes.add("月保养");
|
|
|
+ mSearchTypes.add("年保养");
|
|
|
+ mSearchTypes.add("校准");
|
|
|
+
|
|
|
+ mTypeArrayAdapter = new ArrayAdapter(BatchMaintenanceEquipmentActivity.this, R.layout.layout_myspinner2, mSearchTypes);
|
|
|
+ mTypeArrayAdapter.setDropDownViewResource(R.layout.layout_myspinner_dropdown);
|
|
|
+ s_maintain_type.setAdapter(mTypeArrayAdapter);
|
|
|
+
|
|
|
+ s_maintain_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ // 获取所选的位置
|
|
|
+ //String selectedOption = parent.getItemAtPosition(position).toString();
|
|
|
+ if ("点检".equals(mTypeArrayAdapter.getItem(position).toString())) {
|
|
|
+ mSearchType = "dianjian";
|
|
|
+ } else if ("日保养".equals(mTypeArrayAdapter.getItem(position).toString())) {
|
|
|
+ mSearchType = "ribaoyang";
|
|
|
+ } else if ("周保养".equals(mTypeArrayAdapter.getItem(position).toString())) {
|
|
|
+ mSearchType = "zhoubaoyang";
|
|
|
+ } else if ("月保养".equals(mTypeArrayAdapter.getItem(position).toString())) {
|
|
|
+ mSearchType = "yuebaoyang";
|
|
|
+ } else if ("年保养".equals(mTypeArrayAdapter.getItem(position).toString())) {
|
|
|
+ mSearchType = "nianbaoyang";
|
|
|
+ } else if ("校准".equals(mTypeArrayAdapter.getItem(position).toString())) {
|
|
|
+ mSearchType = "xiaozhun";
|
|
|
+ }
|
|
|
+ s_maintain_type.setSelection(position);
|
|
|
+ SharedPreUtil.saveString(BatchMaintenanceEquipmentActivity.this, Constants.FLAG.DEVICES_MAINTAIN, mSearchType);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNothingSelected(AdapterView<?> parent) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mSearchType = SharedPreUtil.getString(BatchMaintenanceEquipmentActivity.this, Constants.FLAG.DEVICES_MAINTAIN, "dianjian");
|
|
|
+ s_maintain_type.setSelection(0);
|
|
|
+ if ("dianjian".equals(mSearchType)) {
|
|
|
+ s_maintain_type.setSelection(0);
|
|
|
+ //CommonUtil.setSpinnerItemSelectedByValue(s_maintain_type, "点检");
|
|
|
+ } else if ("ribaoyang".equals(mSearchType)) {
|
|
|
+ s_maintain_type.setSelection(1);
|
|
|
+ // CommonUtil.setSpinnerItemSelectedByValue(s_maintain_type, "日保养");
|
|
|
+ } else if ("zhoubaoyang".equals(mSearchType)) {
|
|
|
+ s_maintain_type.setSelection(2);
|
|
|
+ // CommonUtil.setSpinnerItemSelectedByValue(s_maintain_type, "周保养");
|
|
|
+ } else if ("yuebaoyang".equals(mSearchType)) {
|
|
|
+ s_maintain_type.setSelection(3);
|
|
|
+ // CommonUtil.setSpinnerItemSelectedByValue(s_maintain_type, "月保养");
|
|
|
+ } else if ("nianbaoyang".equals(mSearchType)) {
|
|
|
+ s_maintain_type.setSelection(4);
|
|
|
+ // CommonUtil.setSpinnerItemSelectedByValue(s_maintain_type, "年保养");
|
|
|
+ } else if ("xiaozhun".equals(mSearchType)) {
|
|
|
+ s_maintain_type.setSelection(5);
|
|
|
+ //CommonUtil.setSpinnerItemSelectedByValue(s_maintain_type, "校准");
|
|
|
+ }
|
|
|
+ mFeededList = new ArrayList<>();
|
|
|
+ myAdapter = new SelectAdapter(mFeededList);
|
|
|
+
|
|
|
+ rv_date_list.addItemDecoration(new DividerItemDecoration(BatchMaintenanceEquipmentActivity.this, LinearLayout.VERTICAL));
|
|
|
+ rv_date_list.setLayoutManager(new LinearLayoutManager(BatchMaintenanceEquipmentActivity.this));
|
|
|
+ //设置Item增加、移除动画
|
|
|
+ rv_date_list.setItemAnimator(new DefaultItemAnimator());
|
|
|
+ setAdapter(mFeededList);
|
|
|
+ rv_date_list.setAdapter(myAdapter);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void getDeviceListInof(String shebei, String wulixianbie) {
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_DEVICES_LIST)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .addParam("li_code",wulixianbie)
|
|
|
+ .addParam("de_code",shebei)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(),"data");
|
|
|
+ if (dataArray == null || dataArray.size() == 0){
|
|
|
+ CommonUtil.toastNoRepeat(BatchMaintenanceEquipmentActivity.this,"未搜索到匹配数据");
|
|
|
+ }
|
|
|
+ if (dataArray.size() > 0) {
|
|
|
+ ll_quanxuan.setVisibility(View.VISIBLE);
|
|
|
+ mFeededList.clear();
|
|
|
+ for (Object index : dataArray) {
|
|
|
+ JSONObject data = (JSONObject) index;
|
|
|
+ DeviceListBean deviceListBean = new DeviceListBean();
|
|
|
+ deviceListBean.setSelect(false);
|
|
|
+ deviceListBean.setDE_CODE(data.getString("DE_CODE"));
|
|
|
+ deviceListBean.setDE_NAME(data.getString("DE_NAME"));
|
|
|
+ deviceListBean.setDE_KIND(data.getString("DE_KIND"));
|
|
|
+ deviceListBean.setDE_TYPE(data.getString("DE_TYPE"));
|
|
|
+ mFeededList.add(deviceListBean);
|
|
|
+ }
|
|
|
+ setAdapter(mFeededList);
|
|
|
+ }else {
|
|
|
+ ll_quanxuan.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(BatchMaintenanceEquipmentActivity.this, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initwuliPopupWindow() {
|
|
|
+ ipAndwuliPortAdapter = new IpAndwuliPortAdapter(wulilist);
|
|
|
+ View contView = LayoutInflater.from(BatchMaintenanceEquipmentActivity.this).inflate(R.layout.index_line_pup, null);
|
|
|
+ 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);
|
|
|
+ ImageView search_im = contView.findViewById(R.id.search_im);
|
|
|
+ LinearLayout line_top = contView.findViewById(R.id.line_top);
|
|
|
+ rv_line_ip_port_data = contView.findViewById(R.id.rv_ip_port_data);
|
|
|
+ rv_line_ip_port_data.addItemDecoration(new DividerItemDecoration(BatchMaintenanceEquipmentActivity.this, LinearLayout.VERTICAL));
|
|
|
+ rv_line_ip_port_data.setLayoutManager(new LinearLayoutManager(BatchMaintenanceEquipmentActivity.this));
|
|
|
+ ipAndwuliPortAdapter.setmList(wulilist);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndwuliPortAdapter);
|
|
|
+ getwuliDataList();
|
|
|
+ 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 = BatchMaintenanceEquipmentActivity.this.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
|
|
|
+ editPW.showAtLocation(parentView, Gravity.CENTER, 0, 0);
|
|
|
+ CommonUtil.setBackgroundAlpha(BatchMaintenanceEquipmentActivity.this, 0.5f);
|
|
|
+ search_im.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ String mSearchStr = edit_et.getText().toString().trim();
|
|
|
+ if (!mSearchStr.isEmpty()) {
|
|
|
+ List<LineCodeEntity> thisList = new ArrayList<>();
|
|
|
+ for(int i=0;i<wulilist.size();i++){
|
|
|
+ if(wulilist.get(i).getLI_CODE().contains(mSearchStr)){
|
|
|
+ thisList.add(wulilist.get(i));
|
|
|
+ }
|
|
|
+ if(i == wulilist.size() -1){
|
|
|
+ ipAndwuliPortAdapter = new IpAndwuliPortAdapter(thisList);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndwuliPortAdapter);
|
|
|
+ LogUtil.i("mSearchStr", JSON.toJSONString(thisList));
|
|
|
+
|
|
|
+ }
|
|
|
+ List<LineCodeEntity> lineCodeEntities = ipAndwuliPortAdapter.getmList();
|
|
|
+ for (int j = 0; j < lineCodeEntities.size(); j++) {
|
|
|
+ lineCodeEntities.get(j).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndwuliPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ipAndwuliPortAdapter = new IpAndwuliPortAdapter(wulilist);
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndwuliPortAdapter);
|
|
|
+ List<LineCodeEntity> lineCodeEntities = ipAndwuliPortAdapter.getmList();
|
|
|
+ for (int i = 0; i < lineCodeEntities.size(); i++) {
|
|
|
+ lineCodeEntities.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ ipAndwuliPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ ipAndwuliPortAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ List<LineCodeEntity> lineCodeEntities = ipAndwuliPortAdapter.getmList();
|
|
|
+ li_code = lineCodeEntities.get(position).getLI_CODE();
|
|
|
+ for (int i = 0; i < lineCodeEntities.size(); i++) {
|
|
|
+ lineCodeEntities.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ lineCodeEntities.get(position).setChecked(true);
|
|
|
+ ipAndwuliPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ipAndwuliPortAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ List<LineCodeEntity> lineCodeEntities = ipAndwuliPortAdapter.getmList();
|
|
|
+ li_code = lineCodeEntities.get(position).getLI_CODE();
|
|
|
+ for (int i = 0; i < lineCodeEntities.size(); i++) {
|
|
|
+ lineCodeEntities.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ lineCodeEntities.get(position).setChecked(true);
|
|
|
+ ipAndwuliPortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //确定
|
|
|
+ sure_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (!StringUtil.isEmpty(li_code)){
|
|
|
+ tv_wulixianbie.setText(li_code);
|
|
|
+ }else {
|
|
|
+ CommonUtil.toastNoRepeat(BatchMaintenanceEquipmentActivity.this,"请选择物理线体");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String shebei = cet_shebeibianhao.getText().toString().trim();
|
|
|
+ getDeviceListInof(shebei,tv_wulixianbie.getText().toString().trim());
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //取消
|
|
|
+ cancle_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void closeListPopupWindow() {
|
|
|
+ if (editPW != null) {
|
|
|
+ editPW.dismiss();
|
|
|
+ editPW = null;
|
|
|
+ CommonUtil.setBackgroundAlpha(BatchMaintenanceEquipmentActivity.this, 1f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 物理线别
|
|
|
+ */
|
|
|
+ private void getwuliDataList(){
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADDRESS_SPM_GETLINE)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ wulilist.clear();
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONArray dataArray = resultObject.getJSONArray("data");
|
|
|
+ if (dataArray != null) {
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ JSONObject dataObject = dataArray.getJSONObject(i);
|
|
|
+ if (dataObject != null) {
|
|
|
+ LineCodeEntity lineCodeEntity = new LineCodeEntity();
|
|
|
+ lineCodeEntity.setLI_CODE(FastjsonUtil.getText(dataObject, "LI_CODE"));
|
|
|
+ lineCodeEntity.setLI_NAME(FastjsonUtil.getText(dataObject, "LI_NAME"));
|
|
|
+
|
|
|
+ wulilist.add(lineCodeEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (wulilist.size() == 0) {
|
|
|
+ CommonUtil.toastNoRepeat(BatchMaintenanceEquipmentActivity.this, "线别数据为空");
|
|
|
+ } else {
|
|
|
+ setwuliAdapter(wulilist);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(BatchMaintenanceEquipmentActivity.this, failStr);
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setwuliAdapter(ArrayList<LineCodeEntity> mList) {
|
|
|
+ LogUtil.i("mList", JSON.toJSONString(mList));
|
|
|
+ ipAndwuliPortAdapter.setmList(wulilist);
|
|
|
+ ipAndwuliPortAdapter.notifyDataSetChanged();
|
|
|
+ rv_line_ip_port_data.setAdapter(ipAndwuliPortAdapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ private class IpAndwuliPortAdapter extends BaseQuickAdapter<LineCodeEntity, BaseViewHolder> {
|
|
|
+ private List<LineCodeEntity> mmmmList;
|
|
|
+
|
|
|
+ public List<LineCodeEntity> getmList() {
|
|
|
+ return mmmmList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setmList(List<LineCodeEntity> mList) {
|
|
|
+ this.mmmmList = mList;
|
|
|
+ }
|
|
|
+ public LineCodeEntity getBeanByPositon(int position){
|
|
|
+ return mmmmList.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ private IpAndwuliPortAdapter(@Nullable List<LineCodeEntity> data) {
|
|
|
+ super(R.layout.fuzzy_ipandport_item, data);
|
|
|
+ this.mmmmList = data;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ protected void convert(BaseViewHolder helper, LineCodeEntity item) {
|
|
|
+ helper.setText(R.id.macode_ip__Tv,item.getLI_NAME()+"("+item.getLI_CODE()+")");
|
|
|
+ LinearLayout line_true = helper.itemView.findViewById(R.id.line_true);
|
|
|
+ if (item.getChecked()) {
|
|
|
+ line_true.setSelected(true);
|
|
|
+ } else {
|
|
|
+ line_true.setSelected(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setAdapter(ArrayList<DeviceListBean> mList) {
|
|
|
+ LogUtil.i("mList", JSON.toJSONString(mList));
|
|
|
+ myAdapter = new SelectAdapter(mList);
|
|
|
+ rv_date_list.setAdapter(myAdapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ public class SelectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
+
|
|
|
+ private ArrayList<DeviceListBean> mList = new ArrayList<>();
|
|
|
+ private SparseBooleanArray mSelectedPositions = new SparseBooleanArray();
|
|
|
+ private boolean mIsSelectable = false;
|
|
|
+
|
|
|
+ public SelectAdapter(ArrayList<DeviceListBean> list) {
|
|
|
+ if (list == null) {
|
|
|
+ throw new IllegalArgumentException("model Data must not be null");
|
|
|
+ }
|
|
|
+ mList = list;
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新adpter的数据和选择状态
|
|
|
+ public void updateDataSet(ArrayList<DeviceListBean> list) {
|
|
|
+ this.mList = list;
|
|
|
+ mSelectedPositions = new SparseBooleanArray();
|
|
|
+ // ab.setTitle("已选择" + 0 + "项");
|
|
|
+ notifyDataSetChanged();
|
|
|
+ }
|
|
|
+
|
|
|
+ //获得选中条目的结果
|
|
|
+ public ArrayList<DeviceListBean> getSelectedItem() {
|
|
|
+ ArrayList<DeviceListBean> 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.item_devices_list, viewGroup, false);
|
|
|
+ return new SelectAdapter.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.@NotNull ViewHolder holder, @SuppressLint("RecyclerView") int i) {
|
|
|
+ //设置条目状态
|
|
|
+ ((SelectAdapter.ListItemViewHolder) holder).tv_liaocode.setText("设备编号:"+mList.get(i).getDE_CODE());
|
|
|
+ ((SelectAdapter.ListItemViewHolder) holder).tv_liaotetall.setText("设备名称:"+mList.get(i).getDE_NAME());
|
|
|
+ ((SelectAdapter.ListItemViewHolder) holder).tv_liaospec.setText("规格:"+mList.get(i).getDE_KIND());
|
|
|
+ ((SelectAdapter.ListItemViewHolder) holder).tv_liaospec3.setText("设备类型:"+mList.get(i).getDE_TYPE());
|
|
|
+
|
|
|
+ ((ListItemViewHolder) holder).checkBox.setChecked(mList.get(i).isSelect());
|
|
|
+
|
|
|
+ ((ListItemViewHolder) holder).checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
+ // boolean bbb = ((ListItemViewHolder) holder).checkBox.isChecked();
|
|
|
+ // LogUtil.e("aaa", "执行了: " + "checkBox.setOnClickListener" + bbb);
|
|
|
+ // ((ListItemViewHolder) holder).checkBox.setChecked(!bbb);
|
|
|
+ // mList.get(i).setChecked(!bbb);
|
|
|
+
|
|
|
+ if (buttonView.isPressed()) { //只有当用户主动点击时才处理选中状态变化
|
|
|
+ if (isChecked) {
|
|
|
+ if (!TextUtils.isEmpty(caller)) {
|
|
|
+ if (!caller.contains(mList.get(i).getDE_CODE())) {
|
|
|
+ caller += mList.get(i).getDE_CODE() + ",";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ caller = mList.get(i).getDE_CODE() + ",";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ boolean checked = cb_quanxuan.isChecked();
|
|
|
+ if (checked) {
|
|
|
+ cb_quanxuan.setChecked(false);
|
|
|
+ }
|
|
|
+ if (!TextUtils.isEmpty(caller)) {
|
|
|
+ if (caller.contains(mList.get(i).getDE_CODE())) {
|
|
|
+ // caller += mList.get(i).getBAN_BARCODE() + ",";
|
|
|
+ int startIndex = caller.indexOf(mList.get(i).getDE_CODE());
|
|
|
+ int endIndex = startIndex + mList.get(i).getDE_CODE().length() + 1;
|
|
|
+ // 删除子串
|
|
|
+ caller = caller.substring(0, startIndex).concat(caller.substring(endIndex));
|
|
|
+ LogUtil.e("aaa","checkBox.setOnCheckedChangeListener长度是:" +caller);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ((ListItemViewHolder) holder).ll_all_info.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ LogUtil.e("aaa", "执行了: " + "ll_layout.setOnClickListener");
|
|
|
+ boolean bbb = ((ListItemViewHolder) holder).checkBox.isChecked();
|
|
|
+ ((ListItemViewHolder) holder).checkBox.setChecked(!bbb);
|
|
|
+ mList.get(i).setSelect(!bbb);
|
|
|
+ if (!bbb) {
|
|
|
+ if (!TextUtils.isEmpty(caller)) {
|
|
|
+ if (!caller.contains(mList.get(i).getDE_CODE())) {
|
|
|
+ caller += mList.get(i).getDE_CODE() + ",";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ caller = mList.get(i).getDE_CODE() + ",";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ boolean checked = cb_quanxuan.isChecked();
|
|
|
+ if (checked) {
|
|
|
+ cb_quanxuan.setChecked(false);
|
|
|
+ }
|
|
|
+ if (!TextUtils.isEmpty(caller)) {
|
|
|
+ if (caller.contains(mList.get(i).getDE_CODE())) {
|
|
|
+ // caller += mList.get(i).getBAN_BARCODE() + ",";
|
|
|
+ int startIndex = caller.indexOf(mList.get(i).getDE_CODE());
|
|
|
+ int endIndex = startIndex + mList.get(i).getDE_CODE().length() + 1;
|
|
|
+ // 删除子串
|
|
|
+ caller = caller.substring(0, startIndex).concat(caller.substring(endIndex));
|
|
|
+ LogUtil.e("aaa","ll_all_info.setOnClickListener长度是:" +caller);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getItemCount() {
|
|
|
+ return mList == null ? 0 : mList.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ public class ListItemViewHolder extends RecyclerView.ViewHolder{
|
|
|
+ //ViewHolder
|
|
|
+ CheckBox checkBox;
|
|
|
+ TextView tv_liaocode;
|
|
|
+ TextView tv_liaotetall;
|
|
|
+ TextView tv_liaospec;
|
|
|
+ TextView tv_liaospec3;
|
|
|
+ LinearLayout ll_all_info;
|
|
|
+ ListItemViewHolder(View view) {
|
|
|
+ super(view);
|
|
|
+ this.tv_liaocode = (TextView) view.findViewById(R.id.tv_liaocode);
|
|
|
+ this.tv_liaotetall = (TextView) view.findViewById(R.id.tv_liaotetall);
|
|
|
+ this.tv_liaospec = (TextView) view.findViewById(R.id.tv_liaospec);
|
|
|
+ this.checkBox = (CheckBox) view.findViewById(R.id.select_checkbox);
|
|
|
+ this.tv_liaospec3 = (TextView) view.findViewById(R.id.tv_liaospec3);
|
|
|
+ this.ll_all_info = (LinearLayout) view.findViewById(R.id.ll_all_info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|