|
|
@@ -21,6 +21,7 @@ import android.widget.Button;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.RelativeLayout;
|
|
|
+import android.widget.TabHost;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
@@ -39,6 +40,7 @@ import com.silence.commonframe.Dialog.CDialog;
|
|
|
import com.silence.commonframe.R;
|
|
|
import com.silence.commonframe.activity.AddSiteActivity;
|
|
|
import com.silence.commonframe.activity.AdddeviceActivity;
|
|
|
+import com.silence.commonframe.activity.AirGuardActivity;
|
|
|
import com.silence.commonframe.activity.CommonScanActivity;
|
|
|
import com.silence.commonframe.activity.DeviceContextManagementActivity;
|
|
|
import com.silence.commonframe.activity.DevicedetailActivity;
|
|
|
@@ -81,6 +83,7 @@ import java.util.List;
|
|
|
|
|
|
import okhttp3.Call;
|
|
|
import okhttp3.Response;
|
|
|
+import retrofit2.http.Url;
|
|
|
|
|
|
/**
|
|
|
* Created by Silence on 2016/4/5.
|
|
|
@@ -106,6 +109,7 @@ public class DeviceFragment extends Fragment implements OnFunRegisterListener, O
|
|
|
private ArrayList<String> listLocation = new ArrayList<>(); //场所地址
|
|
|
private ArrayList<String> listReginName = new ArrayList<>(); //场所区域
|
|
|
private List<String> listDeviceLocation;
|
|
|
+ private List<String> airDevId=new ArrayList<>();
|
|
|
private View view;
|
|
|
private List<HashMap<String, String>> listmap = new ArrayList<>();
|
|
|
private List<HashMap<String, String>> listmap_camera = new ArrayList<>();
|
|
|
@@ -314,6 +318,9 @@ public class DeviceFragment extends Fragment implements OnFunRegisterListener, O
|
|
|
* 获取摄像头UUId
|
|
|
*/
|
|
|
getCameraId();
|
|
|
+ }else if (getResources().getString(R.string.device_air_guard).equals(listDeviceTypeTitle.get(position_device_type))){
|
|
|
+ refreshLanDeviceList();
|
|
|
+ startActivity(new Intent().putExtra("airDevId",airDevId.get(position)).setClass(getActivity(),AirGuardActivity.class));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -731,7 +738,6 @@ public class DeviceFragment extends Fragment implements OnFunRegisterListener, O
|
|
|
.execute(new StringCallback() {
|
|
|
@Override
|
|
|
public void onSuccess(String s, Call call, Response response) {
|
|
|
-
|
|
|
Camera camera = new Gson().fromJson(s,Camera.class);
|
|
|
String message = camera.getMsg();
|
|
|
int code = camera.getCode();
|
|
|
@@ -792,8 +798,6 @@ public class DeviceFragment extends Fragment implements OnFunRegisterListener, O
|
|
|
@Override
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
siteid = Data.getListid().get(position1);
|
|
|
- // adapter.removeItem(position);
|
|
|
- // Toast.makeText(getContext(), "Delitem!"+siteid, Toast.LENGTH_SHORT).show();
|
|
|
position4 = position;
|
|
|
positionmy = position;
|
|
|
delCameraDevices();
|
|
|
@@ -896,20 +900,119 @@ public class DeviceFragment extends Fragment implements OnFunRegisterListener, O
|
|
|
.cacheKey("cacheGetKey") // 设置当前请求的缓存key,建议每个不同功能的请求设置一个
|
|
|
.cacheMode(CacheMode.DEFAULT) // 缓存模式,详细请看缓存介绍
|
|
|
.headers("token", Data.getToken())
|
|
|
- .execute(new AbsCallback<AirGuardBean>() {
|
|
|
-
|
|
|
+ .execute(new StringCallback() {
|
|
|
@Override
|
|
|
- public AirGuardBean convertSuccess(Response response) throws Exception {
|
|
|
- return null;
|
|
|
- }
|
|
|
+ public void onSuccess(String s, Call call, Response response) {
|
|
|
+ AirGuardBean airGuardData= new Gson().fromJson(s,AirGuardBean.class);
|
|
|
+ if (airGuardData.getCode()==0){
|
|
|
+ if (airGuardData.getData() != null) {
|
|
|
+ for (int i = 0; i < airGuardData.getData().size(); i++) {
|
|
|
+ HashMap<String, String> hashMap = new HashMap<>();
|
|
|
+ String id = airGuardData.getData().get(i).getDeviceId();
|
|
|
+ String deviceLocation = "";
|
|
|
+ String deviceName = airGuardData.getData().get(i).getDeviceName();
|
|
|
+ String status = airGuardData.getData().get(i).getBuzzerState();
|
|
|
+ hashMap.put("id", id);
|
|
|
+ hashMap.put("deviceLocation", deviceLocation);
|
|
|
+ hashMap.put("status", status);
|
|
|
+ hashMap.put("airGuard",airGuardData.getData().get(i).getAirDevId());
|
|
|
+ listCameraId.add(id);
|
|
|
+ listCameraName.add(deviceName);
|
|
|
+ airDevId.add(airGuardData.getData().get(i).getDeviceId());
|
|
|
+ listmap_camera.add(hashMap);
|
|
|
+ }
|
|
|
+ mActivity.runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ // number = listBeans.size();
|
|
|
+ imageView.setVisibility(View.GONE);
|
|
|
+ textView.setVisibility(View.GONE);
|
|
|
+ tv.setVisibility(View.VISIBLE);
|
|
|
+// tv1.setVisibility(View.VISIBLE);
|
|
|
|
|
|
- @Override
|
|
|
- public void onSuccess(AirGuardBean airGuardBean, Call call, Response response) {
|
|
|
+ bt.setVisibility(View.GONE);
|
|
|
+ recyclerView.setVisibility(View.VISIBLE);
|
|
|
|
|
|
- }
|
|
|
- /** 请求失败,响应错误,数据解析错误等,都会回调该方法, UI线程 */
|
|
|
- public void onError(Call call, Response response, Exception e) {
|
|
|
+ adapter2 = new MyAdapterSlide(getContext(), listmap_camera);
|
|
|
+ recyclerView.removeAllViews();
|
|
|
+ adapter2.notifyDataSetChanged();
|
|
|
+ LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
|
|
+ linearLayoutManager.setItemPrefetchEnabled(true);
|
|
|
+// linearLayoutManager.setRecycleChildrenOnDetach(true);
|
|
|
+ recyclerView.setLayoutManager(linearLayoutManager);
|
|
|
+ recyclerView.setAdapter(adapter2);
|
|
|
+ adapter2.setOnItemClickListener(new MyAdapterSlide.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(View view, int position) {
|
|
|
+ //判断跳转到哪个页面
|
|
|
+ isWhichClick_go(position);
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onDeleteClick(final int position) {
|
|
|
+ CDialog.Builder builder = new CDialog.Builder(getContext());
|
|
|
+ builder.setMessage("是否确定要删除该设备");
|
|
|
+ builder.setCancelable(false);
|
|
|
+ builder.setTitle("提示");
|
|
|
+ builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ siteid = Data.getListid().get(position1);
|
|
|
+ position4 = position;
|
|
|
+ positionmy = position;
|
|
|
+ delCameraDevices();
|
|
|
+ onResume();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ builder.show();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNavieteClick(int position) {
|
|
|
+ isWhichClick_go(position);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ tv.setText("设备的数量:" + rows + "");
|
|
|
+ adapter2.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ mActivity.runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ imageView.setVisibility(View.VISIBLE);
|
|
|
+ textView.setVisibility(View.VISIBLE);
|
|
|
+ textView.setText("还未添加空气卫士");
|
|
|
+ bt.setVisibility(View.VISIBLE);
|
|
|
+ recyclerView.setVisibility(View.GONE);
|
|
|
+ tv1.setVisibility(View.GONE);
|
|
|
+ tv.setVisibility(View.VISIBLE);
|
|
|
+ // String p = place.substring(0,9);
|
|
|
+ tv.setText("设备的数量:0");
|
|
|
+ // tv1.setText(place1);
|
|
|
+ bt.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ // Toast.makeText(getContext(),"helll",Toast.LENGTH_SHORT).show();
|
|
|
+ Intent intent = new Intent(getContext(), CommonScanActivity.class);
|
|
|
+ intent.putExtra("deviceType",getResources().getString(R.string.device_air_guard));
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ LoginIn.tokenOut(airGuardData.getCode(),airGuardData.getMsg(),getContext());
|
|
|
+ Toast.makeText(getContext(),""+airGuardData.getMsg(),Toast.LENGTH_SHORT).show();
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -1014,10 +1117,12 @@ public class DeviceFragment extends Fragment implements OnFunRegisterListener, O
|
|
|
public void onLogout() {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public void onAddSubDeviceFailed(FunDevice funDevice, MsgContent msgContent) {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public void onAddSubDeviceSuccess(FunDevice funDevice, MsgContent msgContent) {
|
|
|
|