|
|
@@ -1,701 +0,0 @@
|
|
|
-package com.silence.commonframe.activity;
|
|
|
-
|
|
|
-import android.content.Intent;
|
|
|
-import android.graphics.Color;
|
|
|
-import android.os.Build;
|
|
|
-import android.os.Bundle;
|
|
|
-import android.support.annotation.Nullable;
|
|
|
-import android.support.v7.app.AppCompatActivity;
|
|
|
-import android.support.v7.widget.LinearLayoutManager;
|
|
|
-import android.support.v7.widget.RecyclerView;
|
|
|
-import android.view.View;
|
|
|
-import android.view.ViewGroup;
|
|
|
-import android.view.Window;
|
|
|
-import android.view.WindowManager;
|
|
|
-import android.widget.LinearLayout;
|
|
|
-import android.widget.TextView;
|
|
|
-import android.widget.Toast;
|
|
|
-
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.lzy.okgo.OkGo;
|
|
|
-import com.lzy.okgo.cache.CacheMode;
|
|
|
-import com.lzy.okgo.callback.StringCallback;
|
|
|
-import com.silence.commonframe.ApiService;
|
|
|
-import com.silence.commonframe.R;
|
|
|
-import com.silence.commonframe.adapter.DeviceContextAdapter;
|
|
|
-import com.silence.commonframe.adapter.DeviceContextAdapterCamera;
|
|
|
-import com.silence.commonframe.base.basemvp.BaseActivity;
|
|
|
-import com.silence.commonframe.bean.IsDeviceChange;
|
|
|
-import com.silence.commonframe.model.DelContextDevice;
|
|
|
-import com.silence.commonframe.model.DelContextDevice_success;
|
|
|
-import com.silence.commonframe.utils.AtyContainer;
|
|
|
-import com.silence.commonframe.utils.Data;
|
|
|
-import com.silence.commonframe.utils.LoginIn;
|
|
|
-import com.silence.commonframe.utils.ManagePopupMenu;
|
|
|
-
|
|
|
-import org.json.JSONArray;
|
|
|
-import org.json.JSONException;
|
|
|
-import org.json.JSONObject;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-
|
|
|
-import butterknife.BindView;
|
|
|
-import butterknife.ButterKnife;
|
|
|
-import okhttp3.Call;
|
|
|
-import okhttp3.Response;
|
|
|
-
|
|
|
-/**
|
|
|
- * 关联设备管理
|
|
|
- * @author 郑嘉明
|
|
|
- * device_context_checkbox、device_context_name、device_context_state、device_context_location、context_device_camera_amount、context_device_smokedetector_amount
|
|
|
- */
|
|
|
-public class DeviceContextManagementActivity extends BaseActivity {
|
|
|
-
|
|
|
- /**
|
|
|
- * 导航栏信息
|
|
|
- * back_pic、navi_head_back_text(透明)、navi_head_text、navi_head_text_right(右侧文字)
|
|
|
- */
|
|
|
- @BindView(R.id.navi_head_text)
|
|
|
- TextView navi_head_text; //标题
|
|
|
- @BindView(R.id.navi_head_text_right)
|
|
|
- TextView navi_head_text_right; //导航栏右侧文字
|
|
|
-
|
|
|
- @BindView(R.id.recycleview_camera)
|
|
|
- RecyclerView recycleview_camera; //摄像头列表
|
|
|
- @BindView(R.id.recyclerview_smoke)
|
|
|
- RecyclerView recyclerview_smoke; //烟感列表
|
|
|
- @BindView(R.id.context_device_camera_amount)
|
|
|
- TextView context_device_camera_amount; //摄像头数量
|
|
|
- @BindView(R.id.context_device_smokedetector_amount)
|
|
|
- TextView context_device_smokedetector_amount; //烟感数量
|
|
|
- @BindView(R.id.hint_camera)
|
|
|
- TextView hint_camera; //提示无摄像头
|
|
|
- @BindView(R.id.hint_smoke)
|
|
|
- TextView hint_smoke; //提示无烟感
|
|
|
- @BindView(R.id.context_device_del_submit)
|
|
|
- LinearLayout context_device_del_submit;
|
|
|
-
|
|
|
- private List<HashMap<String,String>> listmap_camera = new ArrayList<>();
|
|
|
- private List<HashMap<String,String>> listmap_smoke = new ArrayList<>();
|
|
|
- DeviceContextAdapterCamera cameraAdapter; //设置关联摄像头构造器
|
|
|
- DeviceContextAdapter smokeAdapter; //设置关联烟感构造器
|
|
|
-
|
|
|
- List<String> listCameraDel = new ArrayList<>();
|
|
|
- List<String> listSmokeDel = new ArrayList<>();
|
|
|
-
|
|
|
- private String device_id = "0000000000000051";
|
|
|
-
|
|
|
- private ManagePopupMenu manageMenu; //管理菜单
|
|
|
-
|
|
|
- private int change = 0;
|
|
|
-
|
|
|
- private int rowsCameradata;
|
|
|
- private int rowCamere;
|
|
|
- private int rowSmoke;
|
|
|
- private int rowsFiredata;
|
|
|
-
|
|
|
- private int devId;
|
|
|
- private Boolean flag = false;
|
|
|
-
|
|
|
-// @Override
|
|
|
-// protected void onCreate(Bundle savedInstanceState) {
|
|
|
-// super.onCreate(savedInstanceState);
|
|
|
-// setContentView(R.layout.activity_device_context_management);
|
|
|
-// ButterKnife.bind(this);
|
|
|
-// AtyContainer.getInstance().addActivity(this);
|
|
|
-// navi_head_text.setText(R.string.devicedetail_associateddevicemanagement); //设置标题
|
|
|
-// navi_head_text_right.setText(R.string.devicecontext_management); //设置导航栏右侧文字
|
|
|
-// context_device_del_submit.setVisibility(View.GONE); //提交按钮默认消失
|
|
|
-// //设置全屏
|
|
|
-// initWindows();
|
|
|
-//
|
|
|
-// IsDeviceChange.setIsContextCamera(true);
|
|
|
-//
|
|
|
-// //获取传递过来的值
|
|
|
-// getIntentMsg();
|
|
|
-//// device_id = Data.getDevIdsCamera();
|
|
|
-//
|
|
|
-// //获取关联设备
|
|
|
-// getContextDevice();
|
|
|
-// //设置管理菜单
|
|
|
-// getManageMenu();
|
|
|
-// //提交点击事件
|
|
|
-// del_sumbitOnClickListener();
|
|
|
-//
|
|
|
-//// context_device_del_submit.setOnClickListener(new View.OnClickListener() {
|
|
|
-//// @Override
|
|
|
-//// public void onClick(View v) {
|
|
|
-//// listCameraDel.addAll(cameraAdapter.getCheckBoxIDList());
|
|
|
-//// listSmokeDel.addAll(smokeAdapter.getCheckBoxIDList());
|
|
|
-//
|
|
|
-//// if (listCameraDel.size() != 0 || listSmokeDel.size() != 0){
|
|
|
-//// //解除设备关联关系
|
|
|
-//// delContextDevice();
|
|
|
-//// change = 1; //页面改变
|
|
|
-//// cameraAdapter.removeAdapterItem(); //adapter中删除要删除的item并刷新
|
|
|
-//// smokeAdapter.removeAdapterItem();
|
|
|
-//// listCameraDel.clear(); //删完清空
|
|
|
-//// listSmokeDel.clear();
|
|
|
-//// cameraAdapter.setIsShow(false); //设置checkbox不显示
|
|
|
-//// cameraAdapter.notifyDataSetChanged(); //刷新adapter
|
|
|
-//// smokeAdapter.setIsShow(false); //设置checkbox不显示
|
|
|
-//// smokeAdapter.notifyDataSetChanged(); //刷新adapter
|
|
|
-//// context_device_del_submit.setVisibility(View.GONE); //提交按钮消失
|
|
|
-//// }else {
|
|
|
-//// Toast.makeText(DeviceContextManagementActivity.this,"请先选择要解除关联的设备",Toast.LENGTH_SHORT).show();
|
|
|
-//// }
|
|
|
-////
|
|
|
-//// }
|
|
|
-//// });
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
- @Override
|
|
|
- public int getLayoutId() {
|
|
|
- return R.layout.activity_device_context_management;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void initPresenter() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void initView() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 若新增关联设备成功,刷新
|
|
|
- * @param requestCode 3
|
|
|
- * @param resultCode 3
|
|
|
- * @param data 无
|
|
|
- */
|
|
|
-// @Override
|
|
|
-// protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
|
-// super.onActivityResult(requestCode, resultCode, data);
|
|
|
-// if (requestCode == 3 && resultCode == 3){
|
|
|
-// if (listmap_smoke.size() != 0){
|
|
|
-// listmap_smoke.clear(); //清空刷新重新获取
|
|
|
-// }
|
|
|
-// if (listmap_camera.size() != 0){
|
|
|
-// listmap_camera.clear();
|
|
|
-// }
|
|
|
-// change = 1;
|
|
|
-// //获取关联设备
|
|
|
-// getContextDevice();
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取传递过来的值
|
|
|
- * device_id
|
|
|
- */
|
|
|
- private void getIntentMsg() {
|
|
|
- Intent intent = getIntent();
|
|
|
- device_id = intent.getStringExtra("deviceId");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 提交解除关联设备
|
|
|
- */
|
|
|
- private void del_sumbitOnClickListener() {
|
|
|
- context_device_del_submit.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- // listCameraDel.addAll(cameraAdapter.getCheckBoxIDList());
|
|
|
- // listSmokeDel.addAll(smokeAdapter.getCheckBoxIDList());
|
|
|
-
|
|
|
-// if (Data.getCheckBoxIDListData().size() == 0&&Data.getCheckBoxIDListDataCamera().size() == 0){
|
|
|
-//
|
|
|
-// Toast.makeText(DeviceContextManagementActivity.this,"请选择要删除的数据!",Toast.LENGTH_SHORT).show();
|
|
|
-// // return;
|
|
|
-// }
|
|
|
-
|
|
|
- if (Data.getCheckBoxIDListData()!= null&&Data.getCheckBoxIDListData().size()!= 0){
|
|
|
- //Data.getCheckBoxIDListDataCamera()
|
|
|
- listSmokeDel.addAll(Data.getCheckBoxIDListData());
|
|
|
- }
|
|
|
- if (Data.getCheckBoxIDListDataCamera()!= null&&Data.getCheckBoxIDListDataCamera().size()!= 0){
|
|
|
- // listSmokeDel.addAll(Data.getCheckBoxIDListData());
|
|
|
- listCameraDel.addAll(Data.getCheckBoxIDListDataCamera());
|
|
|
- }
|
|
|
-
|
|
|
- if (listSmokeDel.size() == 0&&listCameraDel.size() == 0){
|
|
|
-//
|
|
|
- Toast.makeText(DeviceContextManagementActivity.this,"请选择要删除的数据!",Toast.LENGTH_SHORT).show();
|
|
|
-// return;
|
|
|
- }
|
|
|
-
|
|
|
- if (listCameraDel.size() != 0 /*|| listSmokeDel.size() != 0*/){
|
|
|
- //解除设备关联关系
|
|
|
- // delContextDevice();
|
|
|
- delContextDeviceCamera();
|
|
|
- change = 1; //页面改变
|
|
|
- // cameraAdapter.removeAdapterItem(); //adapter中删除要删除的item并刷新
|
|
|
- // smokeAdapter.removeAdapterItem();
|
|
|
- listCameraDel.clear(); //删完清空
|
|
|
- // listSmokeDel.clear();
|
|
|
- cameraAdapter.setIsShow(false); //设置checkbox不显示
|
|
|
- // cameraAdapter.notifyDataSetChanged(); //刷新adapter
|
|
|
-// smokeAdapter.setIsShow(false); //设置checkbox不显示
|
|
|
-// smokeAdapter.notifyDataSetChanged(); //刷新adapter
|
|
|
- context_device_del_submit.setVisibility(View.GONE); //提交按钮消失
|
|
|
- final String rowCamereString = String.valueOf(rowCamere);
|
|
|
- runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- context_device_camera_amount.setText(rowCamereString+"个");
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
- if (listSmokeDel.size() != 0){
|
|
|
- delContextDevice();
|
|
|
- change = 1; //页面改变
|
|
|
- // smokeAdapter.removeAdapterItem();
|
|
|
- listSmokeDel.clear();
|
|
|
- smokeAdapter.setIsShow(false); //设置checkbox不显示
|
|
|
- smokeAdapter.notifyDataSetChanged();
|
|
|
- context_device_del_submit.setVisibility(View.GONE);
|
|
|
-
|
|
|
- final String rowSmokeString = String.valueOf(rowSmoke);
|
|
|
- runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- context_device_smokedetector_amount.setText(rowSmokeString+"个");
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // onResume();
|
|
|
- // context_device_del_submit.setVisibility(View.GONE);
|
|
|
-
|
|
|
-// if (listCameraDel.size() == 0 || listSmokeDel.size() == 0){
|
|
|
-// Toast.makeText(DeviceContextManagementActivity.this,"请先选择要解除关联的设备",Toast.LENGTH_SHORT).show();
|
|
|
-// return;
|
|
|
-// }
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除关联设备关系
|
|
|
- */
|
|
|
- private void delContextDevice() {
|
|
|
-// for (int i = 0; i < listCameraDel.size(); i++){
|
|
|
-// String url1 = ApiService.httpUrl1 + "/app/deleteDeviceConnect?id="+listCameraDel.get(i);
|
|
|
-// OkGo.get(url1)
|
|
|
-// .tag(this)
|
|
|
-// .cacheKey("cacheGetKey")
|
|
|
-// .cacheMode(CacheMode.DEFAULT)
|
|
|
-// .headers("token",Data.getToken())
|
|
|
-// .execute(new StringCallback() {
|
|
|
-// @Override
|
|
|
-// public void onSuccess(String s, Call call, Response response) {
|
|
|
-// DelContextDevice delContextDevice = new Gson().fromJson(s,DelContextDevice.class);
|
|
|
-// String message = delContextDevice.getMsg();
|
|
|
-// int code = delContextDevice.getCode();
|
|
|
-// if ("success".equals(message)){
|
|
|
-// DelContextDevice_success.setSuccess1(true);
|
|
|
-// }else {
|
|
|
-// LoginIn.tokenOut(code,message,DeviceContextManagementActivity.this);
|
|
|
-// Toast.makeText(DeviceContextManagementActivity.this,""+message,Toast.LENGTH_SHORT).show();
|
|
|
-// }
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
-
|
|
|
- if (listSmokeDel.size() == 1){
|
|
|
- Boolean flag = false;
|
|
|
- String url1 = ApiService.httpUrl1 +Data.getConfigUrl()+ "/deleteDeviceConnect?id="+listSmokeDel.get(0);
|
|
|
- OkGo.get(url1)
|
|
|
- .tag(this)
|
|
|
- .cacheKey("cacheGetKey")
|
|
|
- .cacheMode(CacheMode.DEFAULT)
|
|
|
- .headers("token",Data.getToken())
|
|
|
- .execute(new StringCallback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String s, Call call, Response response) {
|
|
|
- DelContextDevice delContextDevice = new Gson().fromJson(s,DelContextDevice.class);
|
|
|
- String message = delContextDevice.getMsg();
|
|
|
- int code = delContextDevice.getCode();
|
|
|
- if ("success".equals(message)){
|
|
|
- DelContextDevice_success.setSuccess1(true);
|
|
|
- runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- // listmap_camera.remove(listCameraDel.get(0));
|
|
|
- // cameraAdapter.removeAdapterItem();
|
|
|
- smokeAdapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }else {
|
|
|
- LoginIn.tokenOut(code,message,DeviceContextManagementActivity.this);
|
|
|
- Toast.makeText(DeviceContextManagementActivity.this,""+message,Toast.LENGTH_SHORT).show();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- flag = true;
|
|
|
- }
|
|
|
-
|
|
|
- for (int i = 0; i < listSmokeDel.size(); i++) {
|
|
|
- String url2 = ApiService.httpUrl1 +Data.getConfigUrl()+ "/deleteDeviceConnect?id=" + listSmokeDel.get(i);
|
|
|
- OkGo.get(url2)
|
|
|
- .tag(this)
|
|
|
- .cacheKey("cacheGetKey")
|
|
|
- .cacheMode(CacheMode.DEFAULT)
|
|
|
- .headers("token", Data.getToken())
|
|
|
- .execute(new StringCallback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String s, Call call, Response response) {
|
|
|
- DelContextDevice delContextDevice = new Gson().fromJson(s, DelContextDevice.class);
|
|
|
- String message = delContextDevice.getMsg();
|
|
|
- int code = delContextDevice.getCode();
|
|
|
- if ("success".equals(message)) {
|
|
|
- DelContextDevice_success.setSuccess2(true);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- } else {
|
|
|
- LoginIn.tokenOut(code, message, DeviceContextManagementActivity.this);
|
|
|
- Toast.makeText(DeviceContextManagementActivity.this,""+message,Toast.LENGTH_SHORT).show();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- smokeAdapter.removeAdapterItem();
|
|
|
- }
|
|
|
- rowSmoke = rowsFiredata - listSmokeDel.size();
|
|
|
- // Toast.makeText(DeviceContextManagementActivity.this, "烟感设备删除成功", Toast.LENGTH_SHORT).show();
|
|
|
- }
|
|
|
-
|
|
|
- private void delContextDeviceCamera() {
|
|
|
- // listmap_camera
|
|
|
- if (listCameraDel.size() == 1){
|
|
|
- Boolean flag = false;
|
|
|
- String url1 = ApiService.httpUrl1 +Data.getConfigUrl()+ "/deleteDeviceConnect?id="+listCameraDel.get(0);
|
|
|
- OkGo.get(url1)
|
|
|
- .tag(this)
|
|
|
- .cacheKey("cacheGetKey")
|
|
|
- .cacheMode(CacheMode.DEFAULT)
|
|
|
- .headers("token",Data.getToken())
|
|
|
- .execute(new StringCallback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String s, Call call, Response response) {
|
|
|
- DelContextDevice delContextDevice = new Gson().fromJson(s,DelContextDevice.class);
|
|
|
- String message = delContextDevice.getMsg();
|
|
|
- int code = delContextDevice.getCode();
|
|
|
- if ("success".equals(message)){
|
|
|
- DelContextDevice_success.setSuccess1(true);
|
|
|
- runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- // listmap_camera.remove(listCameraDel.get(0));
|
|
|
- // cameraAdapter.removeAdapterItem();
|
|
|
- cameraAdapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }else {
|
|
|
- LoginIn.tokenOut(code,message,DeviceContextManagementActivity.this);
|
|
|
- Toast.makeText(DeviceContextManagementActivity.this,""+message,Toast.LENGTH_SHORT).show();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- if (flag){
|
|
|
- cameraAdapter.removeAdapterItem();
|
|
|
- }
|
|
|
- flag = true;
|
|
|
- }
|
|
|
- // if (listCameraDel.size() > 1){
|
|
|
- for (int i = 0; i < listCameraDel.size(); i++){
|
|
|
- // listmap_camera.remove(listCameraDel.get(i));
|
|
|
- String url1 = ApiService.httpUrl1 +Data.getConfigUrl()+ "/deleteDeviceConnect?id="+listCameraDel.get(i);
|
|
|
- final int finalI = i;
|
|
|
- OkGo.get(url1)
|
|
|
- .tag(this)
|
|
|
- .cacheKey("cacheGetKey")
|
|
|
- .cacheMode(CacheMode.DEFAULT)
|
|
|
- .headers("token",Data.getToken())
|
|
|
- .execute(new StringCallback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String s, Call call, Response response) {
|
|
|
- DelContextDevice delContextDevice = new Gson().fromJson(s,DelContextDevice.class);
|
|
|
- String message = delContextDevice.getMsg();
|
|
|
- int code = delContextDevice.getCode();
|
|
|
- if ("success".equals(message)){
|
|
|
- DelContextDevice_success.setSuccess1(true);
|
|
|
- runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- // cameraAdapter.removeAdapterItem();
|
|
|
- // listmap_camera.remove(listCameraDel.get(finalI));
|
|
|
- // cameraAdapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
- });
|
|
|
- }else {
|
|
|
- LoginIn.tokenOut(code,message,DeviceContextManagementActivity.this);
|
|
|
- Toast.makeText(DeviceContextManagementActivity.this,""+message,Toast.LENGTH_SHORT).show();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-// if (listCameraDel.size()!=0){
|
|
|
-// cameraAdapter.removeAdapterItem();
|
|
|
-// }
|
|
|
- cameraAdapter.removeAdapterItem();
|
|
|
- }
|
|
|
- // }
|
|
|
- rowCamere = rowsCameradata - listCameraDel.size();
|
|
|
-// for (int i = 0; i < listSmokeDel.size(); i++) {
|
|
|
-// String url2 = ApiService.httpUrl1 + "/app/deleteDeviceConnect?id=" + listSmokeDel.get(i);
|
|
|
-// OkGo.get(url2)
|
|
|
-// .tag(this)
|
|
|
-// .cacheKey("cacheGetKey")
|
|
|
-// .cacheMode(CacheMode.DEFAULT)
|
|
|
-// .headers("token", Data.getToken())
|
|
|
-// .execute(new StringCallback() {
|
|
|
-// @Override
|
|
|
-// public void onSuccess(String s, Call call, Response response) {
|
|
|
-// DelContextDevice delContextDevice = new Gson().fromJson(s, DelContextDevice.class);
|
|
|
-// String message = delContextDevice.getMsg();
|
|
|
-// int code = delContextDevice.getCode();
|
|
|
-// if ("success".equals(message)) {
|
|
|
-// DelContextDevice_success.setSuccess2(true);
|
|
|
-// } else {
|
|
|
-// LoginIn.tokenOut(code, message, DeviceContextManagementActivity.this);
|
|
|
-// Toast.makeText(DeviceContextManagementActivity.this,""+message,Toast.LENGTH_SHORT).show();
|
|
|
-// }
|
|
|
-// }
|
|
|
-// });
|
|
|
- // }
|
|
|
- Toast.makeText(DeviceContextManagementActivity.this, "摄像头设备删除成功!", Toast.LENGTH_SHORT).show();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 设置管理菜单
|
|
|
- */
|
|
|
- private void getManageMenu() {
|
|
|
- //设置新的菜单
|
|
|
- manageMenu = new ManagePopupMenu(DeviceContextManagementActivity.this, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
- manageMenu.addItem(getResources().getDrawable(R.mipmap.homeadd1),"添加"); //加添加选项
|
|
|
- manageMenu.addItem(getResources().getDrawable(R.mipmap.del),"删除"); //加删除选项
|
|
|
- //设置菜单选项点击事件
|
|
|
- manageMenu.setItemOnClickListener(new ManagePopupMenu.OnItemOnClickListener() {
|
|
|
- @Override
|
|
|
- public void onItemClick(String desc) {
|
|
|
- if ("添加".equals(desc)){ //添加事件
|
|
|
-// Toast.makeText(DeviceContextManagementActivity.this,"添加",Toast.LENGTH_SHORT).show();
|
|
|
- Intent intent_contextdevice_management = new Intent(DeviceContextManagementActivity.this,NewAddContextDeviceActivity.class);
|
|
|
- intent_contextdevice_management.putExtra("deviceId",device_id);
|
|
|
- startActivityForResult(intent_contextdevice_management,3);
|
|
|
- }else if ("删除".equals(desc)){ //删除事件
|
|
|
-// Toast.makeText(DeviceContextManagementActivity.this,"删除",Toast.LENGTH_SHORT).show();
|
|
|
- if (listmap_camera.size() == 0 && listmap_smoke.size() == 0){
|
|
|
- Toast.makeText(DeviceContextManagementActivity.this,"还没有任何关联的设备哦",Toast.LENGTH_SHORT).show();
|
|
|
- context_device_del_submit.setVisibility(View.GONE);
|
|
|
- }else {
|
|
|
- if (listmap_camera.size() != 0){
|
|
|
- cameraAdapter.setIsShow(!cameraAdapter.getShow()); //checkbox点击显示或隐藏
|
|
|
- if (cameraAdapter.getShow()){
|
|
|
- context_device_del_submit.setVisibility(View.VISIBLE); //显示提交按钮
|
|
|
- }
|
|
|
- }
|
|
|
- if (listmap_smoke.size() != 0){
|
|
|
- smokeAdapter.setIsShow(!smokeAdapter.getShow()); //checkbox点击显示或隐藏
|
|
|
- if (smokeAdapter.getShow()){
|
|
|
- context_device_del_submit.setVisibility(View.VISIBLE); //显示提交按钮
|
|
|
- }
|
|
|
- }
|
|
|
-// if (!smokeAdapter.getShow() && !cameraAdapter.getShow()){
|
|
|
-// context_device_del_submit.setVisibility(View.GONE);
|
|
|
-// }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- //点击显示管理菜单或消失
|
|
|
- navi_head_text_right.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- manageMenu.show(v, ManagePopupMenu.STYLE_ALIGN_THIS_BOTTOM_WINDOW_RIGHT);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取关联设备
|
|
|
- * Camera、smoke
|
|
|
- */
|
|
|
- private void getContextDevice() {
|
|
|
- String url = ApiService.httpUrl1 + Data.getConfigUrl()+ "/getConnectDevice?deviceId="+device_id; //获取关联设备列表
|
|
|
- OkGo.get(url)
|
|
|
- .tag(this) // 请求的 tag, 主要用于取消对应的请求
|
|
|
- .cacheKey("cacheGetKey") // 设置当前请求的缓存key,建议每个不同功能的请求设置一个
|
|
|
- .cacheMode(CacheMode.DEFAULT) // 缓存模式,详细请看缓存介绍
|
|
|
- .headers("token", Data.getToken())
|
|
|
- .execute(new StringCallback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String s, Call call, Response response) {
|
|
|
- try {
|
|
|
- JSONObject jsonObject = new JSONObject(s);
|
|
|
- String message = jsonObject.get("msg").toString();
|
|
|
- System.out.println(jsonObject);
|
|
|
- if (message.equalsIgnoreCase("success")){
|
|
|
- JSONObject jsonData = jsonObject.getJSONObject("data");
|
|
|
- JSONObject jsonCameardata = jsonData.getJSONObject("cameradata");
|
|
|
- JSONObject jsonFiredata = jsonData.getJSONObject("firedata");
|
|
|
- JSONArray listCameradata = jsonCameardata.getJSONArray("dataList");
|
|
|
- JSONArray listFiredata = jsonFiredata.getJSONArray("dataList");
|
|
|
- rowsCameradata = jsonCameardata.getInt("rows"); //总的关联的摄像头设备的数量
|
|
|
-
|
|
|
-
|
|
|
- rowsFiredata = jsonFiredata.getInt("rows"); //总的关联的烟感设备的数量
|
|
|
-
|
|
|
- for (int i = 0; i < listCameradata.length(); i++){ //循环取出摄像头里面的信息,List
|
|
|
- HashMap<String,String> hashMapCameradata = new HashMap<>();
|
|
|
-
|
|
|
- JSONObject jsonObjectCameradata = listCameradata.getJSONObject(i);
|
|
|
- String cameraId = jsonObjectCameradata.get("id").toString();
|
|
|
- String cameraDeviceName = jsonObjectCameradata.get("deviceName").toString();
|
|
|
- String cameraLocation = jsonObjectCameradata.get("location").toString();
|
|
|
- String cameraDeviceId= jsonObjectCameradata.get("deviceId").toString();
|
|
|
- String cameraAddTime = jsonObjectCameradata.get("addTime").toString();
|
|
|
- String cameraStatus = jsonObjectCameradata.get("status").toString();
|
|
|
- String cameraDeviceType = jsonObjectCameradata.get("deviceType").toString();
|
|
|
-
|
|
|
- hashMapCameradata.put("id",cameraId);
|
|
|
- hashMapCameradata.put("location",cameraLocation);
|
|
|
- hashMapCameradata.put("deviceName",cameraDeviceName);
|
|
|
- hashMapCameradata.put("deviceId",cameraDeviceId);
|
|
|
- hashMapCameradata.put("addTime",cameraAddTime);
|
|
|
- hashMapCameradata.put("status",cameraStatus);
|
|
|
- hashMapCameradata.put("deviceType",cameraDeviceType);
|
|
|
-
|
|
|
- listmap_camera.add(hashMapCameradata);
|
|
|
- }
|
|
|
-
|
|
|
- for (int i = 0; i < listFiredata.length(); i++){ //循环取出烟感设备里面的信息、List
|
|
|
- HashMap<String,String> hashMapFiredata = new HashMap<>();
|
|
|
-
|
|
|
- JSONObject jsonObjectFiredata = listFiredata.getJSONObject(i);
|
|
|
- String firedataId = jsonObjectFiredata.get("id").toString();
|
|
|
- String firedataDeviceName = jsonObjectFiredata.get("deviceName").toString();
|
|
|
- String firedataLocation = jsonObjectFiredata.get("location").toString();
|
|
|
- String firedataDeviceId= jsonObjectFiredata.get("deviceId").toString();
|
|
|
- String firedataAddTime = jsonObjectFiredata.get("addTime").toString();
|
|
|
- String firedataStatus = jsonObjectFiredata.get("status").toString();
|
|
|
- String firedataDeviceType = jsonObjectFiredata.get("deviceType").toString();
|
|
|
-
|
|
|
- hashMapFiredata.put("id",firedataId);
|
|
|
- hashMapFiredata.put("deviceName",firedataDeviceName);
|
|
|
- hashMapFiredata.put("location",firedataLocation);
|
|
|
- hashMapFiredata.put("deviceId",firedataDeviceId);
|
|
|
- hashMapFiredata.put("addTime",firedataAddTime);
|
|
|
- hashMapFiredata.put("status",firedataStatus);
|
|
|
- hashMapFiredata.put("deviceType",firedataDeviceType);
|
|
|
-
|
|
|
- listmap_smoke.add(hashMapFiredata);
|
|
|
- }
|
|
|
-
|
|
|
- runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- String rowsFire = rowsFiredata + "个";
|
|
|
- String rowsCamera = rowsCameradata + "个";
|
|
|
- context_device_smokedetector_amount.setText(rowsFire);
|
|
|
- context_device_camera_amount.setText(rowsCamera);
|
|
|
-
|
|
|
- if (listmap_camera.size() == 0){
|
|
|
- hint_camera.setVisibility(View.VISIBLE); //如果没有关联摄像头,出现文字提示
|
|
|
- }else {
|
|
|
- hint_camera.setVisibility(View.GONE);
|
|
|
- //setAdapter
|
|
|
- cameraAdapter = new DeviceContextAdapterCamera(DeviceContextManagementActivity.this,listmap_camera);
|
|
|
- recycleview_camera.setLayoutManager(new LinearLayoutManager(DeviceContextManagementActivity.this));
|
|
|
- recycleview_camera.setAdapter(cameraAdapter);
|
|
|
- //设置checkbox不显示
|
|
|
- cameraAdapter.setIsShow(false);
|
|
|
- //刷新adapter
|
|
|
- // cameraAdapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
-
|
|
|
- if (listmap_smoke.size() == 0){
|
|
|
- hint_smoke.setVisibility(View.VISIBLE); //如果没有关联烟感,出现文字提示
|
|
|
- }else {
|
|
|
- hint_smoke.setVisibility(View.GONE);
|
|
|
- //setAdapter
|
|
|
- smokeAdapter = new DeviceContextAdapter(DeviceContextManagementActivity.this,listmap_smoke);
|
|
|
- recyclerview_smoke.setLayoutManager(new LinearLayoutManager(DeviceContextManagementActivity.this));
|
|
|
- recyclerview_smoke.setAdapter(smokeAdapter);
|
|
|
- //设置checkbox不显示
|
|
|
- smokeAdapter.setIsShow(false);
|
|
|
- //刷新adapter
|
|
|
- // smokeAdapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }else {
|
|
|
- //登录失败
|
|
|
- LoginIn.tokenOut(message,DeviceContextManagementActivity.this);
|
|
|
- }
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 页面全屏
|
|
|
- */
|
|
|
- private void initWindows() {
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
|
- Window window = getWindow();
|
|
|
- window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
|
|
|
- | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
|
|
|
- window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
|
- | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
|
|
- window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
|
|
- window.setStatusBarColor(Color.TRANSPARENT);
|
|
|
- window.setNavigationBarColor(Color.BLACK);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onResume() {
|
|
|
- super.onResume();
|
|
|
- if (flag){
|
|
|
- listmap_camera.clear();
|
|
|
- listmap_smoke.clear();
|
|
|
- getContextDevice();
|
|
|
- }
|
|
|
- flag = true;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public void click_back(View view) {
|
|
|
- if (change == 1){
|
|
|
- setResult(4);
|
|
|
- }
|
|
|
- IsDeviceChange.setIsContextCamera(false);
|
|
|
- finish();
|
|
|
- }
|
|
|
-}
|