mac
2024-01-30 3aa86eda8f416bec308d065689d39c847d2d9cc7
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; // 标记正在加载更多数据
@@ -150,12 +152,11 @@
                    messageNascentAdapter.setList(mList);
                    messageNascentAdapter.notifyDataSetChanged();
                }
                //显示发生中消息总数量
                refreshNascentCount();
                //显示没数据Ui样式
                nullDataUpdateUi();
                //显示未读信息总数量
                getUnreadCount();
                //显示没数据Ui样式
                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);
                        }
                    }
                }
            }
@@ -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);
                }
            }
        });
    }