From 80f2ca2df62ff1cd03046864af504245be078eb2 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 05 六月 2025 10:37:28 +0800
Subject: [PATCH] 2025年06月05日10:37:26
---
app/src/main/java/com/hdl/photovoltaic/ui/newC/MessageCenterList.java | 174 ++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 126 insertions(+), 48 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/newC/MessageCenterList.java b/app/src/main/java/com/hdl/photovoltaic/ui/newC/MessageCenterList.java
index 89fcca9..20ba1a0 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/newC/MessageCenterList.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/newC/MessageCenterList.java
@@ -4,6 +4,8 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
import android.view.View;
import android.widget.TextView;
@@ -29,10 +31,13 @@
import com.hdl.photovoltaic.other.HdlThreadLogic;
import com.hdl.photovoltaic.other.HdlUniLogic;
import com.hdl.photovoltaic.ui.bean.MessageBean;
+import com.hdl.photovoltaic.ui.bean.UnCountBean;
import com.hdl.photovoltaic.ui.message.MessageInfoActivity;
import com.hdl.photovoltaic.ui.newC.adapter.MessageCenterListAdapter;
import com.hdl.photovoltaic.uni.HDLUniMP;
import com.hdl.photovoltaic.widget.TypeTitleListDialog;
+import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout;
+import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -48,6 +53,9 @@
*/
public class MessageCenterList extends CustomBaseActivity {
+ private Handler handler;
+ private Runnable delayedRunnable;
+
private ActivityMessageCenterListBinding viewBinding;
private MessageCenterListAdapter messageCenterListAdapter;
@@ -61,7 +69,7 @@
private int mTotalCount1 = 0;//娑堟伅鏁伴噺鎬绘暟
private int mTotalCount2 = 0;//娑堟伅鏁伴噺鎬绘暟
- private String mDeviceTypeFilterKye = FilterType.deviceType;//杩囨护绫诲瀷 deviceType锛圛NV 锛氶�嗗彉鍣紱BMS 锛欱MS鎺у埗鐩掞紱BATTERY 锛氱數姹犲崟鍏冿級
+ private String mDeviceTypeFilterKye = FilterType.all;//杩囨护绫诲瀷 deviceType锛圛NV 锛氶�嗗彉鍣紱BMS 锛欱MS鎺у埗鐩掞紱BATTERY 锛氱數姹犲崟鍏冿級
private String mDeviceTypeFilterValue = FilterType.all;//杩囨护绫诲瀷鍊� deviceType锛圛NV 锛氶�嗗彉鍣紱BMS 锛欱MS鎺у埗鐩掞紱BATTERY 锛氱數姹犲崟鍏冿級
private String mTypeFilterKye = FilterType.all;//杩囨护绫诲瀷 type锛團AULT 锛氭晠闅滐紱 WARN 锛氬憡璀︼紱 EVENT 锛氫簨浠�(鎻愮ず)锛夛紱
@@ -77,6 +85,7 @@
private boolean isLoadingMore = false; // 鏍囪姝e湪鍔犺浇鏇村鏁版嵁
LinearLayoutManager mLayoutManager;
+
@Override
public Object getContentView() {
viewBinding = ActivityMessageCenterListBinding.inflate(getLayoutInflater());
@@ -85,23 +94,33 @@
@Override
public void onBindView(Bundle savedInstanceState) {
- setNotificationBarBackgroundColor(CustomColor.white);
- setStatusBarTextColor();
+ setStatusBarTranslucent();
+ getWindow().setNavigationBarColor(getColor(R.color.text_FF1C1C1E));
//鍒濆鍖栨暟鎹�
initData();
//鍒濆鍖�
initView();
//鍒濆鍖栫晫闈㈢洃鍚櫒
initEvent();
+ getUnreadCount();
//杩涙潵璇诲彇涓�娆℃暟鎹�(涓轰簡鏇存柊currentPage锛宑urrentTotal杩欎釜鍊�)
- loadNextPageMessageList(1, true, FilterType.all, FilterType.all, FilterType.all, FilterType.all, FilterType.all, FilterType.all);
+ loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue);
}
+
@Override
protected void onResume() {
super.onResume();
//杩涙潵璇诲彇涓�娆℃暟鎹�(涓轰簡鏇存柊currentPage锛宑urrentTotal杩欎釜鍊�)
// loadNextPageMessageList(1, true, mFilterKye, mFilterValue);
+ }
+
+ @Override
+ protected void onDestroy() {
+ if (handler != null && delayedRunnable != null) {
+ handler.removeCallbacks(delayedRunnable);
+ }
+ super.onDestroy();
}
private void initEvent() {
@@ -241,7 +260,7 @@
if (isAlarmDeviceClick) {
return;//闃叉澶氭鐐瑰嚮
}
- mDeviceTypeFilterKye = FilterType.deviceType;
+ mDeviceTypeFilterKye = FilterType.all;
mDeviceTypeFilterValue = FilterType.all;
mTypeFilterKye = FilterType.all;
mTypeFilterValue = FilterType.all;
@@ -262,7 +281,7 @@
if (!isAlarmDeviceClick) {
return;//闃叉澶氭鐐瑰嚮
}
- mDeviceTypeFilterKye = FilterType.deviceType;
+ mDeviceTypeFilterKye = FilterType.all;
mDeviceTypeFilterValue = FilterType.all;
mTypeFilterKye = FilterType.all;
mTypeFilterValue = FilterType.all;
@@ -275,38 +294,6 @@
refreshBottomStyle(false);
loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue);
- }
- });
-
- //涓嬫媺鎸夐挳
- viewBinding.messageContentSrl.setColorSchemeResources(R.color.text_FF245EC3);
- viewBinding.messageContentSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
- @Override
- public void onRefresh() {
- viewBinding.messageContentSrl.setRefreshing(false);
- loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue);
- }
- });
- //涓婃媺鎸夐挳
- viewBinding.messageContentRl.addOnScrollListener(new RecyclerView.OnScrollListener() {
- @Override
- public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
-// super.onScrolled(recyclerView, dx, dy);
-
- LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
- if (layoutManager == null) {
- return;
- }
- int visibleItemCount = layoutManager.getChildCount();
- int totalItemCount = layoutManager.getItemCount();
- int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
- if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) {
- if (!isLoadingMore) {
- // 婊戝姩鍒颁簡搴曢儴锛屾墽琛岀浉搴旂殑鎿嶄綔
- HdlLogLogic.print("--->婊戝姩鍒颁簡搴曢儴");
- loadNextPageMessageList(++mCurrentPage, false, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue);
- }
- }
}
});
if (messageCenterListAdapter != null) {
@@ -324,12 +311,10 @@
}
private void initView() {
- viewBinding.toolbarTopMessageCenterListRl.getRoot().setBackgroundColor(getColor(R.color.text_FFFFFFFF));
viewBinding.toolbarTopMessageCenterListRl.topBackLl.setVisibility(View.VISIBLE);
- viewBinding.toolbarTopMessageCenterListRl.topLeftIv.setImageResource(R.drawable.back_c);
viewBinding.toolbarTopMessageCenterListRl.topTitleTv.setText(R.string.set_message_center);
viewBinding.toolbarTopMessageCenterListRl.topMoreBtn.setVisibility(View.VISIBLE);
- viewBinding.toolbarTopMessageCenterListRl.topMoreIv.setImageResource(R.drawable.clearall);
+ viewBinding.toolbarTopMessageCenterListRl.topMoreIv.setImageResource(R.drawable.clear_all);
//榛樿閫変腑鍏ㄩ儴璁惧
viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.down);
viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.down);
@@ -340,10 +325,78 @@
viewBinding.messageContentRl.setLayoutManager(mLayoutManager);
viewBinding.messageContentRl.setAdapter(messageCenterListAdapter);
messageCenterListAdapter.setList(mList);
- this.nullDataUpdateUi();
+// this.nullDataUpdateUi();
+ pullToRefresh();
}
+
private void initData() {
+ try {
+ Intent intent = getIntent();
+ if (intent != null) {
+ String isShowFault = intent.getStringExtra("isShowFault");
+ if (isShowFault != null && isShowFault.equals("true")) {
+ //榛樿鏁呴殰鍏ㄩ儴
+ mDeviceTypeFilterKye = FilterType.all;
+ mDeviceTypeFilterValue = FilterType.all;
+ mTypeFilterKye = FilterType.type;
+ mTypeFilterValue = "FAULT";
+ mTimeTypeFilterKye = FilterType.all;
+ mTimeTypeFilterValue = FilterType.all;
+ viewBinding.allGradeTitleTv.setText(getString(R.string.alarm_all_grade_malfunction));
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ /**
+ * 涓嬫媺鍒锋柊鐨勯�昏緫
+ */
+ protected void pullToRefresh() {
+ viewBinding.messageContentSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() {
+ @Override
+ public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) {
+ handler = new Handler(Looper.getMainLooper());
+
+ delayedRunnable = new Runnable() {
+ @Override
+ public void run() {
+ viewBinding.messageContentSrl.endRefreshing();
+ loadNextPageMessageList(1, false, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue);
+ }
+ };
+ // 寤惰繜 5 绉掓墽琛�
+ handler.postDelayed(delayedRunnable, 1000);
+ }
+
+
+ @Override
+ public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) {
+
+ handler = new Handler(Looper.getMainLooper());
+ delayedRunnable = new Runnable() {
+ @Override
+ public void run() {
+ viewBinding.messageContentSrl.endLoadingMore();
+ if (!isLoadingMore) {
+ // 婊戝姩鍒颁簡搴曢儴锛屾墽琛岀浉搴旂殑鎿嶄綔
+ HdlLogLogic.print("--->婊戝姩鍒颁簡搴曢儴");
+ loadNextPageMessageList(++mCurrentPage, false, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue);
+ }
+ }
+ };
+ // 寤惰繜 5 绉掓墽琛�
+ handler.postDelayed(delayedRunnable, 10);
+
+ return true;
+ }
+ });
+ HDLRefreshViewHolder hdlRefreshViewHolder = new HDLRefreshViewHolder(_mActivity, true);
+ hdlRefreshViewHolder.setPullDownImageResource(R.mipmap.loading_44);
+ hdlRefreshViewHolder.setChangeToReleaseRefreshAnimResId(R.drawable.loading_refresh);
+ hdlRefreshViewHolder.setRefreshingAnimResId(R.drawable.loading_refresh_end);
+ viewBinding.messageContentSrl.setRefreshViewHolder(hdlRefreshViewHolder);
}
/**
@@ -414,12 +467,37 @@
if (isShowLoading) {
hideLoading();
}
+ HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")");
}
});
}
+ /**
+ * 璇诲彇娑堟伅銆愭湭璇绘暟閲�,鏈鐞嗘�绘暟閲忥紝宸插鐞嗘�绘暟閲忋��
+ */
+ private void getUnreadCount() {
+ HdlMessageLogic.getInstance().getMessageUntreatedCount(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<UnCountBean>() {
+ @Override
+ public void onSuccess(UnCountBean unCountBean) {
+ HdlThreadLogic.runMainThread(new Runnable() {
+ @Override
+ public void run() {
+ if (unCountBean == null) {
+ return;
+ }
+ mTotalCount1 = unCountBean.getUntreatedCount();
+ mTotalCount2 = unCountBean.getProcessedCount();
+ }
+ });
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ }
+ });
+ }
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
public void onEventMessage(BaseEventBus eventBus) {
@@ -479,17 +557,15 @@
@Override
public void run() {
if (typeClick) {
- viewBinding.messageBottomAlarmDeviceTitleTv.setTextColor(getColor(R.color.text_191919));
viewBinding.messageBottomAlarmDeviceLineV.setVisibility(View.VISIBLE);
- viewBinding.messageBottomAlarmRecordTitleTv.setTextColor(getColor(R.color.text_B2B2B2));
viewBinding.messageBottomAlarmRecordLineV.setVisibility(View.GONE);
-
-
+ viewBinding.messageBottomAlarmDeviceTitleTv.setTextColor(getColor(R.color.text_FFACACAC));
+ viewBinding.messageBottomAlarmRecordTitleTv.setTextColor(getColor(R.color.text_FF5B5B5B));
} else {
- viewBinding.messageBottomAlarmDeviceTitleTv.setTextColor(getColor(R.color.text_B2B2B2));
viewBinding.messageBottomAlarmDeviceLineV.setVisibility(View.GONE);
- viewBinding.messageBottomAlarmRecordTitleTv.setTextColor(getColor(R.color.text_191919));
viewBinding.messageBottomAlarmRecordLineV.setVisibility(View.VISIBLE);
+ viewBinding.messageBottomAlarmDeviceTitleTv.setTextColor(getColor(R.color.text_FF5B5B5B));
+ viewBinding.messageBottomAlarmRecordTitleTv.setTextColor(getColor(R.color.text_FFACACAC));
}
}
@@ -570,6 +646,7 @@
map.put(getString(R.string.alarm_all_device_inverter), "INV");
map.put(getString(R.string.alarm_all_device_bms), "BMS");
map.put(getString(R.string.alarm_all_device_battery_cell), "BATTERY");
+ map.put(getString(R.string.alarm_all_device_load_centre), "LOAD_CENTRE");
map.put(getString(R.string.alarm_all_grade), "");//璁剧瓑绾у叏閮�
map.put(getString(R.string.alarm_all_grade_malfunction), "FAULT");
map.put(getString(R.string.alarm_all_grade_warning), "WARN");
@@ -602,6 +679,7 @@
stringList.add(getString(R.string.alarm_all_device_inverter));
stringList.add(getString(R.string.alarm_all_device_bms));
stringList.add(getString(R.string.alarm_all_device_battery_cell));
+ stringList.add(getString(R.string.alarm_all_device_load_centre));
}
break;
case FilterType.type: {
--
Gitblit v1.8.0