wxr
2022-12-01 2588ab0681d9ef96f98114a1de018b420e3ee1da
AndroidOpenDemo/app/src/main/java/com/lechange/demo/ui/DeviceDetailMainFragment.java
@@ -1,5 +1,6 @@
package com.lechange.demo.ui;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
@@ -25,6 +26,8 @@
import com.common.openapi.entity.DeviceLocalCacheData;
import com.common.openapi.entity.DeviceUnBindData;
import com.lechange.demo.R;
import com.lechange.demo.dialog.DeviceUpdateDialog;
import com.lechange.demo.dialog.RecoverSDCardDialog;
import com.lechange.demo.tools.DialogUtils;
import com.lechange.demo.tools.MediaPlayHelper;
import com.mm.android.deviceaddmodule.LCDeviceEngine;
@@ -41,7 +44,7 @@
    private RelativeLayout rlDeviceDetail;
    private RelativeLayout rlDetailVersion;
    private RelativeLayout rlDeployment;
//    private RelativeLayout rlDetele;
    private RelativeLayout rlDetele;
    private TextView tvDeviceName;
    private ImageView ivDevicePic;
    private TextView tvDeviceVersion;
@@ -55,6 +58,7 @@
    private IGetDeviceInfoCallBack.IModifyDeviceName modifyNameListener;
    private String fromWhere;
    private TextView tvDeploymentTip;
    private TextView tvFormat_sd;
    public static DeviceDetailMainFragment newInstance() {
        DeviceDetailMainFragment fragment = new DeviceDetailMainFragment();
@@ -86,17 +90,19 @@
        rlDetailVersion = view.findViewById(R.id.rl_detail_version);
        rlDeployment = view.findViewById(R.id.rl_deployment);
        tvDeploymentTip = view.findViewById(R.id.tv_deployment_tip);
//        rlDetele = view.findViewById(R.id.rl_detele);
        rlDetele = view.findViewById(R.id.rl_detele);
        tvDeviceName = view.findViewById(R.id.tv_device_name);
        ivDevicePic = view.findViewById(R.id.iv_device_pic);
        tvDeviceVersion = view.findViewById(R.id.tv_device_version);
        tvCurrentWifi = view.findViewById(R.id.tv_current_wifi);
        rlCurWifi = view.findViewById(R.id.rl_cur_wifi);
        tvFormat_sd =view.findViewById(R.id.tvFormat_sd);
        rlDeployment.setOnClickListener(this);
//        rlDetele.setOnClickListener(this);
        rlDetele.setOnClickListener(this);
        rlDeviceDetail.setOnClickListener(this);
        rlCurWifi.setOnClickListener(this);
        tvFormat_sd.setOnClickListener(this);
        DeviceDetailActivity deviceDetailActivity = (DeviceDetailActivity) getActivity();
        deviceDetailActivity.tvTitle.setText(getResources().getString(R.string.lc_demo_device_detail_title));
        if (arguments == null) {
@@ -126,7 +132,7 @@
                getDeviceLocalCache();
                rlDetailVersion.setVisibility(View.GONE);
                rlCurWifi.setVisibility(View.GONE);
//                rlDetele.setVisibility(View.GONE);
                rlDetele.setVisibility(View.GONE);
            }
        } else if (deviceListBean.channels!=null&&deviceListBean.channels.size() == 1) {
            //单通道
@@ -134,7 +140,7 @@
            getDeviceLocalCache();
            tvDeviceVersion.setText(deviceListBean.version);
            if (deviceListBean.deviceSource == 2) {
//                rlDetele.setVisibility(View.GONE);
                rlDetele.setVisibility(View.GONE);
            }
            rlCurWifi.setVisibility(View.VISIBLE);
            //设备才能获取WIFI
@@ -226,6 +232,7 @@
    }
    public void gotoUpdatePage(FragmentActivity fragmentActivity) {
        if(true){return;}
        if (fragmentActivity == null || fragmentActivity.getSupportFragmentManager() == null) {
            return;
        }
@@ -262,14 +269,41 @@
            gotoDeploymentPage(getActivity());
        } else if (id == R.id.rl_detail_version) {
            gotoUpdatePage(getActivity());
//        } else if (id == R.id.rl_detele) {
//            //解绑设备
//            deviceDetailActivity.rlLoading.setVisibility(View.VISIBLE);
//            DeviceDetailService deviceDetailService = ClassInstanceManager.newInstance().getDeviceDetailService();
//         /*   DeviceUnBindData deviceUnBindData = new DeviceUnBindData();
//            deviceUnBindData.data.deviceId = deviceListBean.deviceId;
//            deviceDetailService.unBindDevice(deviceUnBindData, this);*/
//            deviceDetailService.deletePermission(deviceListBean.deviceId,null,this);
        } else if (id == R.id.rl_detele) {
            //解绑设备
            deviceDetailActivity.rlLoading.setVisibility(View.VISIBLE);
            DeviceDetailService deviceDetailService = ClassInstanceManager.newInstance().getDeviceDetailService();
         /*   DeviceUnBindData deviceUnBindData = new DeviceUnBindData();
            deviceUnBindData.data.deviceId = deviceListBean.deviceId;
            deviceDetailService.unBindDevice(deviceUnBindData, this);*/
            deviceDetailService.deletePermission(deviceListBean.deviceId,null,this);
        }
        else if(id==R.id.tvFormat_sd){
         /*   DeviceUnBindData deviceUnBindData = new DeviceUnBindData();
            deviceUnBindData.data.deviceId = deviceListBean.deviceId;
            deviceDetailService.unBindDevice(deviceUnBindData, this);*/
            RecoverSDCardDialog dialog = new RecoverSDCardDialog(getContext());
            dialog.setOnOkClickLisenter(new DeviceUpdateDialog.OnOkClickLisenter() {
                @Override
                public void OnOK() {
                    deviceDetailActivity.rlLoading.setVisibility(View.VISIBLE);
                    DeviceDetailService deviceDetailService = ClassInstanceManager.newInstance().getDeviceDetailService();
                    deviceDetailService.recoverSDCard(deviceListBean.deviceId, new IGetDeviceInfoCallBack.IRecoverSDCardCallBack() {
                        @Override
                        public void onSuccess(String result) {
                            deviceDetailActivity.rlLoading.setVisibility(View.GONE);
                        }
                        @Override
                        public void onError(Throwable throwable) {
                            deviceDetailActivity.rlLoading.setVisibility(View.GONE);
                        }
                    });
                }
            });
            dialog.show();
        }
    }