From 8b43d4e1190fc9e2261be0579e53cc6c2987f946 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 27 十一月 2025 19:37:56 +0800
Subject: [PATCH] 2025年11月27日19:37:50 备份代码
---
app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java | 151 ++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 121 insertions(+), 30 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
index e05ea20..0948a63 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
@@ -5,7 +5,6 @@
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
-import androidx.lifecycle.Lifecycle;
import android.Manifest;
import android.content.Context;
@@ -21,8 +20,9 @@
import android.view.View;
import android.widget.TextView;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
-import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.linkpm.sdk.home.type.HomeType;
@@ -44,22 +44,23 @@
import com.hdl.photovoltaic.other.HdlMessageLogic;
import com.hdl.photovoltaic.other.HdlMqttLogic;
import com.hdl.photovoltaic.other.HdlOtaLogic;
+import com.hdl.photovoltaic.other.HdlPushLogic;
import com.hdl.photovoltaic.other.HdlResidenceLogic;
import com.hdl.photovoltaic.other.HdlThreadLogic;
import com.hdl.photovoltaic.other.HdlUniLogic;
+import com.hdl.photovoltaic.push.PushMessageInfoBean;
import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo;
-import com.hdl.photovoltaic.ui.bean.HouseIdBean;
+import com.hdl.photovoltaic.ui.bean.MessageBean;
import com.hdl.photovoltaic.ui.bean.OidBean;
import com.hdl.photovoltaic.ui.bean.UnCountBean;
import com.hdl.photovoltaic.ui.home.HomePageFragment;
import com.hdl.photovoltaic.ui.me.MeFragment;
-import com.hdl.photovoltaic.ui.message.MessageFragment;
-import com.hdl.photovoltaic.ui.newC.PowerStationsListActivity;
-import com.hdl.photovoltaic.ui.newC.PowerStationsMoveActivity;
+import com.hdl.photovoltaic.ui.message.MessageHouseFragment;
+import com.hdl.photovoltaic.ui.message.MessageInfoActivity;
import com.hdl.photovoltaic.ui.powerstation.HouseAndDeviceFragment;
import com.hdl.photovoltaic.uni.HDLUniMP;
+import com.hdl.photovoltaic.uni.HDLUniMPSDKManager;
import com.hdl.photovoltaic.utils.AppManagerUtils;
-import com.hdl.photovoltaic.utils.FragmentUtils;
import com.hdl.photovoltaic.utils.GPSManagerUtils;
import com.hdl.photovoltaic.utils.PermissionUtils;
import com.hdl.photovoltaic.utils.SharedPreUtils;
@@ -82,6 +83,7 @@
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import cn.jpush.android.api.JPushInterface;
@@ -121,10 +123,14 @@
this.registerAllTopicsListener();
//鍒濆鍖杕qtt瀹㈡埛绔�
this.initMqttClient();
- //涓婁紶鏋佸厜娉ㄥ唽ID鍒颁簯绔�
- this.pushTokens();
- //鐐瑰嚮鏋佸厜閫氱煡鏍忔秷鎭繘鏉�
- this.clickJpushNotificationMessage();
+// //涓婁紶鏋佸厜娉ㄥ唽ID鍒颁簯绔� 闅愯棌2025-11-21 11:52:27
+// this.pushTokens();
+ //涓婁紶鎺ㄥ姩浠ょ墝鍒颁簯绔紙璋锋瓕FCM鎺ㄩ�侊級
+ this.sendPushTokenToServer(UserConfigManage.getInstance().getPushToken());
+// //鐐瑰嚮鏋佸厜閫氱煡鏍忔秷鎭繘鏉�
+// this.clickJpushNotificationMessage();
+ //鐐瑰嚮閫氱煡鏍忔秷鎭繘鏉�
+ this.OpenSpecifiedPage(getIntent(), "onBindView");
//鍒濆鍖栨潈闄�
this.requestPermissions();
//璇诲彇娑堟伅鏈鏁伴噺
@@ -135,6 +141,36 @@
}
+ /**
+ * 鐐瑰嚮閫氱煡鏍忔秷鎭繘鏉�
+ */
+ private void OpenSpecifiedPage(Intent intent, String tag) {
+ Log.d("==========", tag);
+ try {
+ String data = getIntentExpantData(intent);
+ if (TextUtils.isEmpty(data)) {
+ return;
+ }
+ PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing("", "", data);
+ if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId())) {
+ return;
+ }
+ MessageBean messageBean = new MessageBean();
+ messageBean.setMsgId(Long.valueOf(pushMessageInfoBean.getMsgId()));
+ Intent intentMessageInfoActivity = new Intent();
+ intentMessageInfoActivity.setClass(_mActivity, MessageInfoActivity.class);
+ intentMessageInfoActivity.putExtra("messageBean", JSONObject.toJSONString(messageBean));
+ startActivity(intentMessageInfoActivity);
+ this.clickNotificationMessageTab();
+ if (null != HDLUniMPSDKManager.getInstance().getUniMP()) {
+ Log.d("HDLUniMPSDKManager.getInstance().getUniMP()", "HDLUniMPSDKManager.getInstance().getUniMP()");
+ HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP();
+ }
+
+ } catch (Exception e) {
+ Log.d("閿欒", " " + e.getMessage());
+ }
+ }
/**
* 鍒濆鍖朏ragment
@@ -146,7 +182,7 @@
//纰庣墖鍒濆鍖�
HomePageFragment mHomePageFragment = new HomePageFragment();
HouseAndDeviceFragment mHouseAndDeviceFragment = new HouseAndDeviceFragment();
- MessageFragment mMessageFragment = new MessageFragment();
+ MessageHouseFragment mMessageHouseFragment = new MessageHouseFragment();
MeFragment mMeFragment = new MeFragment();
if (savedInstanceState != null) {
//鈥滃唴瀛橀噸鍚�濇椂璋冪敤 鑾峰彇鈥滃唴瀛橀噸鍚�濇椂淇濆瓨鐨勭储寮曚笅鏍�
@@ -168,7 +204,7 @@
}
fragmentList.add(mHomePageFragment);
fragmentList.add(mHouseAndDeviceFragment);
- fragmentList.add(mMessageFragment);
+ fragmentList.add(mMessageHouseFragment);
fragmentList.add(mMeFragment);
this.showFragment();
}
@@ -251,12 +287,6 @@
//鍚姩椤典笌mainActivity鏍峰紡涓�鏍凤紝杩欐牱鍚姩椤靛拰mainActivity鐪嬩笂鍘绘槸涓�涓晫闈紝鐩殑鏄负浜唌ainActivity閬綇涓嬩竴椤碉紱
// AppManagerUtils.getAppManager().finishActivity(StartActivity.class);
portConflictDialog();
-// Intent intent = new Intent(_mActivity, BPowerStationActivity.class);
-// intent.setFlags(Intent.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
-// intent.putExtra("skip", "skip");//閲岄潰鍒ゆ柇鏈夎繖涓爣璇嗗氨璺宠浆鍒版秷鎭腑蹇冪晫闈�
-// _mActivity.startActivity(intent);
- //鐐瑰嚮鏋佸厜閫氱煡鏍忔秷鎭繘鏉�
-// this.clickJpushNotificationMessage();
}
@@ -294,7 +324,7 @@
public void onSuccess(String pushId) {
if (!TextUtils.isEmpty(pushId)) {
- UserConfigManage.getInstance().setRegistrationID(finalRegistrationID);
+ UserConfigManage.getInstance().setPushToken(finalRegistrationID);
UserConfigManage.getInstance().setPushId(pushId);
UserConfigManage.getInstance().Save();
}
@@ -313,6 +343,28 @@
}
+ }
+ });
+ }
+
+ /**
+ * 涓婁紶 token 鍒版湇鍔″櫒
+ *
+ * @param token 浠ょ墝
+ */
+ private void sendPushTokenToServer(final String token) {
+ if (TextUtils.isEmpty(token)) {
+ return;
+ }
+ HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
+ @Override
+ public void onSuccess(String pushId) {
+ HdlLogLogic.print("娣诲姞浠ょ墝鍒颁簯绔� PushToken:" + UserConfigManage.getInstance().getPushToken() + " pushId:" + pushId, true);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ HdlLogLogic.print("娣诲姞浠ょ墝鍒颁簯绔け璐� PushToken:" + UserConfigManage.getInstance().getPushToken() + " 閿欒锛�" + e.getMessage(), true);
}
});
}
@@ -417,6 +469,7 @@
@Override
protected void onDestroy() {
super.onDestroy();
+ Log.d("BPowerStationActivity", "onDestroy");
HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack();
//绉婚櫎鐩戝惉
HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener);
@@ -749,6 +802,12 @@
bottomViewChangeOfStyle();
showFragment();
}
+ } else if (event.getTopic().contains(ConstantManage.refresh_push_token)) {
+ String token=event.getType();
+ UserConfigManage.getInstance().setPushToken(token);
+ UserConfigManage.getInstance().Save();
+ //pushToken鏇存柊
+ sendPushTokenToServer(UserConfigManage.getInstance().getPushToken());
}
}
@@ -801,19 +860,27 @@
});
}
+ @Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ //AndroidManifest.xml 闇�瑕佹坊鍔犲惎鍔ㄦā寮廰ndroid:launchMode="singleTask"鎵嶆墽琛岃繖涓柟娉�
+ OpenSpecifiedPage(intent, "onNewIntent");
+ }
/**
- * 鐐瑰嚮鏋佸厜閫氱煡鏍忔秷鎭繘鏉�
+ * 鐐瑰嚮閫氱煡鏍忔秷鎭繘鏉�,榛樿閫夋嫨娑堟伅妯″潡
*/
- private void clickJpushNotificationMessage() {
- Intent intent = getIntent();
- if (intent != null) {
- String key = intent.getStringExtra("skip");
- if (key != null) {
- //瑙﹀彂娑堟伅鐐瑰嚮浜嬩欢
- viewBinding.myMessageBottomIl2.clickTv.performClick();
- }
- }
+ private void clickNotificationMessageTab() {
+ //瑙﹀彂娑堟伅鐐瑰嚮浜嬩欢
+ viewBinding.myMessageBottomIl2.clickTv.performClick();
+// if (currentFragmentIndex == 2) {
+// return;
+// }
+// currentFragmentIndex = 2;
+// bottomViewChangeOfStyle();
+// showFragment();
+// HdlCommonLogic.lowerTagType = LowerTagType.message;
+// HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, HomepageTitleTabSwitch.message.toString());
}
@@ -907,5 +974,29 @@
}
}
+ /**
+ * 澶勭悊浠庨�氱煡鐐瑰嚮甯︽潵鐨勬暟鎹紝杩欓噷鑾峰彇鏁版嵁锛岀劧鍚庨�忎紶缁欎富鐣岄潰鍋氬鐞�
+ *
+ * @return 杩斿洖闄勫姞鏁版嵁
+ */
+ private String getIntentExpantData(Intent intent) {
+ try {
+ if (intent == null) {
+ return "";
+ }
+ // 澶勭悊浠庨�氱煡鐐瑰嚮甯︽潵鐨勬暟鎹紝杩欓噷鑾峰彇鏁版嵁锛岀劧鍚庨�忎紶缁欎富鐣岄潰鍋氬鐞�
+ if (intent.getExtras() != null) {
+ for (String key : intent.getExtras().keySet()) {
+ if (key.equals("pushData")) {
+ return Objects.requireNonNull(intent.getExtras().get(key)).toString();
+ }
+ }
+ }
+ } catch (Exception e) {
+ return "";
+ }
+ return "";
+ }
+
}
\ No newline at end of file
--
Gitblit v1.8.0