mac
2024-03-15 82e8cfb24eed54690cdee39831ed266418cbd7dd
app/src/main/java/com/hdl/photovoltaic/ui/newC/MessageCenterList.java
@@ -11,8 +11,7 @@
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.photovoltaic.R;
import com.hdl.photovoltaic.base.CustomBaseActivity;
@@ -26,9 +25,11 @@
import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.other.HdlMessageLogic;
import com.hdl.photovoltaic.other.HdlThreadLogic;
import com.hdl.photovoltaic.other.HdlUniLogic;
import com.hdl.photovoltaic.ui.bean.MessageBean;
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.sdk.link.core.bean.eventbus.BaseEventBus;
@@ -71,6 +72,8 @@
    @Override
    public void onBindView(Bundle savedInstanceState) {
        setNotificationBarBackgroundColor(CustomColor.white);
        setStatusBarTextColor();
        //初始化数据
        initData();
        //初始化
@@ -81,12 +84,25 @@
        loadNextPageMessageList(1, true, FilterType.all, FilterType.all);
    }
    @Override
    protected void onResume() {
        super.onResume();
        //进来读取一次数据(为了更新currentPage,currentTotal这个值)
//        loadNextPageMessageList(1, true, mFilterKye, mFilterValue);
    }
    private void initEvent() {
        //返回按钮
        viewBinding.toolbarTopMessageCenterListRl.topBackBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                clearCacheData();
                HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
                uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_REFRESH_USERINFO);
                JsonObject jsonObject = new JsonObject();
                jsonObject.addProperty("homeId", UserConfigManage.getInstance().getHomeId());
                uniCallBackBaseBean.setData(jsonObject);
                HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_REFRESH_REFRESH_UNREAD_NUMBER, uniCallBackBaseBean);
                finish();
            }
        });
@@ -99,7 +115,8 @@
                    @Override
                    public void onSuccess(Boolean obj) {
                        hideLoading();
                        loadNextPageMessageList(1, true, mFilterKye, mFilterValue);
                        HdlMessageLogic.getInstance().setAllRead(true);
                        updateListData();
                    }
                    @Override
@@ -304,7 +321,7 @@
        } else {
            messageStateType = MessageStateType.processed;
        }
        HdlMessageLogic.getInstance().getPageNoMessageList_C(pageNo, messageStateType, filter_key, filter_value, new CloudCallBeak<HdlMessageLogic.MessageListClass>() {
        HdlMessageLogic.getInstance().getPageNoMessageList_C(UserConfigManage.getInstance().getHomeId(), pageNo, messageStateType, filter_key, filter_value, new CloudCallBeak<HdlMessageLogic.MessageListClass>() {
            @Override
            public void onSuccess(HdlMessageLogic.MessageListClass messageListClass) {
                if (messageListClass != null) {
@@ -337,42 +354,6 @@
        });
    }
    /**
     * 读取消息【未读数量】
     */
    private void getUnreadCount() {
        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");
                            refreshCount();
                        }
                        if (jsonObject.containsKey("unreadCount")) {
                            //未读数量
                            String unreadCount = jsonObject.getString("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);
                }
            }
        });
    }
@@ -571,4 +552,19 @@
        }
        return stringList;
    }
    /**
     * 物理按键返回事件
     */
    @Override
    public void onBackPressed() {
        clearCacheData();
        HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
        uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_REFRESH_REFRESH_UNREAD_NUMBER);
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("homeId", UserConfigManage.getInstance().getHomeId());
        uniCallBackBaseBean.setData(jsonObject);
        HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
        super.onBackPressed();
    }
}