| | |
| | | |
| | | import androidx.multidex.MultiDex; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.hdl.hdlhttp.HxHttpConfig; |
| | | import com.hdl.linkpm.sdk.HDLLinkPMSdk; |
| | | import com.hdl.linkpm.sdk.user.HDLLinkPMUser; |
| | |
| | | HDLLinkPMUser.getInstance().setOnReloginListener(new IOnReloginListener() { |
| | | @Override |
| | | public void onReLogin(int type) { |
| | | Log.d("====退到登录界面====", "====退到登录界面====" + type); |
| | | HdlLogLogic.print("退到登录界面---" + type, true); |
| | | //type: 0:正常退出 1:极光推送强制退出 |
| | | //收到登录处理通知,关闭所有页面并打开登录页面 |
| | | AppManagerUtils.getAppManager().finishAllActivity(); |
| | |
| | | UserConfigManage.getInstance().Save(); |
| | | } |
| | | HDLApp.getInstance().setInfoMap(registrationId_tag, "true");//记录一下状态,后台杀死app会清空; |
| | | HdlLogLogic.print("添加极光ID到云端--->registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | HdlLogLogic.print("添加极光ID到云端---registrationID:" + UserConfigManage.getInstance().getUserName() + "---" + finalRegistrationID, true); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HDLApp.getInstance().setInfoMap(registrationId_tag, "false");//记录一下状态,后台杀死app会清空; |
| | | HdlLogLogic.print("添加极光ID到云端失败--->registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | HdlLogLogic.print("添加极光ID到云端失败---registrationID:" + UserConfigManage.getInstance().getUserName() + "---" + finalRegistrationID, true); |
| | | } |
| | | }); |
| | | |
| | |
| | | HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack(); |
| | | //移除监听 |
| | | HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener); |
| | | |
| | | |
| | | } |
| | | |
| | | private void initView() { |
| | |
| | | if (response.getTopic() == null) { |
| | | return; |
| | | } |
| | | HdlLogLogic.print("监听到Modbus数据--->" + new Gson().toJson(response), false); |
| | | HdlLogLogic.print("监听到Modbus数据---" + new Gson().toJson(response), false); |
| | | // if (response.getTopic().endsWith("custom/native/inverter/up")) { |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(response.getTopic()); |
| | |
| | | } else if (linkResponse.getTopic().endsWith("/custom/device/list/upload")) { |
| | | //逆变器有新oid通知主题 |
| | | if (linkResponse.getData() == null) { |
| | | HdlLogLogic.print("逆变器有新oid通知--->数据为空", false); |
| | | HdlLogLogic.print("逆变器有新oid通知---数据为空", false); |
| | | return; |
| | | } |
| | | try { |
| | |
| | | if (info != null) { |
| | | MqttRecvClient.getInstance().setConnectParam(info.getUrl(), info.getClientId(), info.getUserName(), info.getPassWord()); |
| | | MqttRecvClient.getInstance().connect(); |
| | | HdlLogLogic.print("mqtt链接成功--->ClientId--->" + info.getClientId(), true); |
| | | HdlLogLogic.print("mqtt链接成功---ClientId---" + info.getClientId(), true); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlLogLogic.print("读取mqtt远程信息失败--->" + e.getMessage(), e.getCode(), true); |
| | | HdlLogLogic.print("读取mqtt远程信息失败---" + e.getMessage(), e.getCode(), true); |
| | | } |
| | | }); |
| | | } |
| | |
| | | UserConfigManage.getInstance().Save(); |
| | | } |
| | | HDLApp.getInstance().setInfoMap(registrationId_tag, "true");//记录一下状态,后台杀死app会清空; |
| | | HdlLogLogic.print("C端--->添加极光ID到云端--->registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | HdlLogLogic.print("C端---添加极光ID到云端---registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HDLApp.getInstance().setInfoMap(registrationId_tag, "false");//记录一下状态,后台杀死app会清空; |
| | | HdlLogLogic.print("C端--->添加极光ID到云端失败--->registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | HdlLogLogic.print("C端---添加极光ID到云端失败---registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | } |
| | | }); |
| | | |
| | |
| | | if (info != null) { |
| | | MqttRecvClient.getInstance().setConnectParam(info.getUrl(), info.getClientId(), info.getUserName(), info.getPassWord()); |
| | | MqttRecvClient.getInstance().connect(); |
| | | HdlLogLogic.print("mqtt链接成功--->ClientId--->" + info.getClientId(), true); |
| | | HdlLogLogic.print("mqtt链接成功---ClientId---" + info.getClientId(), true); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlLogLogic.print("读取mqtt远程信息失败--->" + e.getMessage(), e.getCode(), true); |
| | | HdlLogLogic.print("读取mqtt远程信息失败---" + e.getMessage(), e.getCode(), true); |
| | | } |
| | | }); |
| | | } |
| | |
| | | if (response.getTopic() == null) { |
| | | return; |
| | | } |
| | | HdlLogLogic.print("C端--->监听到Modbus数据--->" + new Gson().toJson(response), false); |
| | | HdlLogLogic.print("C端---监听到Modbus数据---" + new Gson().toJson(response), false); |
| | | // if (response.getTopic().endsWith("custom/native/inverter/up")) { |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(response.getTopic()); |
| | |
| | | if (mUniMPCaches.containsKey(uniAppId)) { |
| | | if (mUniMPCaches.get(uniAppId) != null) { |
| | | mUniMPCaches.get(uniAppId).sendUniMPEvent(topic, data); |
| | | HdlLogLogic.print("Android--->通知---uni--->主题:" + topic + "--->发送数据:" + new Gson().toJson(data)); |
| | | HdlLogLogic.print("Android---通知---uni---主题:" + topic + "---发送数据:" + new Gson().toJson(data)); |
| | | } else { |
| | | HdlLogLogic.print("Android--->通知---uni--->失败--->小程序对象为空:" + uniAppId); |
| | | HdlLogLogic.print("Android---通知---uni---失败---小程序对象为空:" + uniAppId); |
| | | } |
| | | } else { |
| | | HdlLogLogic.print("Android--->通知---uni--->失败--->小程序对象为空:" + uniAppId); |
| | | HdlLogLogic.print("Android---通知---uni--->失败---¬小程序对象为空:" + uniAppId); |
| | | } |
| | | |
| | | } |
| | |
| | | public void checkRemoveOtherUniMPEventCallBack(IOnOtherUniMPEventCallBack onOtherUniMPEventCallBack) { |
| | | if (this.onOtherUniMPEventCallBack == onOtherUniMPEventCallBack) { |
| | | this.onOtherUniMPEventCallBack = null; |
| | | HdlLogLogic.print("onOtherUniMPEventCallBack remove callback"); |
| | | HdlLogLogic.print("onOtherUniMPEventCallBack remove callback", true); |
| | | } |
| | | } |
| | | |