hxb
2022-11-24 535d69817e83737f3da6250fc6fb70da25fc1a4c
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package com.common.openapi;
 
import android.os.Handler;
import android.os.Message;
 
import com.common.openapi.entity.DeviceDetailListData;
import com.common.openapi.entity.DeviceListData;
import com.common.openapi.entity.SubAccountDeviceData;
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.BusinessException;
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.BusinessRunnable;
import com.mm.android.deviceaddmodule.mobilecommon.base.LCBusinessHandler;
import com.mm.android.deviceaddmodule.mobilecommon.businesstip.BusinessErrorTip;
import com.mm.android.deviceaddmodule.mobilecommon.businesstip.HandleMessageCode;
import com.mm.android.deviceaddmodule.openapi.data.DeviceInfoBeforeBindData;
 
public class DeviceSubAccountListService {
    public static final int pageSize=10;
 
    public void getDeviceListSubAccount(final int pageNo, final String openid, final IGetDeviceInfoCallBack.ISubAccountDevice<SubAccountDeviceData.Response> getDeviceListCallBack){
        final LCBusinessHandler handler = new LCBusinessHandler() {
            @Override
            public void handleBusiness(Message msg) {
                if (getDeviceListCallBack == null) {
                    return;
                }
                if (msg.what == HandleMessageCode.HMC_SUCCESS) {
                    //成功
                    getDeviceListCallBack.DeviceList((SubAccountDeviceData.Response) msg.obj);
                } else {
                    //失败
                    getDeviceListCallBack.onError(BusinessErrorTip.throwError(msg));
                }
            }
        };
        new BusinessRunnable(handler) {
            @Override
            public void doBusiness() throws BusinessException {
                try {
                    dealSubAccountDeviceList(handler,pageNo,openid);
                } catch (BusinessException e) {
                    throw e;
                }
            }
        };
    }
 
    private void dealSubAccountDeviceList(Handler handler,int pageNo,String openid)throws BusinessException{
        SubAccountDeviceData.Response response= DeviceInfoOpenApiManager.getSubAccountDeviceListLight(pageNo,pageSize,openid);
        handler.obtainMessage(HandleMessageCode.HMC_SUCCESS, response).sendToTarget();
    }
 
    public void getSubAccountDeviceList(final int pageNo, final IGetDeviceInfoCallBack.ISubAccountDevice<DeviceDetailListData.Response> getDeviceListCallBack){
        final LCBusinessHandler handler = new LCBusinessHandler() {
            @Override
            public void handleBusiness(Message msg) {
                if (getDeviceListCallBack == null) {
                    return;
                }
                if (msg.what == HandleMessageCode.HMC_SUCCESS) {
                    //成功
                    getDeviceListCallBack.DeviceList(( DeviceDetailListData.Response) msg.obj);
                } else {
                    //失败
                    getDeviceListCallBack.onError(BusinessErrorTip.throwError(msg));
                }
            }
        };
        new BusinessRunnable(handler) {
            @Override
            public void doBusiness() throws BusinessException {
                try {
                    getDeviceListAtSubAccount(handler,pageNo);
                } catch (BusinessException e) {
                    throw e;
                }
            }
        };
    }
 
    private void getDeviceListAtSubAccount(Handler handler,int pageNo)throws BusinessException{
        DeviceDetailListData.Response response= DeviceInfoOpenApiManager.getSubAccountDeviceList(pageNo,pageSize);
        handler.obtainMessage(HandleMessageCode.HMC_SUCCESS, response).sendToTarget();
    }
 
}