From b8209d15d915f72d9abe3a68b76e1f4cfd21eac3 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期六, 23 九月 2023 14:37:00 +0800
Subject: [PATCH] 2023年09月23日14:36:51

---
 app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java |  108 ++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 89 insertions(+), 19 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..a149678 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
@@ -6,20 +6,34 @@
 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 java.nio.charset.StandardCharsets;
 
+/**
+ * 鎴戠殑鐢电珯鐣岄潰
+ */
 public class MyPowerStationActivity extends CustomBaseActivity {
 
 
     private ActivityMyPowerStationBinding viewBinding;
-    private int currentFragmentIndex = 0;
+    private int currentFragmentIndex = 1;
+    private EventListener allTopicsListener;
 
 
     @Override
@@ -35,23 +49,33 @@
         initView();
         //鍒濆鍖栫晫闈㈢洃鍚櫒
         initEvent();
+        //娉ㄥ唽鐩戝惉
+        registerAllTopicsListener();
     }
 
     private void initEvent() {
         viewBinding.myPowerStationBottomIl1.clickTv.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                currentFragmentIndex = 0;
-                bottomViewChangeOfStyle();
-            }
-        });
-        viewBinding.myPowerStationBottomIl2.clickTv.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
                 currentFragmentIndex = 1;
                 bottomViewChangeOfStyle();
             }
         });
+        viewBinding.myMessageBottomIl2.clickTv.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                currentFragmentIndex = 2;
+                bottomViewChangeOfStyle();
+            }
+        });
+        viewBinding.myMeBottomIl3.clickTv.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                currentFragmentIndex = 3;
+                bottomViewChangeOfStyle();
+            }
+        });
+
 
     }
 
@@ -59,34 +83,53 @@
     protected void onDestroy() {
         super.onDestroy();
         HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack();
+        //绉婚櫎鐩戝惉
+        HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener);
+
     }
 
     private void initView() {
         viewBinding.myPowerStationBottomIl1.titleTv.setText(R.string.my_power_station_鐢电珯);
-        viewBinding.myPowerStationBottomIl2.titleTv.setText(R.string.my_power_station_鎴戠殑);
+        viewBinding.myMessageBottomIl2.titleTv.setText(R.string.message_娑堟伅);
+        viewBinding.myMeBottomIl3.titleTv.setText(R.string.my_power_station_鎴戠殑);
         this.bottomViewChangeOfStyle();
 
     }
 
     private void bottomViewChangeOfStyle() {
-        if (this.currentFragmentIndex == 0) {
+        if (this.currentFragmentIndex == 1) {
             viewBinding.myPowerStationFcv1.setVisibility(View.VISIBLE);
-            viewBinding.myPowerStationFcv2.setVisibility(View.GONE);
+            viewBinding.myMessageFcv2.setVisibility(View.GONE);
+            viewBinding.myMeFcv3.setVisibility(View.GONE);
             viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.selectedpowerstation));
             viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_90000000));
-            viewBinding.myPowerStationBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.unselectedme));
-            viewBinding.myPowerStationBottomIl2.titleTv.setTextColor(getColor(R.color.text_65000000));
-        } else {
+            viewBinding.myMessageBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.message_unselected));
+            viewBinding.myMessageBottomIl2.titleTv.setTextColor(getColor(R.color.text_65000000));
+            viewBinding.myMeBottomIl3.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.unselectedme));
+            viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_65000000));
+        } else if (this.currentFragmentIndex == 2) {
             viewBinding.myPowerStationFcv1.setVisibility(View.GONE);
-            viewBinding.myPowerStationFcv2.setVisibility(View.VISIBLE);
+            viewBinding.myMessageFcv2.setVisibility(View.VISIBLE);
+            viewBinding.myMeFcv3.setVisibility(View.GONE);
             viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.unselectedpowerstation));
             viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_65000000));
-            viewBinding.myPowerStationBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.selectedme));
-            viewBinding.myPowerStationBottomIl2.titleTv.setTextColor(getColor(R.color.text_90000000));
-
-
+            viewBinding.myMessageBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.message_select));
+            viewBinding.myMessageBottomIl2.titleTv.setTextColor(getColor(R.color.text_90000000));
+            viewBinding.myMeBottomIl3.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.unselectedme));
+            viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_65000000));
+        } else if (this.currentFragmentIndex == 3) {
+            viewBinding.myPowerStationFcv1.setVisibility(View.GONE);
+            viewBinding.myMessageFcv2.setVisibility(View.GONE);
+            viewBinding.myMeFcv3.setVisibility(View.VISIBLE);
+            viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.unselectedpowerstation));
+            viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_65000000));
+            viewBinding.myMessageBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.message_unselected));
+            viewBinding.myMessageBottomIl2.titleTv.setTextColor(getColor(R.color.text_65000000));
+            viewBinding.myMeBottomIl3.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.selectedme));
+            viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_90000000));
         }
     }
+
 
     public void requestPermissions() {
         String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION});
@@ -131,4 +174,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