From ebf1b9c813030a366bdc8967d2788eba3f3d9b5a Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期一, 21 八月 2023 13:18:58 +0800 Subject: [PATCH] 2023年08月21日13:18:56 --- app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java index 2c1f5f6..107c441 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java @@ -6,13 +6,25 @@ import android.Manifest; import android.content.pm.PackageManager; import android.os.Bundle; +import android.os.Parcel; +import android.os.Parcelable; +import android.view.MotionEvent; 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.ActivityMyPowerStationBinding; +import com.hdl.photovoltaic.other.HdlLogLogic; import com.hdl.photovoltaic.other.HdlUniLogic; +import com.hdl.photovoltaic.uni.HDLUniMP; import com.hdl.photovoltaic.utils.PermissionUtils; +import com.hdl.sdk.link.HDLLinkLocalSdk; +import com.hdl.sdk.link.common.event.EventListener; +import com.hdl.sdk.link.core.bean.LinkResponse; +import com.hdl.sdk.link.core.bean.ModbusResponse; + +import java.nio.charset.StandardCharsets; public class MyPowerStationActivity extends CustomBaseActivity { @@ -20,6 +32,7 @@ private ActivityMyPowerStationBinding viewBinding; private int currentFragmentIndex = 0; + private EventListener allTopicsListener; @Override @@ -35,6 +48,8 @@ initView(); //鍒濆鍖栫晫闈㈢洃鍚櫒 initEvent(); + //娉ㄥ唽鐩戝惉 + registerAllTopicsListener(); } private void initEvent() { @@ -59,6 +74,9 @@ protected void onDestroy() { super.onDestroy(); HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack(); + //绉婚櫎鐩戝惉 + HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener); + } private void initView() { @@ -87,6 +105,7 @@ } } + public void requestPermissions() { String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}); @@ -131,4 +150,31 @@ } + /** + * 娉ㄥ唽鎵�鏈変富棰樻暟鎹殑鐩戝惉 + */ + private void registerAllTopicsListener() { + allTopicsListener = new EventListener() { + @Override + public void onMessage(Object msg) { + if (msg instanceof LinkResponse) { + LinkResponse response = (LinkResponse) msg; + if (response.getTopic() == null) { + return; + } + HdlLogLogic.print("鐩戝惉鍒扮殑鏁版嵁===========" + new Gson().toJson(response)); +// if (response.getTopic().endsWith("custom/native/inverter/up")) { + HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); + uniCallBackBaseBean.setType(response.getTopic()); + uniCallBackBaseBean.setData(response.getData()); + HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); +// } + + } + } + }; + HDLLinkLocalSdk.getInstance().registerAllTopicsListener(allTopicsListener); + } + + } \ No newline at end of file -- Gitblit v1.8.0