app/src/main/java/com/hdl/photovoltaic/enums/MessageFunctionTabSwitch.java
@@ -5,6 +5,6 @@ */ public enum MessageFunctionTabSwitch { all,//全部 nascent,//进行中 nascent,//发生中 recover,//已恢复 } app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -1164,21 +1164,22 @@ HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<GatewayBean>>() { @Override public void onSuccess(List<GatewayBean> list) { GatewayBean gatewayBean = HdlDeviceLogic.getInstance().queryCurrentHomeMainGateway(list); if (gatewayBean != null) { //进来住宅详情都要上传一次oid列表到云端; HdlDeviceLogic.getInstance().uploadDataToCloud(gatewayBean.getDevice_mac(), null); } //EventBus事件分发,进入住宅开始订阅主题 BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST); baseEventBus.setData(list); EventBus.getDefault().post(baseEventBus); if (callback != null) { uniCallbackData(list, callback); //EventBus事件分发,进入住宅开始订阅主题 BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST); baseEventBus.setData(list); EventBus.getDefault().post(baseEventBus); GatewayBean gatewayBean = HdlDeviceLogic.getInstance().queryCurrentHomeMainGateway(list); if (gatewayBean != null) { //进来住宅详情都要上传一次oid列表到云端; HdlDeviceLogic.getInstance().uploadDataToCloud(gatewayBean.getDevice_mac(), null); } } } @Override app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
@@ -126,6 +126,7 @@ currentFragmentIndex = 2; bottomViewChangeOfStyle(); postEventBus(HomepageTitleTabSwitch.message); } }); viewBinding.myMeBottomIl3.clickTv.setOnClickListener(new View.OnClickListener() { @@ -201,7 +202,7 @@ private void postEventBus(HomepageTitleTabSwitch tabSwitch) { BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setTopic(ConstantManage.homepage_title_tab_switch); baseEventBus.setType(tabSwitch + ""); baseEventBus.setType(tabSwitch.toString()); EventBus.getDefault().post(baseEventBus); } app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java
@@ -47,14 +47,18 @@ //装机容量 String capacity = mContext.getString(R.string.my_power_station_installed_capacity) + houseIdBean.getInstalledCapacity() + "kW"; holder.capacityTv.setText(capacity); String kw = "0.0"; String kw = "0"; try { double d = Double.parseDouble(houseIdBean.getPower()); int intValue = (int) d; if (houseIdBean.getPower().contains(".")) { int indexOf = houseIdBean.getPower().indexOf("."); houseIdBean.setPower(houseIdBean.getPower().substring(0, indexOf)); } int intValue = Integer.parseInt(houseIdBean.getPower()); int k = intValue / 1000; int w = intValue % 1000; kw = k + "." + w; } catch (Exception ignored) { kw = "0.0"; } //发电功率 String power = mContext.getString(R.string.power_station_generated_power) + kw + "kW"; app/src/main/java/com/hdl/photovoltaic/ui/bean/HouseIdBean.java
@@ -42,7 +42,7 @@ } public String getInstalledCapacity() { return installedCapacity == null ? "" : installedCapacity; return installedCapacity == null ? "0" : installedCapacity; } public void setInstalledCapacity(String installedCapacity) { app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java
@@ -12,8 +12,10 @@ import com.hdl.photovoltaic.base.CustomBaseFragment; import com.hdl.photovoltaic.config.ConstantManage; import com.hdl.photovoltaic.databinding.FragmentMessageBinding; import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch; import com.hdl.photovoltaic.enums.MessageFunctionTabSwitch; import com.hdl.photovoltaic.other.HdlCommonLogic; import com.hdl.photovoltaic.other.HdlLogLogic; import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; import org.greenrobot.eventbus.EventBus; @@ -128,7 +130,7 @@ private void postEventBus(MessageFunctionTabSwitch tabSwitch) { BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setTopic(ConstantManage.message_function_tab_switch); baseEventBus.setType(tabSwitch + ""); baseEventBus.setType(tabSwitch.toString()); EventBus.getDefault().post(baseEventBus); } @@ -175,11 +177,9 @@ //如果之前没有添加过 if (!fragmentList.get(currentIndex).isAdded()) { //第三个参数为添加当前的fragment时绑定一个tag ft.hide(currentFragment) .add(R.id.message_fcv, fragmentList.get(currentIndex), currentIndex + ""); ft.hide(currentFragment).add(R.id.message_fcv, fragmentList.get(currentIndex), currentIndex + ""); } else { ft.hide(currentFragment) .show(fragmentList.get(currentIndex)); ft.hide(currentFragment).show(fragmentList.get(currentIndex)); } currentFragment = fragmentList.get(currentIndex); ft.commit(); @@ -203,4 +203,17 @@ } @Override public void onEventMessage(BaseEventBus eventBus) { super.onEventMessage(eventBus); //接收外部点击事件 if (eventBus.getTopic().equals(ConstantManage.homepage_title_tab_switch)) { if (eventBus.getType().equals(HomepageTitleTabSwitch.message.toString())) { postEventBus(MessageFunctionTabSwitch.nascent); HdlLogLogic.print("正在点击【消息】"); } } } } app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java
@@ -4,6 +4,7 @@ import android.os.Bundle; import android.view.View; import com.google.gson.Gson; import com.hdl.photovoltaic.R; import com.hdl.photovoltaic.base.CustomBaseActivity; import com.hdl.photovoltaic.databinding.ActivityMessageInfoBinding; @@ -16,6 +17,8 @@ ActivityMessageInfoBinding viewBinding; private MessageBean mMessageBean; @Override public Object getContentView() { viewBinding = ActivityMessageInfoBinding.inflate(getLayoutInflater()); @@ -26,8 +29,14 @@ public void onBindView(Bundle savedInstanceState) { setNotificationBarBackgroundColor(CustomColor.white); setStatusBarTextColor(); Bundle bundle = getIntent().getBundleExtra("message_info"); // MessageBean try { String json = getIntent().getStringExtra("message_info"); mMessageBean = new Gson().fromJson(json, MessageBean.class); } catch (Exception ignored) { } if (mMessageBean == null) { mMessageBean = new MessageBean(); } //初始化 initView(); app/src/main/java/com/hdl/photovoltaic/ui/message/NascentMessageFragment.java
@@ -49,15 +49,7 @@ } private void initData() { // mList = new ArrayList<>(); // for (int i = 0; i < 3; i++) { // MessageBean messageBean = new MessageBean(); // messageBean.setTitle("来了一条告警信息" + i); // messageBean.setHomeName(i + ""); // messageBean.setCreateTime((long) 1234567777); // messageBean.setRead(false); // mList.add(messageBean); // } getNascentMessageList(true); } private void initEvent() { app/src/main/java/com/hdl/photovoltaic/ui/message/RecoverMessageFragment.java
@@ -6,6 +6,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import com.google.gson.Gson; import com.hdl.linkpm.sdk.core.exception.HDLException; import com.hdl.photovoltaic.R; import com.hdl.photovoltaic.base.CustomBaseFragment; @@ -77,9 +78,7 @@ @Override public void onClick(int position, MessageBean item) { Intent intent = new Intent(); Bundle bundle = new Bundle(); bundle.putSerializable("message_info", MessageBean.class); intent.putExtras(bundle); intent.putExtra("message_info", new Gson().toJson(item)); intent.setClass(_mActivity, MessageInfoActivity.class); startActivity(intent); } app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
@@ -205,13 +205,13 @@ } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) { //进去住宅详情uni读取逆变器列表成功后通知 for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().size(); i++) { //String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().get(i).getGatewayId(); //字符串是自己按规则拼接的,里面注册主题时会解析字符串,只拿getGatewayId()值; //String topic = "/user/" + gatewayId+"/1"; //进去住宅详情开始订阅主题 MqttRecvClient.getInstance().checkAndsubscribeAllTopics(""); } // for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().size(); i++) { //String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().get(i).getGatewayId(); //字符串是自己按规则拼接的,里面注册主题时会解析字符串,只拿getGatewayId()值; //String topic = "/user/" + gatewayId+"/1"; //进去住宅详情开始订阅主题 MqttRecvClient.getInstance().checkAndsubscribeAllTopics(""); // } } else if (eventBus.getTopic().equals(ConstantManage.homepage_title_tab_switch)) { //接收外部点击事件 if (eventBus.getType().equals(HomepageTitleTabSwitch.powerstation.toString())) {