|
|
@@ -1,763 +0,0 @@
|
|
|
-package com.wisdom.hydroponics.ui.activity;
|
|
|
-
|
|
|
-import android.app.AlertDialog;
|
|
|
-import android.content.Intent;
|
|
|
-import android.os.Bundle;
|
|
|
-import android.os.Handler;
|
|
|
-import android.os.Message;
|
|
|
-import android.text.TextUtils;
|
|
|
-import android.util.Log;
|
|
|
-import android.view.LayoutInflater;
|
|
|
-import android.view.View;
|
|
|
-import android.widget.Button;
|
|
|
-import android.widget.CompoundButton;
|
|
|
-import android.widget.ImageView;
|
|
|
-import android.widget.LinearLayout;
|
|
|
-import android.widget.Switch;
|
|
|
-import android.widget.TextView;
|
|
|
-import android.widget.TimePicker;
|
|
|
-
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.wisdom.hydroponics.R;
|
|
|
-import com.wisdom.hydroponics.base.BaseActivity;
|
|
|
-import com.wisdom.hydroponics.bean.BindDeviceBean;
|
|
|
-import com.wisdom.hydroponics.bean.DeviceNodeBean;
|
|
|
-import com.wisdom.hydroponics.utils.SPUtil;
|
|
|
-import com.wisdom.hydroponics.utils.WQNetUtil;
|
|
|
-import com.wisdom.hydroponics.utils.WQUtils;
|
|
|
-
|
|
|
-import org.json.JSONException;
|
|
|
-import org.json.JSONObject;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import butterknife.BindView;
|
|
|
-import butterknife.ButterKnife;
|
|
|
-import butterknife.OnClick;
|
|
|
-
|
|
|
-public class DingShiActivity extends BaseActivity implements CompoundButton.OnCheckedChangeListener {
|
|
|
-
|
|
|
- @BindView(R.id.iv_base_activity_back)
|
|
|
- ImageView ivBaseActivityBack;
|
|
|
- @BindView(R.id.tv_title_center)
|
|
|
- TextView tvTitleCenter;
|
|
|
- @BindView(R.id.sw_dingshi_sw1)
|
|
|
- Switch swDingshiSw1;
|
|
|
- @BindView(R.id.tv_dingshi_start1)
|
|
|
- TextView tvDingshiStart1;
|
|
|
- @BindView(R.id.tv_dingshi_close1)
|
|
|
- TextView tvDingshiClose1;
|
|
|
- @BindView(R.id.bt_kongzhi_1)
|
|
|
- Button btKongzhi1;
|
|
|
- @BindView(R.id.sw_dingshi_sw2)
|
|
|
- Switch swDingshiSw2;
|
|
|
- @BindView(R.id.tv_dingshi_start2)
|
|
|
- TextView tvDingshiStart2;
|
|
|
- @BindView(R.id.tv_dingshi_close2)
|
|
|
- TextView tvDingshiClose2;
|
|
|
- @BindView(R.id.bt_kongzhi_2)
|
|
|
- Button btKongzhi2;
|
|
|
- @BindView(R.id.sw_dingshi_sw3)
|
|
|
- Switch swDingshiSw3;
|
|
|
- @BindView(R.id.tv_dingshi_start3)
|
|
|
- TextView tvDingshiStart3;
|
|
|
- @BindView(R.id.tv_dingshi_close3)
|
|
|
- TextView tvDingshiClose3;
|
|
|
- @BindView(R.id.bt_kongzhi_3)
|
|
|
- Button btKongzhi3;
|
|
|
- @BindView(R.id.sw_dingshi_sw4)
|
|
|
- Switch swDingshiSw4;
|
|
|
- @BindView(R.id.tv_dingshi_start4)
|
|
|
- TextView tvDingshiStart4;
|
|
|
- @BindView(R.id.tv_dingshi_close4)
|
|
|
- TextView tvDingshiClose4;
|
|
|
- @BindView(R.id.bt_kongzhi_4)
|
|
|
- Button btKongzhi4;
|
|
|
- @BindView(R.id.sw_dingshi_sw5)
|
|
|
- Switch swDingshiSw5;
|
|
|
- @BindView(R.id.tv_dingshi_start5)
|
|
|
- TextView tvDingshiStart5;
|
|
|
- @BindView(R.id.tv_dingshi_close5)
|
|
|
- TextView tvDingshiClose5;
|
|
|
- @BindView(R.id.bt_kongzhi_5)
|
|
|
- Button btKongzhi5;
|
|
|
- @BindView(R.id.sw_dingshi_sw6)
|
|
|
- Switch swDingshiSw6;
|
|
|
- @BindView(R.id.tv_dingshi_start6)
|
|
|
- TextView tvDingshiStart6;
|
|
|
- @BindView(R.id.tv_dingshi_close6)
|
|
|
- TextView tvDingshiClose6;
|
|
|
- @BindView(R.id.bt_kongzhi_6)
|
|
|
- Button btKongzhi6;
|
|
|
- @BindView(R.id.sw_dingshi_sw7)
|
|
|
- Switch swDingshiSw7;
|
|
|
- @BindView(R.id.tv_dingshi_start7)
|
|
|
- TextView tvDingshiStart7;
|
|
|
- @BindView(R.id.tv_dingshi_close7)
|
|
|
- TextView tvDingshiClose7;
|
|
|
- @BindView(R.id.bt_kongzhi_7)
|
|
|
- Button btKongzhi7;
|
|
|
- @BindView(R.id.sw_dingshi_sw8)
|
|
|
- Switch swDingshiSw8;
|
|
|
- @BindView(R.id.tv_dingshi_start8)
|
|
|
- TextView tvDingshiStart8;
|
|
|
- @BindView(R.id.tv_dingshi_close8)
|
|
|
- TextView tvDingshiClose8;
|
|
|
- @BindView(R.id.bt_kongzhi_8)
|
|
|
- Button btKongzhi8;
|
|
|
- @BindView(R.id.tv_led1_name)
|
|
|
- TextView tvLed1Name;
|
|
|
- @BindView(R.id.ll_led1)
|
|
|
- LinearLayout llLed1;
|
|
|
- @BindView(R.id.tv_led2_name)
|
|
|
- TextView tvLed2Name;
|
|
|
- @BindView(R.id.ll_led2)
|
|
|
- LinearLayout llLed2;
|
|
|
- @BindView(R.id.tv_led3_name)
|
|
|
- TextView tvLed3Name;
|
|
|
- @BindView(R.id.ll_led3)
|
|
|
- LinearLayout llLed3;
|
|
|
- @BindView(R.id.tv_led4_name)
|
|
|
- TextView tvLed4Name;
|
|
|
- @BindView(R.id.ll_led4)
|
|
|
- LinearLayout llLed4;
|
|
|
- @BindView(R.id.tv_pump1_name)
|
|
|
- TextView tvPump1Name;
|
|
|
- @BindView(R.id.ll_pump1)
|
|
|
- LinearLayout llPump1;
|
|
|
- @BindView(R.id.tv_pump2_name)
|
|
|
- TextView tvPump2Name;
|
|
|
- @BindView(R.id.ll_pump2)
|
|
|
- LinearLayout llPump2;
|
|
|
- @BindView(R.id.tv_pump3_name)
|
|
|
- TextView tvPump3Name;
|
|
|
- @BindView(R.id.ll_pump3)
|
|
|
- LinearLayout llPump3;
|
|
|
- @BindView(R.id.tv_pump4_name)
|
|
|
- TextView tvPump4Name;
|
|
|
- @BindView(R.id.ll_pump4)
|
|
|
- LinearLayout llPump4;
|
|
|
-
|
|
|
- private String device_mac;
|
|
|
- private String L1 = "";
|
|
|
- private String L2 = "";
|
|
|
- private String L3 = "";
|
|
|
- private String L4 = "";
|
|
|
- private String S1 = "";
|
|
|
- private String S2 = "";
|
|
|
- private String S3 = "";
|
|
|
- private String S4 = "";
|
|
|
- private int currentOnline1;
|
|
|
- private int currentOnline2;
|
|
|
- private int currentOnline3;
|
|
|
- private int currentOnline4;
|
|
|
- private int currentOnline5;
|
|
|
- private int currentOnline6;
|
|
|
- private int currentOnline7;
|
|
|
- private int currentOnline8;
|
|
|
-
|
|
|
- @Override
|
|
|
- protected int setView() {
|
|
|
- return R.layout.activity_dengkongzhi;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void initView() {
|
|
|
- ivBaseActivityBack.setVisibility(View.VISIBLE);
|
|
|
- tvTitleCenter.setText("定时控制");
|
|
|
-
|
|
|
- Intent intent = getIntent();
|
|
|
- device_mac = intent.getStringExtra("Device_Mac");
|
|
|
- if (!TextUtils.isEmpty(device_mac)) {
|
|
|
- getNodeData(device_mac);
|
|
|
- }
|
|
|
-
|
|
|
- swDingshiSw1.setOnCheckedChangeListener(this);
|
|
|
- swDingshiSw2.setOnCheckedChangeListener(this);
|
|
|
- swDingshiSw3.setOnCheckedChangeListener(this);
|
|
|
- swDingshiSw4.setOnCheckedChangeListener(this);
|
|
|
- swDingshiSw5.setOnCheckedChangeListener(this);
|
|
|
- swDingshiSw6.setOnCheckedChangeListener(this);
|
|
|
- swDingshiSw7.setOnCheckedChangeListener(this);
|
|
|
- swDingshiSw8.setOnCheckedChangeListener(this);
|
|
|
- }
|
|
|
-
|
|
|
- @OnClick({R.id.iv_base_activity_back, R.id.tv_dingshi_start1, R.id.tv_dingshi_close1, R.id.bt_kongzhi_1, R.id.tv_dingshi_start2, R.id.tv_dingshi_close2, R.id.bt_kongzhi_2, R.id.tv_dingshi_start3, R.id.tv_dingshi_close3, R.id.bt_kongzhi_3, R.id.tv_dingshi_start4, R.id.tv_dingshi_close4, R.id.bt_kongzhi_4, R.id.tv_dingshi_start5, R.id.tv_dingshi_close5, R.id.bt_kongzhi_5, R.id.tv_dingshi_start6, R.id.tv_dingshi_close6, R.id.bt_kongzhi_6, R.id.tv_dingshi_start7, R.id.tv_dingshi_close7, R.id.bt_kongzhi_7, R.id.tv_dingshi_start8, R.id.tv_dingshi_close8, R.id.bt_kongzhi_8})
|
|
|
- public void onViewClicked(View view) {
|
|
|
- switch (view.getId()) {
|
|
|
- case R.id.iv_base_activity_back:
|
|
|
- finish();
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_start1:
|
|
|
- setTimeByView(tvDingshiStart1);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_close1:
|
|
|
- setTimeByView(tvDingshiClose1);
|
|
|
- break;
|
|
|
- case R.id.bt_kongzhi_1:
|
|
|
- String s1 = tvDingshiStart1.getText().toString().trim();
|
|
|
- String e1 = tvDingshiClose1.getText().toString().trim();
|
|
|
- if (TextUtils.isEmpty(s1)) {
|
|
|
- WQUtils.showToast(this, "请选择打开时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- if (TextUtils.isEmpty(e1)) {
|
|
|
- WQUtils.showToast(this, "请选择关闭时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- takeData(L1, currentOnline1, s1, e1);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_start2:
|
|
|
- setTimeByView(tvDingshiStart2);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_close2:
|
|
|
- setTimeByView(tvDingshiClose2);
|
|
|
- break;
|
|
|
- case R.id.bt_kongzhi_2:
|
|
|
- String s2 = tvDingshiStart2.getText().toString().trim();
|
|
|
- String e2 = tvDingshiClose2.getText().toString().trim();
|
|
|
- if (TextUtils.isEmpty(s2)) {
|
|
|
- WQUtils.showToast(this, "请选择打开时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- if (TextUtils.isEmpty(e2)) {
|
|
|
- WQUtils.showToast(this, "请选择关闭时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- takeData(L2, currentOnline2, s2, e2);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_start3:
|
|
|
- setTimeByView(tvDingshiStart3);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_close3:
|
|
|
- setTimeByView(tvDingshiClose3);
|
|
|
- break;
|
|
|
- case R.id.bt_kongzhi_3:
|
|
|
- String s3 = tvDingshiStart3.getText().toString().trim();
|
|
|
- String e3 = tvDingshiClose3.getText().toString().trim();
|
|
|
- if (TextUtils.isEmpty(s3)) {
|
|
|
- WQUtils.showToast(this, "请选择打开时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- if (TextUtils.isEmpty(e3)) {
|
|
|
- WQUtils.showToast(this, "请选择关闭时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- takeData(L3, currentOnline3, s3, e3);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_start4:
|
|
|
- setTimeByView(tvDingshiStart4);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_close4:
|
|
|
- setTimeByView(tvDingshiClose4);
|
|
|
- break;
|
|
|
- case R.id.bt_kongzhi_4:
|
|
|
- String s4 = tvDingshiStart4.getText().toString().trim();
|
|
|
- String e4 = tvDingshiClose4.getText().toString().trim();
|
|
|
- if (TextUtils.isEmpty(s4)) {
|
|
|
- WQUtils.showToast(this, "请选择打开时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- if (TextUtils.isEmpty(e4)) {
|
|
|
- WQUtils.showToast(this, "请选择关闭时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- takeData(L4, currentOnline4, s4, e4);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_start5:
|
|
|
- setTimeByView(tvDingshiStart5);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_close5:
|
|
|
- setTimeByView(tvDingshiClose5);
|
|
|
- break;
|
|
|
- case R.id.bt_kongzhi_5:
|
|
|
- String s5 = tvDingshiStart5.getText().toString().trim();
|
|
|
- String e5 = tvDingshiClose5.getText().toString().trim();
|
|
|
- if (TextUtils.isEmpty(s5)) {
|
|
|
- WQUtils.showToast(this, "请选择打开时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- if (TextUtils.isEmpty(e5)) {
|
|
|
- WQUtils.showToast(this, "请选择关闭时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- takeData(S1, currentOnline5, s5, e5);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_start6:
|
|
|
- setTimeByView(tvDingshiStart6);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_close6:
|
|
|
- setTimeByView(tvDingshiClose6);
|
|
|
- break;
|
|
|
- case R.id.bt_kongzhi_6:
|
|
|
- String s6 = tvDingshiStart6.getText().toString().trim();
|
|
|
- String e6 = tvDingshiClose6.getText().toString().trim();
|
|
|
- if (TextUtils.isEmpty(s6)) {
|
|
|
- WQUtils.showToast(this, "请选择打开时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- if (TextUtils.isEmpty(e6)) {
|
|
|
- WQUtils.showToast(this, "请选择关闭时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- takeData(S2, currentOnline6, s6, e6);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_start7:
|
|
|
- setTimeByView(tvDingshiStart7);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_close7:
|
|
|
- setTimeByView(tvDingshiClose7);
|
|
|
- break;
|
|
|
- case R.id.bt_kongzhi_7:
|
|
|
- String s7 = tvDingshiStart7.getText().toString().trim();
|
|
|
- String e7 = tvDingshiClose7.getText().toString().trim();
|
|
|
- if (TextUtils.isEmpty(s7)) {
|
|
|
- WQUtils.showToast(this, "请选择打开时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- if (TextUtils.isEmpty(e7)) {
|
|
|
- WQUtils.showToast(this, "请选择关闭时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- takeData(S3, currentOnline7, s7, e7);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_start8:
|
|
|
- setTimeByView(tvDingshiStart8);
|
|
|
- break;
|
|
|
- case R.id.tv_dingshi_close8:
|
|
|
- setTimeByView(tvDingshiClose8);
|
|
|
- break;
|
|
|
- case R.id.bt_kongzhi_8:
|
|
|
- String s8 = tvDingshiStart8.getText().toString().trim();
|
|
|
- String e8 = tvDingshiClose8.getText().toString().trim();
|
|
|
- if (TextUtils.isEmpty(s8)) {
|
|
|
- WQUtils.showToast(this, "请选择打开时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- if (TextUtils.isEmpty(e8)) {
|
|
|
- WQUtils.showToast(this, "请选择关闭时间");
|
|
|
- break;
|
|
|
- }
|
|
|
- takeData(S4, currentOnline8, s8, e8);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void offMode(String nodeMac, int currentOnline, int control_Mode) {
|
|
|
- JSONObject jsonObj = new JSONObject();
|
|
|
- try {
|
|
|
- jsonObj.put("DeviceMac", device_mac);
|
|
|
- jsonObj.put("NodeMac", nodeMac);
|
|
|
- jsonObj.put("CurrentOnline", currentOnline);
|
|
|
- jsonObj.put("Control_Mode", control_Mode);//1手动 0自动
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- // 发送网络请求
|
|
|
- WQNetUtil.postHttp(this, jsonObj, SPUtil.getString(this, "URL") + "Device/UpdateDeviceControlMode", handler_offMode);
|
|
|
- }
|
|
|
-
|
|
|
- private Handler handler_offMode = new Handler() {
|
|
|
- public void handleMessage(Message msg) {
|
|
|
- String json = (String) msg.obj;
|
|
|
-
|
|
|
- Gson gson = new Gson();
|
|
|
- BindDeviceBean getTokenBean = gson.fromJson(json, BindDeviceBean.class);
|
|
|
-
|
|
|
- if (getTokenBean != null && getTokenBean.getReturnCode() == 200) {
|
|
|
-
|
|
|
- initButton(btt, startt, cloosee, sww.isChecked(), sww);
|
|
|
-
|
|
|
-// btt.setVisibility(View.GONE);
|
|
|
-// startt.setEnabled(false);
|
|
|
-// cloosee.setEnabled(false);
|
|
|
-// startt.setBackgroundResource(R.drawable.rect_radius_device_dark1);d
|
|
|
-// cloosee.setBackgroundResource(R.drawable.rect_radius_device_dark1);
|
|
|
-
|
|
|
- WQUtils.tip(DingShiActivity.this, getTokenBean.getMessage() + "");
|
|
|
- } else {
|
|
|
-
|
|
|
- sww.setChecked(true);
|
|
|
- WQUtils.tip(DingShiActivity.this, getTokenBean.getMessage() + "");
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- private void takeData(String nodeMac, int currentOnline, String startTime, String endTime) {
|
|
|
- JSONObject jsonObj = new JSONObject();
|
|
|
- try {
|
|
|
- jsonObj.put("DeviceMac", device_mac);
|
|
|
- jsonObj.put("NodeMac", nodeMac);
|
|
|
- jsonObj.put("CurrentOnline", currentOnline);
|
|
|
- jsonObj.put("Swith_Time1", startTime);
|
|
|
- jsonObj.put("Swith_Time2", endTime);
|
|
|
- jsonObj.put("Swith_Time3", "");
|
|
|
- jsonObj.put("Swith_Time4", "");
|
|
|
- jsonObj.put("Swith_Action1", 255);
|
|
|
- jsonObj.put("Swith_Action2", 0);
|
|
|
- jsonObj.put("Swith_Action3", 255);
|
|
|
- jsonObj.put("Swith_Action4", 0);
|
|
|
- jsonObj.put("Swith_Mode", 1);//1 每天 2每周
|
|
|
- jsonObj.put("Control_Mode", 0);//1手动 0自动
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- // 发送网络请求
|
|
|
- WQNetUtil.postHttp(this, jsonObj, SPUtil.getString(this, "URL") + "Device/EditDeviceGateWayOn", handler);
|
|
|
- }
|
|
|
-
|
|
|
- private Handler handler = new Handler() {
|
|
|
- public void handleMessage(Message msg) {
|
|
|
- String json = (String) msg.obj;
|
|
|
-
|
|
|
- Gson gson = new Gson();
|
|
|
- BindDeviceBean getTokenBean = gson.fromJson(json, BindDeviceBean.class);
|
|
|
-
|
|
|
- if (getTokenBean != null && getTokenBean.getReturnCode() == 200) {
|
|
|
-
|
|
|
- WQUtils.tip(DingShiActivity.this, getTokenBean.getMessage() + "");
|
|
|
- } else {
|
|
|
- WQUtils.tip(DingShiActivity.this, getTokenBean.getMessage() + "");
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- //获取节点列表
|
|
|
- private void getNodeData(String device_mac) {
|
|
|
- String user_id = SPUtil.getString(this, "User_ID");
|
|
|
-
|
|
|
- JSONObject jsonObj = new JSONObject();
|
|
|
- try {
|
|
|
- jsonObj.put("PageIndex", 1);
|
|
|
- jsonObj.put("PageSize", 99);
|
|
|
- jsonObj.put("UserID", user_id);
|
|
|
- jsonObj.put("GateWayMac", device_mac);
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- // 发送网络请求
|
|
|
- WQNetUtil.postHttp(this, jsonObj, SPUtil.getString(this, "URL") + "Device/GetAllNodeByMac", handler_node);
|
|
|
- }
|
|
|
-
|
|
|
- private Handler handler_node = new Handler() {
|
|
|
- public void handleMessage(Message msg) {
|
|
|
- String json = (String) msg.obj;
|
|
|
-
|
|
|
- Gson gson = new Gson();
|
|
|
- DeviceNodeBean deviceNodeBean = gson.fromJson(json, DeviceNodeBean.class);
|
|
|
- if (deviceNodeBean != null && deviceNodeBean.getReturnCode() == 200) {
|
|
|
- if (deviceNodeBean.getResult() != null && deviceNodeBean.getResult().getModels() != null && deviceNodeBean.getResult().getModels().size() > 0) {
|
|
|
- List<DeviceNodeBean.ResultBean.ModelsBean> node_list = deviceNodeBean.getResult().getModels();
|
|
|
- if (node_list != null && node_list.size() > 0) {
|
|
|
-
|
|
|
- List<DeviceNodeBean.ResultBean.ModelsBean> led = new ArrayList<>();
|
|
|
- List<DeviceNodeBean.ResultBean.ModelsBean> pump = new ArrayList<>();
|
|
|
- for (int i = 0; i < node_list.size(); i++) {
|
|
|
- if (node_list.get(i).getDeviceMac().contains("LED") || node_list.get(i).getDeviceMac().contains("led")) {
|
|
|
- led.add(node_list.get(i));
|
|
|
- } else {
|
|
|
- pump.add(node_list.get(i));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (led.size() >= 1) {
|
|
|
- llLed1.setVisibility(View.VISIBLE);
|
|
|
- tvLed1Name.setText(led.get(0).getDeviceName());
|
|
|
- L1 = led.get(0).getDeviceMac();
|
|
|
- currentOnline1 = led.get(0).getCurrentOnline();
|
|
|
-
|
|
|
- if (led.get(0).getControl_Mode() != 16) {
|
|
|
- if (!TextUtils.isEmpty(led.get(0).getSwith_Time1())) {
|
|
|
- tvDingshiStart1.setText(led.get(0).getSwith_Time1().substring(13, 18));
|
|
|
- }
|
|
|
- if (!TextUtils.isEmpty(led.get(0).getSwith_Time2())) {
|
|
|
- tvDingshiClose1.setText(led.get(0).getSwith_Time2().substring(13, 18));
|
|
|
- }
|
|
|
- }
|
|
|
- if (led.get(0).getControl_Mode() == 0 || led.get(0).getControl_Mode() == 16) {
|
|
|
- initButton(btKongzhi1, tvDingshiStart1, tvDingshiClose1, true, swDingshiSw1);
|
|
|
- } else {
|
|
|
- initButton(btKongzhi1, tvDingshiStart1, tvDingshiClose1, false, swDingshiSw1);
|
|
|
- }
|
|
|
- }
|
|
|
- if (led.size() >= 2) {
|
|
|
- llLed2.setVisibility(View.VISIBLE);
|
|
|
- tvLed2Name.setText(led.get(1).getDeviceName());
|
|
|
- L2 = led.get(1).getDeviceMac();
|
|
|
- currentOnline2 = led.get(1).getCurrentOnline();
|
|
|
-
|
|
|
- if (led.get(1).getControl_Mode() != 16) {
|
|
|
- if (!TextUtils.isEmpty(led.get(1).getSwith_Time1())) {
|
|
|
- tvDingshiStart2.setText(led.get(1).getSwith_Time1().substring(13, 18));
|
|
|
- }
|
|
|
- if (!TextUtils.isEmpty(led.get(1).getSwith_Time2())) {
|
|
|
- tvDingshiClose2.setText(led.get(1).getSwith_Time2().substring(13, 18));
|
|
|
- }
|
|
|
- }
|
|
|
- if (led.get(1).getControl_Mode() == 0 || led.get(1).getControl_Mode() == 16) {
|
|
|
- initButton(btKongzhi2, tvDingshiStart2, tvDingshiClose2, true, swDingshiSw2);
|
|
|
- } else {
|
|
|
- initButton(btKongzhi2, tvDingshiStart2, tvDingshiClose2, false, swDingshiSw2);
|
|
|
- }
|
|
|
- }
|
|
|
- if (led.size() >= 3) {
|
|
|
- llLed3.setVisibility(View.VISIBLE);
|
|
|
- tvLed3Name.setText(led.get(2).getDeviceName());
|
|
|
- L3 = led.get(2).getDeviceMac();
|
|
|
- currentOnline3 = led.get(2).getCurrentOnline();
|
|
|
-
|
|
|
- if (led.get(2).getControl_Mode() != 16) {
|
|
|
- if (!TextUtils.isEmpty(led.get(2).getSwith_Time1())) {
|
|
|
- tvDingshiStart3.setText(led.get(2).getSwith_Time1().substring(13, 18));
|
|
|
- }
|
|
|
- if (!TextUtils.isEmpty(led.get(2).getSwith_Time2())) {
|
|
|
- tvDingshiClose3.setText(led.get(2).getSwith_Time2().substring(13, 18));
|
|
|
- }
|
|
|
- }
|
|
|
- if (led.get(2).getControl_Mode() == 0 || led.get(2).getControl_Mode() == 16) {
|
|
|
- initButton(btKongzhi3, tvDingshiStart3, tvDingshiClose3, true, swDingshiSw3);
|
|
|
- } else {
|
|
|
- initButton(btKongzhi3, tvDingshiStart3, tvDingshiClose3, false, swDingshiSw3);
|
|
|
- }
|
|
|
- }
|
|
|
- if (led.size() >= 4) {
|
|
|
- llLed4.setVisibility(View.VISIBLE);
|
|
|
- tvLed4Name.setText(led.get(3).getDeviceName());
|
|
|
- L4 = led.get(3).getDeviceMac();
|
|
|
- currentOnline4 = led.get(3).getCurrentOnline();
|
|
|
-
|
|
|
- if (led.get(3).getControl_Mode() != 16) {
|
|
|
- if (!TextUtils.isEmpty(led.get(3).getSwith_Time1())) {
|
|
|
- tvDingshiStart4.setText(led.get(3).getSwith_Time1().substring(13, 18));
|
|
|
- }
|
|
|
- if (!TextUtils.isEmpty(led.get(3).getSwith_Time2())) {
|
|
|
- tvDingshiClose4.setText(led.get(3).getSwith_Time2().substring(13, 18));
|
|
|
- }
|
|
|
- }
|
|
|
- if (led.get(3).getControl_Mode() == 0 || led.get(3).getControl_Mode() == 16) {
|
|
|
- initButton(btKongzhi4, tvDingshiStart4, tvDingshiClose4, true, swDingshiSw4);
|
|
|
- } else {
|
|
|
- initButton(btKongzhi4, tvDingshiStart4, tvDingshiClose4, false, swDingshiSw4);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (pump.size() >= 1) {
|
|
|
- llPump1.setVisibility(View.VISIBLE);
|
|
|
- tvPump1Name.setText(pump.get(0).getDeviceName());
|
|
|
- S1 = pump.get(0).getDeviceMac();
|
|
|
- currentOnline5 = pump.get(0).getCurrentOnline();
|
|
|
-
|
|
|
- if (pump.get(0).getControl_Mode() != 16) {
|
|
|
- if (!TextUtils.isEmpty(pump.get(0).getSwith_Time1())) {
|
|
|
- tvDingshiStart5.setText(pump.get(0).getSwith_Time1().substring(13, 18));
|
|
|
- }
|
|
|
- if (!TextUtils.isEmpty(pump.get(0).getSwith_Time2())) {
|
|
|
- tvDingshiClose5.setText(pump.get(0).getSwith_Time2().substring(13, 18));
|
|
|
- }
|
|
|
- }
|
|
|
- if (pump.get(0).getControl_Mode() == 0 || pump.get(0).getControl_Mode() == 16) {
|
|
|
- initButton(btKongzhi5, tvDingshiStart5, tvDingshiClose5, true, swDingshiSw5);
|
|
|
- } else {
|
|
|
- initButton(btKongzhi5, tvDingshiStart5, tvDingshiClose5, false, swDingshiSw5);
|
|
|
- }
|
|
|
- }
|
|
|
- if (pump.size() >= 2) {
|
|
|
- llPump2.setVisibility(View.VISIBLE);
|
|
|
- tvPump2Name.setText(pump.get(1).getDeviceName());
|
|
|
- S2 = pump.get(1).getDeviceMac();
|
|
|
- currentOnline6 = pump.get(1).getCurrentOnline();
|
|
|
-
|
|
|
- if (pump.get(1).getControl_Mode() != 16) {
|
|
|
- if (!TextUtils.isEmpty(pump.get(1).getSwith_Time1())) {
|
|
|
- tvDingshiStart6.setText(pump.get(1).getSwith_Time1().substring(13, 18));
|
|
|
- }
|
|
|
- if (!TextUtils.isEmpty(pump.get(1).getSwith_Time2())) {
|
|
|
- tvDingshiClose6.setText(pump.get(1).getSwith_Time2().substring(13, 18));
|
|
|
- }
|
|
|
- }
|
|
|
- if (pump.get(1).getControl_Mode() == 0 || pump.get(1).getControl_Mode() == 16) {
|
|
|
- initButton(btKongzhi6, tvDingshiStart6, tvDingshiClose6, true, swDingshiSw6);
|
|
|
- } else {
|
|
|
- initButton(btKongzhi6, tvDingshiStart6, tvDingshiClose6, false, swDingshiSw6);
|
|
|
- }
|
|
|
- }
|
|
|
- if (pump.size() >= 3) {
|
|
|
- llPump3.setVisibility(View.VISIBLE);
|
|
|
- tvPump3Name.setText(pump.get(2).getDeviceName());
|
|
|
- S3 = pump.get(2).getDeviceMac();
|
|
|
- currentOnline7 = pump.get(2).getCurrentOnline();
|
|
|
-
|
|
|
- if (pump.get(2).getControl_Mode() != 16) {
|
|
|
- if (!TextUtils.isEmpty(pump.get(2).getSwith_Time1())) {
|
|
|
- tvDingshiStart7.setText(pump.get(2).getSwith_Time1().substring(13, 18));
|
|
|
- }
|
|
|
- if (!TextUtils.isEmpty(pump.get(2).getSwith_Time2())) {
|
|
|
- tvDingshiClose7.setText(pump.get(2).getSwith_Time2().substring(13, 18));
|
|
|
- }
|
|
|
- }
|
|
|
- if (pump.get(2).getControl_Mode() == 0 || pump.get(2).getControl_Mode() == 16) {
|
|
|
- initButton(btKongzhi7, tvDingshiStart7, tvDingshiClose7, true, swDingshiSw7);
|
|
|
- } else {
|
|
|
- initButton(btKongzhi7, tvDingshiStart7, tvDingshiClose7, false, swDingshiSw7);
|
|
|
- }
|
|
|
- }
|
|
|
- if (pump.size() >= 4) {
|
|
|
- llPump4.setVisibility(View.VISIBLE);
|
|
|
- tvPump4Name.setText(pump.get(3).getDeviceName());
|
|
|
- S4 = pump.get(3).getDeviceMac();
|
|
|
- currentOnline8 = pump.get(3).getCurrentOnline();
|
|
|
-
|
|
|
- if (pump.get(3).getControl_Mode() != 16) {
|
|
|
- if (!TextUtils.isEmpty(pump.get(3).getSwith_Time1())) {
|
|
|
- tvDingshiStart8.setText(pump.get(3).getSwith_Time1().substring(13, 18));
|
|
|
- }
|
|
|
- if (!TextUtils.isEmpty(pump.get(3).getSwith_Time2())) {
|
|
|
- tvDingshiClose8.setText(pump.get(3).getSwith_Time2().substring(13, 18));
|
|
|
- }
|
|
|
- }
|
|
|
- if (pump.get(3).getControl_Mode() == 0 || pump.get(3).getControl_Mode() == 16) {
|
|
|
- initButton(btKongzhi8, tvDingshiStart8, tvDingshiClose8, true, swDingshiSw8);
|
|
|
- } else {
|
|
|
- initButton(btKongzhi8, tvDingshiStart8, tvDingshiClose8, false, swDingshiSw8);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- WQUtils.tip(DingShiActivity.this, deviceNodeBean.getMessage() + "");
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onCheckedChanged(CompoundButton buttonView, boolean b) {
|
|
|
- //防止初始化的时候出发监听
|
|
|
- if (!buttonView.isPressed()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- switch (buttonView.getId()) {
|
|
|
- case R.id.sw_dingshi_sw1:
|
|
|
- setButton(btKongzhi1, tvDingshiStart1, tvDingshiClose1, b, L1, currentOnline1);
|
|
|
- sww = swDingshiSw1;
|
|
|
- break;
|
|
|
- case R.id.sw_dingshi_sw2:
|
|
|
- setButton(btKongzhi2, tvDingshiStart2, tvDingshiClose2, b, L2, currentOnline2);
|
|
|
- sww = swDingshiSw2;
|
|
|
- break;
|
|
|
- case R.id.sw_dingshi_sw3:
|
|
|
- setButton(btKongzhi3, tvDingshiStart3, tvDingshiClose3, b, L3, currentOnline3);
|
|
|
- sww = swDingshiSw3;
|
|
|
- break;
|
|
|
- case R.id.sw_dingshi_sw4:
|
|
|
- setButton(btKongzhi4, tvDingshiStart4, tvDingshiClose4, b, L4, currentOnline4);
|
|
|
- sww = swDingshiSw4;
|
|
|
- break;
|
|
|
- case R.id.sw_dingshi_sw5:
|
|
|
- setButton(btKongzhi5, tvDingshiStart5, tvDingshiClose5, b, S1, currentOnline5);
|
|
|
- sww = swDingshiSw5;
|
|
|
- break;
|
|
|
- case R.id.sw_dingshi_sw6:
|
|
|
- setButton(btKongzhi6, tvDingshiStart6, tvDingshiClose6, b, S2, currentOnline6);
|
|
|
- sww = swDingshiSw6;
|
|
|
- break;
|
|
|
- case R.id.sw_dingshi_sw7:
|
|
|
- setButton(btKongzhi7, tvDingshiStart7, tvDingshiClose7, b, S3, currentOnline7);
|
|
|
- sww = swDingshiSw7;
|
|
|
- break;
|
|
|
- case R.id.sw_dingshi_sw8:
|
|
|
- setButton(btKongzhi8, tvDingshiStart8, tvDingshiClose8, b, S4, currentOnline8);
|
|
|
- sww = swDingshiSw8;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private Switch sww;
|
|
|
- private Button btt;
|
|
|
- private TextView startt;
|
|
|
- private TextView cloosee;
|
|
|
-
|
|
|
- private void setButton(Button bt, TextView start, TextView cloose, boolean b, String node_mac, int currentOnline) {
|
|
|
- if (b) {
|
|
|
- btt = bt;
|
|
|
- startt = start;
|
|
|
- cloosee = cloose;
|
|
|
-
|
|
|
- offMode(node_mac, currentOnline, 0);
|
|
|
- } else {
|
|
|
- btt = bt;
|
|
|
- startt = start;
|
|
|
- cloosee = cloose;
|
|
|
- offMode(node_mac, currentOnline, 1);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void initButton(Button bt, TextView start, TextView cloose, boolean b, Switch sw) {
|
|
|
- Log.e("wwqq", "initButton " + b);
|
|
|
- if (b) {
|
|
|
- bt.setVisibility(View.VISIBLE);
|
|
|
- start.setEnabled(true);
|
|
|
- cloose.setEnabled(true);
|
|
|
- start.setBackgroundResource(R.drawable.rect_radius_device_dark);
|
|
|
- cloose.setBackgroundResource(R.drawable.rect_radius_device_dark);
|
|
|
-
|
|
|
- sw.setChecked(true);
|
|
|
- } else {
|
|
|
- bt.setVisibility(View.GONE);
|
|
|
- start.setEnabled(false);
|
|
|
- cloose.setEnabled(false);
|
|
|
- start.setBackgroundResource(R.drawable.rect_radius_device_dark1);
|
|
|
- cloose.setBackgroundResource(R.drawable.rect_radius_device_dark1);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void setTimeByView(TextView tv) {
|
|
|
-
|
|
|
- final AlertDialog ad = new AlertDialog.Builder(this).create();
|
|
|
- ad.show();
|
|
|
- LayoutInflater inflater = LayoutInflater.from(this);
|
|
|
- View view = inflater.inflate(R.layout.time_dialog, null);
|
|
|
- final TimePicker timePick = (TimePicker) view.findViewById(R.id.timePic1);
|
|
|
- Button bt_yes = (Button) view.findViewById(R.id.bt_yes);
|
|
|
- Button bt_no = (Button) view.findViewById(R.id.bt_no);
|
|
|
- timePick.setIs24HourView(true);
|
|
|
- bt_yes.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View arg0) {
|
|
|
- int h = timePick.getCurrentHour();
|
|
|
- int m = timePick.getCurrentMinute();
|
|
|
-
|
|
|
- String hour = "";
|
|
|
- String min = "";
|
|
|
- if (h < 10) {
|
|
|
- hour = "0" + h;
|
|
|
- } else {
|
|
|
- hour = h + "";
|
|
|
- }
|
|
|
- if (m < 10) {
|
|
|
- min = "0" + m;
|
|
|
- } else {
|
|
|
- min = m + "";
|
|
|
- }
|
|
|
-
|
|
|
- Log.e("时间", "|" + hour + ":" + min);
|
|
|
-
|
|
|
- tv.setText(hour + ":" + min);
|
|
|
- ad.dismiss();
|
|
|
- }
|
|
|
- });
|
|
|
- bt_no.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View arg0) {
|
|
|
- ad.dismiss();
|
|
|
- }
|
|
|
- });
|
|
|
- ad.getWindow().setContentView(view);
|
|
|
- }
|
|
|
-
|
|
|
-}
|