From 791f82dc46e14491116a87bd4aa84ade011ab4c6 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期一, 15 一月 2024 14:30:58 +0800
Subject: [PATCH] 2024年01月15日14:30:41
---
app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java | 34 ++++++++++++++++++++++------------
1 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java
index ff6ccf9..c13e282 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java
@@ -3,24 +3,33 @@
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
+import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.photovoltaic.R;
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.enums.MessageStateType;
+import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.other.HdlCommonLogic;
import com.hdl.photovoltaic.other.HdlLogLogic;
+import com.hdl.photovoltaic.other.HdlMessageLogic;
import com.hdl.photovoltaic.ui.bean.BUserInfo;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
@@ -67,6 +76,7 @@
currentIndex = 0;
initView();
showFragment();
+ postEventBus(MessageFunctionTabSwitch.nascent);
}
});
@@ -77,6 +87,7 @@
currentIndex = 1;
initView();
showFragment();
+ postEventBus(MessageFunctionTabSwitch.recover);
}
});
@@ -88,6 +99,7 @@
currentIndex = 2;
initView();
showFragment();
+ postEventBus(MessageFunctionTabSwitch.all);
}
});
}
@@ -116,6 +128,7 @@
viewBinding.line2V.setVisibility(View.GONE);
viewBinding.line3V.setVisibility(View.VISIBLE);
}
+
}
private void initData() {
@@ -130,7 +143,8 @@
BaseEventBus baseEventBus = new BaseEventBus();
baseEventBus.setTopic(ConstantManage.message_function_tab_switch);
baseEventBus.setType(tabSwitch.toString());
- EventBus.getDefault().post(baseEventBus);
+ //鍙戦�佺矘鎬т簨浠�(濡傛灉涓嶅彂绮樻�т簨浠朵細閬囧埌涓�涓病鏈夊姞杞藉嚭鏉ョ殑纰庣墖鎺ユ敹涓嶅埌淇℃伅)
+ EventBus.getDefault().postSticky(baseEventBus);
}
@@ -183,13 +197,6 @@
//鎶婂綋鍓嶆樉绀虹殑fragment璁板綍涓嬫潵
currentFragment = fragmentList.get(currentIndex);
- if (this.currentIndex == 0) {
- postEventBus(MessageFunctionTabSwitch.nascent);
- } else if (this.currentIndex == 1) {
- postEventBus(MessageFunctionTabSwitch.recover);
- } else if (this.currentIndex == 2) {
- postEventBus(MessageFunctionTabSwitch.all);
- }
}
@@ -209,18 +216,21 @@
}
-
- @Override
+ @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
public void onEventMessage(BaseEventBus eventBus) {
super.onEventMessage(eventBus);
+ if (eventBus == null) {
+ return;
+ }
//鎺ユ敹澶栭儴鐐瑰嚮浜嬩欢
if (eventBus.getTopic().equals(ConstantManage.homepage_title_tab_switch)) {
if (eventBus.getType().equals(HomepageTitleTabSwitch.message.toString())) {
+ // 鍙栨秷绮樻�т簨浠�
+ EventBus.getDefault().removeStickyEvent(eventBus);
postEventBus(MessageFunctionTabSwitch.nascent);
HdlLogLogic.print("姝e湪鐐瑰嚮銆愭秷鎭��");
+
}
}
}
-
-
}
--
Gitblit v1.8.0