111
hxb
2022-11-24 0a3e07f10937484145f33c7560607b4b2353cb81
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.mm.android.deviceaddmodule.device_wifi;
 
import android.content.Intent;
import android.os.Handler;
 
import com.mm.android.deviceaddmodule.LCDeviceEngine;
import com.mm.android.deviceaddmodule.R;
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.BusinessException;
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.BusinessRunnable;
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.DHBaseHandler;
import com.mm.android.deviceaddmodule.mobilecommon.businesstip.HandleMessageCode;
import com.mm.android.deviceaddmodule.mobilecommon.common.LCConfiguration;
import com.mm.android.deviceaddmodule.openapi.DeviceAddOpenApiManager;
 
public class HiddenWifiPresenter<T extends HiddenWifiConstract.View> extends BasePresenter<T> implements HiddenWifiConstract.Presenter {
 
    protected String mDeviceId;
    private DHBaseHandler mWifiOperateHandler;
 
    public HiddenWifiPresenter(T view) {
        super(view);
        initModel();
    }
 
    protected void initModel() {
 
    }
 
    @Override
    public void dispatchIntentData(Intent intent) {
        if (intent != null && intent.getExtras() != null) {
            mDeviceId = intent.getStringExtra(LCConfiguration.Device_ID);
        }
    }
 
 
    @Override
    public void wifiOperate() {
        if (mView.get().getWifiSSID().equalsIgnoreCase("")) {
            return;
        }
        new BusinessRunnable(mWifiOperateHandler) {
            @Override
            public void doBusiness() throws BusinessException {
                try {
                    DeviceAddOpenApiManager.controlDeviceWifi(LCDeviceEngine.newInstance().accessToken, mDeviceId, mView.get().getWifiSSID(),"", true, mView.get().getWifiPassword());
                    mWifiOperateHandler.obtainMessage(HandleMessageCode.HMC_SUCCESS, true).sendToTarget();
                } catch (BusinessException e) {
                    throw e;
                }
            }
        };
        mView.get().showToastInfo(R.string.device_manager_wifi_connetting_tip);
        Handler mHandler = new Handler();
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                mView.get().onWifiOperateSucceed(null);
            }
        }, 3000);
    }
 
 
    @Override
    public void unInit() {
 
    }
}