| | |
| | | package com.hdl.photovoltaic.other; |
| | | |
| | | |
| | | import android.text.TextUtils; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.hdl.photovoltaic.HDLApp; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.ui.bean.HouseIdBean; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | | import com.hdl.photovoltaic.utils.WifiUtils; |
| | | |
| | | import org.json.JSONObject; |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import io.dcloud.feature.unimp.DCUniMPJSCallback; |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void onOtherUniMPEventReceive(String appId, String event, Object data, DCUniMPJSCallback callback) { |
| | | if (!HDLUniMP.UNI_APP_ID.equals(appId)) { |
| | | return; |
| | | } |
| | | try { |
| | | org.json.JSONObject jsonObject = null; |
| | | if (data != null) { |
| | | jsonObject = new org.json.JSONObject(data.toString()); |
| | | if (!HDLUniMP.UNI_APP_ID.equals(appId)) { |
| | | return; |
| | | } |
| | | //住宅模块 |
| | | if (HDLUniMP.UNI_EVENT_REPLY_HOME_LIST.equals(event)) { |
| | | org.json.JSONObject jsonObject = getJSONObject(data); |
| | | String type_value = ""; |
| | | if (jsonObject.has("type")) { |
| | | type_value = jsonObject.getString("type"); |
| | | } |
| | | |
| | | if (HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL.equals(event)) { |
| | | //住宅模块 |
| | | switch (type_value) { |
| | | case HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION: { |
| | | //创建 |
| | | HdlResidenceLogic.getInstance().getResidenceIdList("", "", new CloudCallBeak<List<HouseIdBean>>() { |
| | | @Override |
| | | public void onSuccess(List<HouseIdBean> list) { |
| | | HdlResidenceLogic.getInstance().setHouseIdList(list); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(Exception exception) { |
| | | |
| | | } |
| | | }); |
| | | |
| | | } |
| | | break; |
| | | case HDLUniMP.UNI_EVENT_REPLY_HOME_DETAILS: { |
| | | //详情 |
| | | } |
| | | break; |
| | | |
| | | } |
| | | if (callback != null) { |
| | | uniCallbackData(null, "0", "", callback); |
| | | } |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODEL.equals(event)) { |
| | | //设备模块 |
| | | switch (type_value) { |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_ADD: { |
| | | //添加 |
| | | } |
| | | break; |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST: { |
| | | //获取设备列表 |
| | | } |
| | | break; |
| | | |
| | | } |
| | | |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_WIFI_MODEL.equals(event)) { |
| | | WifiUtils wifiUtils = new WifiUtils(HDLApp.getInstance()); |
| | | //wifi模块 |
| | | switch (type_value) { |
| | | case HDLUniMP.UNI_EVENT_REPLY_WIFI_LIST: { |
| | | //获取wifi列表 |
| | | if (callback != null) { |
| | | uniCallbackData(wifiUtils.getScanResult(), "0", "", callback); |
| | | } |
| | | } |
| | | break; |
| | | case HDLUniMP.UNI_EVENT_REPLY_WIFI_INFO: { |
| | | //当前wifi详情 |
| | | if (callback != null) { |
| | | uniCallbackData(wifiUtils.getCurrentConnectWifiInfo(), "0", "", callback); |
| | | } |
| | | } |
| | | break; |
| | | case HDLUniMP.UNI_EVENT_REPLY_WIFI_CONNECT: { |
| | | //wifi连接 |
| | | } |
| | | break; |
| | | |
| | | } |
| | | } |
| | | HdlLogLogic.print("uni===原生接收uni发来的数据", event + "\r\n" + data); |
| | |
| | | uniCallBackBaseBean.setMes(msg); |
| | | uniCallBackBaseBean.setData(obj); |
| | | if (callback != null) { |
| | | callback.invoke(uniCallBackBaseBean); |
| | | callback.invoke(getJSONObject(uniCallBackBaseBean)); |
| | | } |
| | | } catch (Exception e) { |
| | | HdlLogLogic.print("uni===组装uni发送数据格式", e.getMessage()); |
| | |
| | | */ |
| | | private JSONObject getJSONObject(Object obj) { |
| | | try { |
| | | if (obj == null) { |
| | | return new JSONObject(); |
| | | } |
| | | if (TextUtils.isEmpty(obj.toString())) { |
| | | return new JSONObject(); |
| | | } |
| | | String json = new Gson().toJson(obj); |
| | | return new JSONObject(json); |
| | | } catch (Exception e) { |