From 040227e7bf27786656347612f3e89d703df33cc3 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期五, 31 五月 2024 14:51:42 +0800
Subject: [PATCH] 2024年05月31日14:51:40
---
app/src/main/java/com/hdl/photovoltaic/ui/message/MessageFragment.java | 104 +++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 90 insertions(+), 14 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 466190d..979a2b6 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
@@ -12,6 +12,7 @@
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+import com.google.gson.Gson;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.photovoltaic.R;
import com.hdl.photovoltaic.base.CustomBaseFragment;
@@ -28,6 +29,7 @@
import com.hdl.photovoltaic.ui.adapter.MessageAdapter;
import com.hdl.photovoltaic.ui.bean.MessageBean;
import com.hdl.photovoltaic.ui.bean.UnCountBean;
+import com.hdl.photovoltaic.widget.BTypeTitleListDialog;
import com.hdl.photovoltaic.widget.TypeTitleListDialog;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
@@ -51,6 +53,9 @@
private boolean isAlarmDeviceClick = true;//true琛ㄧず鍛婅璁惧琚�変腑,鍒檉alse琛ㄧず鎶ヨ璁板綍琚�変腑
private final List<MessageBean> mList = new ArrayList<>();
+
+ private boolean isRefreshTotalCount = true;
+ private int mTotalCount = 0; //鎬绘潯鏁�
private int mCurrentPage = 0; // 褰撳墠椤电爜
private int mCurrentTotal = 0; // 鎬婚〉鐮�
private String mDeviceTypeFilterKye = FilterType.deviceType;//杩囨护绫诲瀷 deviceType锛圛NV 锛氶�嗗彉鍣紱BMS 锛欱MS鎺у埗鐩掞紱BATTERY 锛氱數姹犲崟鍏冿級
@@ -92,7 +97,17 @@
if (isAlarmDeviceClick) {
return;
}
+ mDeviceTypeFilterKye = FilterType.deviceType;
+ mDeviceTypeFilterValue = FilterType.all;
+ mTypeFilterKye = FilterType.all;
+ mTypeFilterValue = FilterType.all;
+ mTimeTypeFilterKye = FilterType.all;
+ mTimeTypeFilterValue = FilterType.all;
+ viewBinding.allDeviceTitleTv.setText(getString(R.string.alarm_all_device));
+ viewBinding.allGradeTitleTv.setText(getString(R.string.alarm_all_grade));
+ viewBinding.allTimeTitleTv.setText(getString(R.string.alarm_all_time));
isAlarmDeviceClick = true;
+ isRefreshTotalCount = true;
viewBinding.messageTabNascentTitleTv.setTextAppearance(R.style.Text20Style);
viewBinding.messageTabRecoverTitleTv.setTextAppearance(R.style.Text16Style);
viewBinding.allClearTv.setVisibility(View.VISIBLE);
@@ -106,7 +121,17 @@
if (!isAlarmDeviceClick) {
return;
}
+ mDeviceTypeFilterKye = FilterType.deviceType;
+ mDeviceTypeFilterValue = FilterType.all;
+ mTypeFilterKye = FilterType.all;
+ mTypeFilterValue = FilterType.all;
+ mTimeTypeFilterKye = FilterType.all;
+ mTimeTypeFilterValue = FilterType.all;
+ viewBinding.allDeviceTitleTv.setText(getString(R.string.alarm_all_device));
+ viewBinding.allGradeTitleTv.setText(getString(R.string.alarm_all_grade));
+ viewBinding.allTimeTitleTv.setText(getString(R.string.alarm_all_time));
isAlarmDeviceClick = false;
+ isRefreshTotalCount = true;
viewBinding.messageTabNascentTitleTv.setTextAppearance(R.style.Text16Style);
viewBinding.messageTabRecoverTitleTv.setTextAppearance(R.style.Text20Style);
viewBinding.allClearTv.setVisibility(View.GONE);
@@ -117,7 +142,14 @@
viewBinding.messageSearchCl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+ String messageStateType;
+ if (isAlarmDeviceClick) {
+ messageStateType = MessageStateType.untreated;
+ } else {
+ messageStateType = MessageStateType.processed;
+ }
Intent intent = new Intent();
+ intent.putExtra("MessageStateType", messageStateType);
intent.setClass(_mActivity, SearchMessageActivity.class);
startActivity(intent);
}
@@ -213,7 +245,7 @@
@Override
public void onClick(int position, MessageBean messageBean) {
Intent intent = new Intent();
- intent.putExtra("msgId", messageBean.getMsgId().toString());
+ intent.putExtra("messageBean", new Gson().toJson(messageBean));
intent.setClass(_mActivity, MessageInfoActivity.class);
startActivity(intent);
}
@@ -230,14 +262,29 @@
* @param stringList 杩囨护绫诲瀷鍊艰〃
*/
private void setTypeTitleListDialog(TextView textView, String filterType, List<String> stringList) {
- TypeTitleListDialog typeTitleListDialog = new TypeTitleListDialog(_mActivity, stringList);
+ BTypeTitleListDialog typeTitleListDialog = new BTypeTitleListDialog(_mActivity, stringList, textView.getText().toString());
typeTitleListDialog.show();
- typeTitleListDialog.setOnListener(new TypeTitleListDialog.OnClickListener() {
+ typeTitleListDialog.setOnListener(new BTypeTitleListDialog.OnClickListener() {
@Override
public void onClick(int position, String title) {
textView.setText(title);
- mTimeTypeFilterKye = filterType;
- mTimeTypeFilterValue = findFilterValueString(title);
+ switch (filterType) {
+ case FilterType.deviceType: {
+ mDeviceTypeFilterKye = filterType;
+ mDeviceTypeFilterValue = findFilterValueString(title);
+ }
+ break;
+ case FilterType.type: {
+ mTypeFilterKye = filterType;
+ mTypeFilterValue = findFilterValueString(title);
+ }
+ break;
+ case FilterType.timeType: {
+ mTimeTypeFilterKye = filterType;
+ mTimeTypeFilterValue = findFilterValueString(title);
+ }
+ break;
+ }
loadNextPageMessageList(true, 1, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue, true);
}
});
@@ -276,7 +323,7 @@
// 鍙栨秷绮樻�т簨浠�
EventBus.getDefault().removeStickyEvent(eventBus);
//杩涙潵璇诲彇涓�娆℃暟鎹�(涓轰簡鏇存柊currentPage锛宑urrentTotal杩欎釜鍊�)
- initData();
+// initData();
HdlLogLogic.print("姝e湪鐐瑰嚮銆愭秷鎭��");
}
@@ -337,6 +384,7 @@
if (messageListClass != null) {
mCurrentTotal = (int) messageListClass.getTotalPage();
mCurrentPage = (int) messageListClass.getPageNo();
+ mTotalCount = (int) messageListClass.getTotalCount();
updateListData();
}
isLoadingMore = false;
@@ -373,20 +421,25 @@
updateRecyclerViewList();
//鏄剧ず鏈淇℃伅鎬绘暟閲�
getUnreadCount();
+ if (isAlarmDeviceClick) {
+ refreshNascentTotalCount(mTotalCount);
+ } else {
+ refreshRecoverTotalCount(mTotalCount);
+ }
//鏄剧ず娌℃暟鎹甎i鏍峰紡
nullDataUpdateUi();
+
}
});
}
/**
- * 鍒锋柊淇℃伅鏁伴噺鎬绘暟
+ * 鍒锋柊鍙戦�佷腑娑堟伅鎬绘暟閲�
*
* @param nascentTotalCount 鍙戦�佷腑娑堟伅鎬绘暟閲�
- * @param recoverTotalCount 鎶ヨ璁板綍娑堟伅鎬绘暟閲�
*/
- private void refreshAascentAndRecoverTotalCount(int nascentTotalCount, int recoverTotalCount) {
+ private void refreshNascentTotalCount(int nascentTotalCount) {
HdlThreadLogic.runMainThread(new Runnable() {
@Override
public void run() {
@@ -399,6 +452,20 @@
nascentTv.setText(s);
}
}
+ }
+ });
+
+ }
+
+ /**
+ * 鍒锋柊鎶ヨ璁板綍娑堟伅鎬绘暟閲�
+ *
+ * @param recoverTotalCount 鎶ヨ璁板綍娑堟伅鎬绘暟閲�
+ */
+ private void refreshRecoverTotalCount(int recoverTotalCount) {
+ HdlThreadLogic.runMainThread(new Runnable() {
+ @Override
+ public void run() {
//鎶ヨ璁板綍鎬绘暟閲�
TextView recoverTV = _mActivity.findViewById(R.id.message_tab_recover_title_tv);
if (recoverTV != null) {
@@ -486,8 +553,12 @@
if (unCountBean == null) {
return;
}
- refreshAascentAndRecoverTotalCount(unCountBean.getUntreatedCount(), unCountBean.getProcessedCount());
refreshUnreadCount(unCountBean.getUnreadCount());
+ if (isRefreshTotalCount) {
+ isRefreshTotalCount = false;
+ refreshNascentTotalCount(unCountBean.getUntreatedCount());
+ refreshRecoverTotalCount(unCountBean.getProcessedCount());
+ }
}
});
@@ -495,10 +566,15 @@
@Override
public void onFailure(HDLException e) {
- TextView textView = _mActivity.findViewById(R.id.my_message_bottom_il2).findViewById(R.id.red_count_tv);
- if (textView != null) {
- textView.setVisibility(View.GONE);
- }
+ HdlThreadLogic.runMainThread(new Runnable() {
+ @Override
+ public void run() {
+ TextView textView = _mActivity.findViewById(R.id.my_message_bottom_il2).findViewById(R.id.red_count_tv);
+ if (textView != null) {
+ textView.setVisibility(View.GONE);
+ }
+ }
+ });
}
});
}
--
Gitblit v1.8.0