From 3aa86eda8f416bec308d065689d39c847d2d9cc7 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期二, 30 一月 2024 19:48:26 +0800 Subject: [PATCH] 2024年01月30日19:44:13 --- app/src/main/java/com/hdl/photovoltaic/ui/message/NascentMessageFragment.java | 131 +++++++++++++++++++++---------------------- 1 files changed, 64 insertions(+), 67 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/message/NascentMessageFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/message/NascentMessageFragment.java index 016b4c4..3c464aa 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/message/NascentMessageFragment.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/message/NascentMessageFragment.java @@ -1,6 +1,7 @@ package com.hdl.photovoltaic.ui.message; +import android.annotation.SuppressLint; import android.content.Intent; import android.os.Bundle; import android.os.Handler; @@ -54,6 +55,7 @@ private final List<MessageBean> mList = new ArrayList<>(); private int currentPage = 0; // 褰撳墠椤电爜 private int total = 0; // 鏈�鍚庨〉鐮� + private boolean isLoadingMore = false; // 鏍囪姝e湪鍔犺浇鏇村鏁版嵁 @@ -150,12 +152,11 @@ messageNascentAdapter.setList(mList); messageNascentAdapter.notifyDataSetChanged(); } - //鏄剧ず鍙戠敓涓秷鎭�绘暟閲� - refreshNascentCount(); - //鏄剧ず娌℃暟鎹甎i鏍峰紡 - nullDataUpdateUi(); //鏄剧ず鏈淇℃伅鎬绘暟閲� getUnreadCount(); + //鏄剧ず娌℃暟鎹甎i鏍峰紡 + nullDataUpdateUi(); + } }); } @@ -163,16 +164,41 @@ /** * 鍒锋柊銆愬彂鐢熶腑銆戜俊鎭暟閲忔�绘暟 */ - private void refreshNascentCount() { + private void refreshNascentCount(String totalCount) { HdlThreadLogic.runMainThread(new Runnable() { @Override public void run() { TextView textView = _mActivity.findViewById(R.id.message_tab_nascent_title_tv); if (textView != null) { textView.setText(getText(R.string.message_nascent)); - if (mList.size() > 0) { - String s = getText(R.string.message_nascent) + "(" + mList.size() + ")"; + if (!TextUtils.isEmpty(totalCount) && !totalCount.equals("0")) { + String s = getText(R.string.message_nascent) + "(" + totalCount + ")"; textView.setText(s); + } + } + } + }); + } + + /** + * 鍒锋柊瑙掓爣銆愭湭璇汇�戜俊鎭暟閲忔�绘暟 + */ + private void refreshUnreadNascentCount(String unreadCount) { + HdlThreadLogic.runMainThread(new Runnable() { + @SuppressLint("SetTextI18n") + @Override + public void run() { + TextView textView = _mActivity.findViewById(R.id.my_message_bottom_il2).findViewById(R.id.red_count_tv); + if (textView != null) { + if (TextUtils.isEmpty(unreadCount) || unreadCount.equals("0")) { + textView.setVisibility(View.GONE); + } else { + textView.setVisibility(View.VISIBLE); + if (unreadCount.length() > 2) { + textView.setText("99+"); + } else { + textView.setText(unreadCount); + } } } } @@ -214,7 +240,7 @@ */ private void loadNextPageNascentMessageList(int pageNo, boolean isShowLoading) { if (pageNo == 1 && mList.size() > 0) { - //缂撳瓨鏁版嵁娌℃湁鎵嶅彲浠ヨ鍙栫涓�椤� + //娌℃湁缂撳瓨鏁版嵁,鎵嶅彲浠ヨ鍙栫涓�椤� return; } if (currentPage > total) { @@ -256,66 +282,37 @@ * 璇诲彇娑堟伅銆愭湭璇绘暟閲忋�� */ private void getUnreadCount() { - String untreatedMemoryCount = HdlMessageLogic.getInstance().getMessageUntreatedMemoryCount(); - TextView textView = _mActivity.findViewById(R.id.my_message_bottom_il2).findViewById(R.id.red_count_tv); - if (textView != null) { - if (TextUtils.isEmpty(untreatedMemoryCount) || untreatedMemoryCount.equals("0")) { - textView.setVisibility(View.GONE); - } else { - if (untreatedMemoryCount.length() > 2) { - //澶т簬3浣嶆暟,榛樿99+ - untreatedMemoryCount = "99+"; - } - textView.setVisibility(View.VISIBLE); - textView.setText(untreatedMemoryCount); + HdlMessageLogic.getInstance().getMessageUntreatedCount(new CloudCallBeak<String>() { + @Override + public void onSuccess(String data) { + + HdlThreadLogic.runMainThread(new Runnable() { + @Override + public void run() { + JSONObject jsonObject = JSON.parseObject(data); + if (jsonObject.containsKey("untreatedCount")) { + //鏈鐞嗘暟閲� + String untreatedCount = jsonObject.getString("untreatedCount"); + refreshNascentCount(untreatedCount); + } + if (jsonObject.containsKey("unreadCount")) { + //鏈鏁伴噺 + String unreadCount = jsonObject.getString("unreadCount"); + refreshUnreadNascentCount(unreadCount); + } + } + }); + } - } -// -// HdlMessageLogic.getInstance().getMessageUntreatedCount(new CloudCallBeak<String>() { -// @Override -// public void onSuccess(String data) { -// -// HdlThreadLogic.runMainThread(new Runnable() { -// @Override -// public void run() { -// JSONObject jsonObject = JSON.parseObject(data); -//// if (jsonObject.containsKey("untreatedCount")) { -//// //鏈鐞嗘暟閲� -//// jsonObject.getString("untreatedCount"); -//// } -// String unreadCount = "0"; -// if (jsonObject.containsKey("unreadCount")) { -// //鏈鏁伴噺 -// unreadCount = jsonObject.getString("unreadCount"); -// } -// TextView textView = _mActivity.findViewById(R.id.my_message_bottom_il2).findViewById(R.id.red_count_tv); -// if (textView != null) { -// if (TextUtils.isEmpty(unreadCount) || unreadCount.equals("0")) { -// textView.setVisibility(View.GONE); -// } else { -// if (unreadCount.length() > 2) { -// //澶т簬3浣嶆暟,榛樿99+ -// unreadCount = "99+"; -// } -// textView.setVisibility(View.VISIBLE); -// textView.setText(unreadCount); -// } -// -// -// } -// } -// }); -// -// } -// -// @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); -// } -// } -// }); + + @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); + } + } + }); } -- Gitblit v1.8.0