| | |
| | | |
| | | |
| | | import android.os.Bundle; |
| | | import android.os.Process; |
| | | import android.os.SystemClock; |
| | | import android.text.TextUtils; |
| | | |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.linkpm.sdk.home.type.HomeType; |
| | | import com.hdl.photovoltaic.HDLApp; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | | import com.hdl.photovoltaic.bean.MqttInfo; |
| | | import com.hdl.photovoltaic.config.ConstantManage; |
| | |
| | | import com.hdl.photovoltaic.ui.bean.HouseIdBean; |
| | | import com.hdl.photovoltaic.ui.bean.OidBean; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.sdk.link.HDLLinkLocalSdk; |
| | | import com.hdl.sdk.link.common.event.EventListener; |
| | | import com.hdl.sdk.link.core.bean.LinkResponse; |
| | |
| | | private ActivityCpowerStationBinding viewBinding; |
| | | |
| | | private EventListener allTopicsListener; |
| | | private int backPressTimes; |
| | | |
| | | @Override |
| | | public Object getContentView() { |
| | |
| | | if (deviceRemoteInfo != null) { |
| | | //更新mqtt通讯的新秘钥 |
| | | gatewayBean.setAesKey(deviceRemoteInfo.getSecret()); |
| | | gatewayBean.setGatewayId(deviceRemoteInfo.getGatewayId()); |
| | | //用之前的库,底层mqtt订阅,加解密会用到该参数; |
| | | HDLLinkConfig.getInstance().setAesKey(deviceRemoteInfo.getSecret());//设置mqtt通讯秘钥库 |
| | | HDLLinkConfig.getInstance().setGatewayId(deviceRemoteInfo.getGatewayId());//设置GatewayId |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | }); |
| | | } |
| | | } else if (event.getTopic().contains(HDLUniMP.UNI_EVENT_REPLY_OTHER_MODEL) |
| | | && event.getType().contains(HDLUniMP.UNI_EVENT_REPLY_OTHER_BACK)) { |
| | | //物理按键返回事件(包括左滑移除事件) |
| | | if (AppManagerUtils.getAppManager().getActivitySize() <= 1) { |
| | | if (backPressTimes == 0) { |
| | | HdlThreadLogic.toast(_mActivity, R.string.kill_app); |
| | | backPressTimes = 1; |
| | | new Thread() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Thread.sleep(2000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | backPressTimes = 0; |
| | | } |
| | | } |
| | | }.start(); |
| | | return; |
| | | } else { |
| | | //关闭小程序 |
| | | if (null != HDLUniMPSDKManager.getInstance().getUniMP()) { |
| | | HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP(); |
| | | } |
| | | AppManagerUtils.getAppManager().finishAllActivity(); |
| | | HDLUniMPSDKManager.getInstance().initDCUniMPSDK(HDLApp.getInstance()); |
| | | Process.killProcess(Process.myPid()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | HouseIdBean houseIdBean = HouseIdList.get(select_home); |
| | | HdlResidenceLogic.getInstance().switchHouse(houseIdBean); |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS_C |
| | | + "?homeId=" + houseIdBean.getHomeId() |
| | | + "&homeName=" + houseIdBean.getHomeName() |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | |
| | | * 初始化mqtt客户端 |
| | | */ |
| | | public void initMqttClient() { |
| | | |
| | | HdlMqttLogic.getInstance().getMqttRemoteInfo(HomeType.A, new CloudCallBeak<MqttInfo>() { |
| | | @Override |
| | | public void onSuccess(MqttInfo info) { |
| | | if (info != null) { |
| | | MqttRecvClient.getInstance().setConnectParam(info.getUrl(), info.getClientId(), info.getUserName(), info.getPassWord()); |
| | | MqttRecvClient.getInstance().connect(); |
| | | if (!MqttRecvClient.getInstance().isInit()) { |
| | | HdlMqttLogic.getInstance().getMqttRemoteInfo(HomeType.A, new CloudCallBeak<MqttInfo>() { |
| | | @Override |
| | | public void onSuccess(MqttInfo info) { |
| | | if (info != null) { |
| | | MqttRecvClient.getInstance().setConnectParam(info.getUrl(), info.getClientId(), info.getUserName(), info.getPassWord()); |
| | | MqttRecvClient.getInstance().connect(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlLogLogic.print("读取mqtt远程信息失败--->" + e.getMessage(), e.getCode(), true); |
| | | } |
| | | }); |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlLogLogic.print("读取mqtt远程信息失败--->" + e.getMessage(), e.getCode(), true); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |