| | |
| | | package com.mm.android.deviceaddmodule;
|
| | |
|
| | | import android.app.Activity;
|
| | | import android.app.Application;
|
| | | import android.content.Context;
|
| | | import android.content.Intent;
|
| | | import android.os.Bundle;
|
| | |
| | | private Throwable throwable;
|
| | | public CommonParam commonParam;
|
| | | public String userId = "";
|
| | | private String homeId;
|
| | |
|
| | | private Application context;
|
| | | public Application getContext() {
|
| | | return context;
|
| | | }
|
| | |
|
| | | public void setContext(Application context) {
|
| | | this.context = context;
|
| | | }
|
| | |
|
| | | public static LCDeviceEngine newInstance() {
|
| | | if (lcDeviceEngine == null) {
|
| | |
| | |
|
| | | public boolean init(CommonParam commonParam) throws Throwable {
|
| | | this.commonParam = commonParam;
|
| | | this.accessToken = "";
|
| | | this.accessToken = "St_0000c3e2e772d5f74bfca2d86eaa18a6";//为了低层空判断,当前token无效
|
| | | this.userId = "";
|
| | | this.sdkHasInit = false;
|
| | | this.context = commonParam.getContext();
|
| | | if (commonParam == null) {
|
| | | throw new Exception("commonParam must not null");
|
| | | }
|
| | |
| | | commonParam.checkParam();
|
| | | //初始化参数
|
| | | initParam(commonParam);
|
| | | //获取开放平台token
|
| | | initToken();
|
| | | if (TextUtils.isEmpty(accessToken)) {
|
| | | throw throwable;
|
| | | if (!CONST.HOST.contains("hdlcontrol.com")) {
|
| | | //获取开放平台token
|
| | | initToken();
|
| | | if (TextUtils.isEmpty(accessToken)) {
|
| | | throw throwable;
|
| | | }
|
| | | }
|
| | | //组件初始化
|
| | | InitParams initParams = new InitParams(commonParam.getContext(), CONST.HOST.replace("https://", ""), accessToken);
|
| | | InitParams initParams = new InitParams(commonParam.getContext(), CONST.Envirment.OVERSEAS_PRO.url.replace("https://", ""), accessToken);
|
| | | LCOpenSDK_Api.initOpenApi(initParams);
|
| | | LCOpenSDK_DeviceInit.getInstance();
|
| | | sdkHasInit = true;
|
| | |
| | | //开启添加页面
|
| | | activity.startActivity(new Intent(commonParam.getContext(), DeviceAddActivity.class));
|
| | | }
|
| | | public void setSubAccessToken(String subAccessToken){
|
| | |
|
| | | public void setSubAccessToken(String subAccessToken) {
|
| | | this.subAccessToken = subAccessToken;
|
| | | }
|
| | |
|
| | | public boolean deviceOnlineChangeNet(Activity activity,DHDevice device, CurWifiInfo wifiInfo) {
|
| | | public boolean deviceOnlineChangeNet(Activity activity, DHDevice device, CurWifiInfo wifiInfo) {
|
| | | if (!sdkHasInit) {
|
| | | return false;
|
| | | }
|
| | |
| | | private void initParam(CommonParam commonParam) throws Exception {
|
| | | userId = TextUtils.isEmpty(commonParam.getUserId()) ? commonParam.getAppId() : commonParam.getUserId();
|
| | | //传入参数 AppId SecretKey 环境切换
|
| | | CONST.makeEnv(commonParam.getEnvirment(), commonParam.getAppId(), commonParam.getAppSecret());
|
| | | CONST.makeEnv(commonParam.getEnvirment(), commonParam.getAppId(), commonParam.getAppSecret());//
|
| | | ContextHelper.init(commonParam.getContext());
|
| | | new EnvironmentConfig.Builder().setContext(commonParam.getContext()).build();
|
| | | initImageLoader(commonParam.getContext());
|
| | |
| | | ImageLoader.getInstance().init(config);
|
| | | }
|
| | |
|
| | | public String getHomeId() {
|
| | | return homeId == null ? "" : homeId;
|
| | | }
|
| | |
|
| | | public void setHomeId(String homeId) {
|
| | | this.homeId = homeId;
|
| | | }
|
| | |
|
| | | private String productBrandldentity;
|
| | | public String getProductBrandldentity() { return productBrandldentity == null ? "" : productBrandldentity;}
|
| | |
|
| | | public void setProductBrandldentity(String productBrandldentity){
|
| | | this.productBrandldentity = productBrandldentity;
|
| | | }
|
| | | }
|