| | |
| | | package com.hdl.photovoltaic.ui.newC; |
| | | |
| | | |
| | | import android.annotation.SuppressLint; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.recyclerview.widget.LinearLayoutManager; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonObject; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | | import com.hdl.photovoltaic.config.ConstantManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.ActivityMessageCenterListBinding; |
| | | import com.hdl.photovoltaic.enums.FilterType; |
| | | import com.hdl.photovoltaic.enums.MessageStateType; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | 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; |
| | | |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * C端消息中心列表 |
| | |
| | | private boolean isAlarmDeviceClick = true;//true表示告警设备被选中,则false表示报警记录被选中 |
| | | |
| | | private final List<MessageBean> mList = new ArrayList<>(); |
| | | private int currentPage = 0; // 当前页码 |
| | | private int currentTotal = 0; // 总页码 |
| | | private int mCurrentPage = 0; // 当前页码 |
| | | private int mCurrentTotal = 0; // 总页码 |
| | | |
| | | private int mTotalCount1 = 0;//消息数量总数 |
| | | |
| | | private int mTotalCount2 = 0;//消息数量总数 |
| | | private String mDeviceTypeFilterKye = FilterType.all;//过滤类型 deviceType(INV :逆变器;BMS :BMS控制盒;BATTERY :电池单元) |
| | | private String mDeviceTypeFilterValue = FilterType.all;//过滤类型值 deviceType(INV :逆变器;BMS :BMS控制盒;BATTERY :电池单元) |
| | | |
| | | private String mTypeFilterKye = FilterType.all;//过滤类型 type(FAULT :故障; WARN :告警; EVENT :事件(提示)); |
| | | private String mTypeFilterValue = FilterType.all;//过滤类型值 type(FAULT :故障; WARN :告警; EVENT :事件(提示)); |
| | | |
| | | private String mTimeTypeFilterKye = FilterType.all;//过滤类型 timeType(TODAY :今天;LAST_3_DAYS: 近3天;LAST_7_DAYS :近7天;LAST_30_DAYS :近30天); |
| | | private String mTimeTypeFilterValue = FilterType.all;//过滤类型值 timeType(TODAY :今天;LAST_3_DAYS: 近3天;LAST_7_DAYS :近7天;LAST_30_DAYS :近30天); |
| | | |
| | | |
| | | //deviceType_filter_value deviceType(INV :逆变器;BMS :BMS控制盒;BATTERY :电池单元); |
| | | // * type(FAULT :故障; WARN :告警; EVENT :事件(提示)); |
| | | // * timeType(TODAY :今天;LAST_3_DAYS: 近3天;LAST_7_DAYS :近7天;LAST_30_DAYS :近30天); |
| | | private boolean isLoadingMore = false; // 标记正在加载更多数据 |
| | | LinearLayoutManager mLayoutManager; |
| | | |
| | | LinearLayoutManager layoutManager; |
| | | |
| | | @Override |
| | | public Object getContentView() { |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setNotificationBarBackgroundColor(CustomColor.white); |
| | | setStatusBarTextColor(); |
| | | //初始化数据 |
| | | initData(); |
| | | //初始化 |
| | |
| | | //初始化界面监听器 |
| | | initEvent(); |
| | | //进来读取一次数据(为了更新currentPage,currentTotal这个值) |
| | | loadNextPageNascentMessageList(1, true); |
| | | loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue); |
| | | } |
| | | |
| | | @Override |
| | | protected void onResume() { |
| | | super.onResume(); |
| | | //进来读取一次数据(为了更新currentPage,currentTotal这个值) |
| | | // loadNextPageMessageList(1, true, mFilterKye, mFilterValue); |
| | | } |
| | | |
| | | private void initEvent() { |
| | | //返回按钮 |
| | | viewBinding.toolbarTopMessageCenterListRl.topBackBtn.setOnClickListener(new View.OnClickListener() { |
| | | viewBinding.toolbarTopMessageCenterListRl.topBackLl.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_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); |
| | | finish(); |
| | | } |
| | | }); |
| | | //清空所有未读按钮 |
| | | viewBinding.toolbarTopMessageCenterListRl.topMoreBtn.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | showLoading(); |
| | | HdlMessageLogic.getInstance().messageAllRead(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | hideLoading(); |
| | | loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue); |
| | | // HdlMessageLogic.getInstance().setAllRead(true); |
| | | // updateListData(); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | hideLoading(); |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | |
| | | viewBinding.messageTabAllDeviceCl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | List<String> stringList = new ArrayList<>(); |
| | | stringList.add(getString(R.string.alarm_all_device)); |
| | | 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)); |
| | | TypeTitleListDialog typeTitleListDialog = new TypeTitleListDialog(_mActivity, stringList); |
| | | viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.up); |
| | | viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.down); |
| | | List<String> stringList = getTypeList(FilterType.deviceType); |
| | | TypeTitleListDialog typeTitleListDialog = new TypeTitleListDialog(_mActivity, stringList, viewBinding.allDeviceTitleTv.getText().toString()); |
| | | typeTitleListDialog.show(); |
| | | typeTitleListDialog.setOnListener(new TypeTitleListDialog.OnClickListener() { |
| | | @Override |
| | | public void onClick(int position, String title) { |
| | | viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.up); |
| | | |
| | | viewBinding.allDeviceTitleTv.setText(title); |
| | | mDeviceTypeFilterKye = FilterType.deviceType; |
| | | mDeviceTypeFilterValue = findFilterValueString(title); |
| | | loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue); |
| | | |
| | | } |
| | | }); |
| | | typeTitleListDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { |
| | | @Override |
| | | public void onDismiss(DialogInterface dialog) { |
| | | viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allDeviceTitleTv.setText(title); |
| | | } |
| | | }); |
| | | |
| | |
| | | viewBinding.messageTabAllGradeCl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | List<String> stringList = new ArrayList<>(); |
| | | stringList.add(getString(R.string.alarm_all_grade)); |
| | | stringList.add(getString(R.string.alarm_all_grade_malfunction)); |
| | | stringList.add(getString(R.string.alarm_all_grade_warning)); |
| | | stringList.add(getString(R.string.alarm_all_grade_tip)); |
| | | TypeTitleListDialog typeTitleListDialog = new TypeTitleListDialog(_mActivity, stringList); |
| | | viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.up); |
| | | viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.down); |
| | | List<String> stringList = getTypeList(FilterType.type); |
| | | TypeTitleListDialog typeTitleListDialog = new TypeTitleListDialog(_mActivity, stringList, viewBinding.allGradeTitleTv.getText().toString()); |
| | | typeTitleListDialog.show(); |
| | | typeTitleListDialog.setOnListener(new TypeTitleListDialog.OnClickListener() { |
| | | @Override |
| | | public void onClick(int position, String title) { |
| | | viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.up); |
| | | viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allGradeTitleTv.setText(title); |
| | | mTypeFilterKye = FilterType.type; |
| | | mTypeFilterValue = findFilterValueString(title); |
| | | loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue); |
| | | } |
| | | }); |
| | | typeTitleListDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { |
| | | @Override |
| | | public void onDismiss(DialogInterface dialog) { |
| | | viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.down); |
| | | } |
| | | }); |
| | | } |
| | |
| | | viewBinding.messageTabAllTimeCl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | List<String> stringList = new ArrayList<>(); |
| | | stringList.add(getString(R.string.alarm_all_time)); |
| | | stringList.add(getString(R.string.alarm_all_time_same_day)); |
| | | stringList.add(getString(R.string.alarm_all_time_3)); |
| | | stringList.add(getString(R.string.alarm_all_time_7)); |
| | | stringList.add(getString(R.string.alarm_all_time_30)); |
| | | TypeTitleListDialog typeTitleListDialog = new TypeTitleListDialog(_mActivity, stringList); |
| | | viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.up); |
| | | List<String> stringList = getTypeList(FilterType.timeType); |
| | | TypeTitleListDialog typeTitleListDialog = new TypeTitleListDialog(_mActivity, stringList, viewBinding.allTimeTitleTv.getText().toString()); |
| | | typeTitleListDialog.show(); |
| | | typeTitleListDialog.setOnListener(new TypeTitleListDialog.OnClickListener() { |
| | | @Override |
| | | public void onClick(int position, String title) { |
| | | viewBinding.allTimeTitleTv.setText(title); |
| | | mTimeTypeFilterKye = FilterType.timeType; |
| | | mTimeTypeFilterValue = findFilterValueString(title); |
| | | loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue); |
| | | } |
| | | }); |
| | | typeTitleListDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { |
| | | @Override |
| | | public void onDismiss(DialogInterface dialog) { |
| | | viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.up); |
| | | viewBinding.allTimeTitleTv.setText(title); |
| | | viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.down); |
| | | } |
| | | }); |
| | | } |
| | |
| | | viewBinding.messageBottomAlarmDeviceCl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (isAlarmDeviceClick) { |
| | | return;//防止多次点击 |
| | | } |
| | | mDeviceTypeFilterKye = FilterType.all; |
| | | 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; |
| | | refreshBottomStyle(true); |
| | | loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue); |
| | | } |
| | | }); |
| | | //告警记录按钮 |
| | | viewBinding.messageBottomAlarmRecordCl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (!isAlarmDeviceClick) { |
| | | return;//防止多次点击 |
| | | } |
| | | mDeviceTypeFilterKye = FilterType.all; |
| | | 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; |
| | | 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) { |
| | | messageCenterListAdapter.setNoOnclickListener(new MessageCenterListAdapter.OnclickListener() { |
| | | @Override |
| | | public void onClick(int position, MessageBean messageBean) { |
| | | Intent intent = new Intent(); |
| | | intent.putExtra("messageBean", new Gson().toJson(messageBean)); |
| | | intent.setClass(_mActivity, MessageInfoActivity.class); |
| | | startActivity(intent); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void initView() { |
| | | viewBinding.toolbarTopMessageCenterListRl.getRoot().setBackgroundColor(getColor(R.color.text_FFFFFFFF)); |
| | | viewBinding.toolbarTopMessageCenterListRl.topBackBtn.setVisibility(View.VISIBLE); |
| | | 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.allDeviceTitleIv.setBackgroundResource(R.drawable.up); |
| | | viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.down); |
| | | refreshBottomStyle(true); |
| | | layoutManager = new LinearLayoutManager(_mActivity); |
| | | mLayoutManager = new LinearLayoutManager(_mActivity); |
| | | messageCenterListAdapter = new MessageCenterListAdapter(_mActivity); |
| | | viewBinding.messageContentRl.setLayoutManager(layoutManager); |
| | | viewBinding.messageContentRl.setLayoutManager(mLayoutManager); |
| | | viewBinding.messageContentRl.setAdapter(messageCenterListAdapter); |
| | | messageCenterListAdapter.setList(mList); |
| | | this.nullDataUpdateUi(); |
| | | } |
| | | |
| | | 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) { |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 加载一页数据 |
| | | * |
| | | * @param pageNo 页数 |
| | | * @param isShowLoading 是否启动加载框 true启动 |
| | | * @param pageNo 页数 |
| | | * @param isShowLoading 是否启动加载框 true启动 |
| | | * @param deviceType_filter_key 类型(设备,等级,时间) |
| | | * @param deviceType_filter_value deviceType(INV :逆变器;BMS :BMS控制盒;BATTERY :电池单元); |
| | | * type(FAULT :故障; WARN :告警; EVENT :事件(提示)); |
| | | * timeType(TODAY :今天;LAST_3_DAYS: 近3天;LAST_7_DAYS :近7天;LAST_30_DAYS :近30天); |
| | | */ |
| | | private void loadNextPageNascentMessageList(int pageNo, boolean isShowLoading) { |
| | | private void loadNextPageMessageList(int pageNo, boolean isShowLoading, |
| | | String deviceType_filter_key, String deviceType_filter_value, |
| | | String type_filter_key, String type_filter_value, |
| | | String timeType_filter_key, String timeType_filter_value) { |
| | | if (pageNo == 1) { |
| | | //表示从第一页可以读取,默认清空所有缓存数据; |
| | | clearCacheData(); |
| | | } |
| | | //第一页读取数据强制读 |
| | | if (pageNo > 1 && currentPage > currentTotal) { |
| | | --currentPage; |
| | | if (pageNo > 1 && mCurrentPage > mCurrentTotal) { |
| | | --mCurrentPage; |
| | | //当前页不能大于总页数 |
| | | return; |
| | | } |
| | |
| | | if (isShowLoading) { |
| | | showLoading(); |
| | | } |
| | | HdlMessageLogic.getInstance().getPageNoMessageList(pageNo, MessageStateType.untreated, new CloudCallBeak<HdlMessageLogic.MessageListClass>() { |
| | | @Override |
| | | public void onSuccess(HdlMessageLogic.MessageListClass messageListClass) { |
| | | if (messageListClass != null) { |
| | | currentTotal = (int) messageListClass.getTotalPage(); |
| | | currentPage = (int) messageListClass.getPageNo(); |
| | | updateListData(); |
| | | } |
| | | isLoadingMore = false; |
| | | if (isShowLoading) { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | if (currentPage > 1) { |
| | | --currentPage; |
| | | } |
| | | isLoadingMore = false; |
| | | if (isShowLoading) { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 读取消息【未读数量】 |
| | | */ |
| | | private void getUnreadCount() { |
| | | HdlMessageLogic.getInstance().getMessageUntreatedCount(new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String data) { |
| | | |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | String messageStateType; |
| | | if (isAlarmDeviceClick) { |
| | | messageStateType = MessageStateType.untreated; |
| | | } else { |
| | | messageStateType = MessageStateType.processed; |
| | | } |
| | | HdlMessageLogic.getInstance().getPageNoMessageList(UserConfigManage.getInstance().getHomeId(), pageNo, messageStateType, |
| | | deviceType_filter_key, deviceType_filter_value, |
| | | type_filter_key, type_filter_value, |
| | | timeType_filter_key, timeType_filter_value, |
| | | "", |
| | | new CloudCallBeak<HdlMessageLogic.MessageListClass>() { |
| | | @Override |
| | | public void run() { |
| | | JSONObject jsonObject = JSON.parseObject(data); |
| | | if (jsonObject.containsKey("untreatedCount")) { |
| | | //未处理数量 |
| | | String untreatedCount = jsonObject.getString("untreatedCount"); |
| | | refreshNascentCount(untreatedCount); |
| | | public void onSuccess(HdlMessageLogic.MessageListClass messageListClass) { |
| | | if (messageListClass != null) { |
| | | mCurrentTotal = (int) messageListClass.getTotalPage(); |
| | | mCurrentPage = (int) messageListClass.getPageNo(); |
| | | int totalCount = (int) messageListClass.getTotalCount(); |
| | | if (isAlarmDeviceClick) { |
| | | mTotalCount1 = totalCount; |
| | | } else { |
| | | mTotalCount2 = totalCount; |
| | | } |
| | | updateListData(); |
| | | } |
| | | if (jsonObject.containsKey("unreadCount")) { |
| | | //未读数量 |
| | | String unreadCount = jsonObject.getString("unreadCount"); |
| | | refreshUnreadNascentCount(unreadCount); |
| | | isLoadingMore = false; |
| | | if (isShowLoading) { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | if (mCurrentPage > 1) { |
| | | --mCurrentPage; |
| | | } |
| | | isLoadingMore = false; |
| | | if (isShowLoading) { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @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); |
| | | } |
| | | |
| | | |
| | | @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) |
| | | public void onEventMessage(BaseEventBus eventBus) { |
| | | super.onEventMessage(eventBus); |
| | | if (eventBus == null) { |
| | | return; |
| | | } |
| | | if (eventBus.getTopic().equals(ConstantManage.message_function_push_post)) { |
| | | if (eventBus.getType().equals(MessageStateType.untreated)) { |
| | | updateListData(); |
| | | } else if (eventBus.getType().equals(MessageStateType.processed)) { |
| | | if (mTotalCount1 > 0) { |
| | | mTotalCount1--; |
| | | mTotalCount2++; |
| | | } |
| | | updateListData(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 刷新信息数量总数 |
| | | */ |
| | | private void refreshNascentCount(String totalCount) { |
| | | private void refreshCount() { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | TextView textView = _mActivity.findViewById(R.id.message_bottom_alarm_device_title_tv); |
| | | if (textView != null) { |
| | | textView.setText(getText(R.string.alarm_device)); |
| | | if (!TextUtils.isEmpty(totalCount) && !totalCount.equals("0")) { |
| | | String s = getText(R.string.message_nascent) + "(" + totalCount + ")"; |
| | | textView.setText(s); |
| | | //设备报警总数量 |
| | | TextView textView1 = _mActivity.findViewById(R.id.message_bottom_alarm_device_title_tv); |
| | | if (textView1 != null) { |
| | | textView1.setText(getText(R.string.alarm_device)); |
| | | if (mTotalCount1 > 0) { |
| | | String s = getText(R.string.alarm_device) + "(" + mTotalCount1 + ")"; |
| | | textView1.setText(s); |
| | | } |
| | | } |
| | | //报警记录总数量 |
| | | TextView textView2 = _mActivity.findViewById(R.id.message_bottom_alarm_record_title_tv); |
| | | if (textView2 != null) { |
| | | textView2.setText(getText(R.string.alarm_record)); |
| | | if (mTotalCount2 > 0) { |
| | | String s = getText(R.string.alarm_record) + "(" + mTotalCount2 + ")"; |
| | | textView2.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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 刷新列表数据 |
| | | */ |
| | | private void updateListData() { |
| | |
| | | //读取缓存数据 |
| | | updateCacheData(); |
| | | //刷新列表 |
| | | if (messageCenterListAdapter != null) { |
| | | messageCenterListAdapter.setList(mList); |
| | | } |
| | | updateRecyclerViewList(); |
| | | //显示未读信息总数量 |
| | | getUnreadCount(); |
| | | refreshCount(); |
| | | //显示没数据Ui样式 |
| | | nullDataUpdateUi(); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 重新更新列表数据 |
| | | */ |
| | | private void updateRecyclerViewList() { |
| | | if (messageCenterListAdapter == null) { |
| | | return; |
| | | } |
| | | messageCenterListAdapter.setList(mList); |
| | | } |
| | | |
| | | /** |
| | | * 清空所有缓存数据(获取第一页之前要清空所有缓存数据) |
| | | */ |
| | | private void clearCacheData() { |
| | | mList.clear(); |
| | | HdlMessageLogic.getInstance().clearListMessage();//表示强制清空所有缓存信息 |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新缓存数据 |
| | | */ |
| | | private void updateCacheData() { |
| | | mList.clear(); |
| | | mList.addAll(HdlMessageLogic.getInstance().getNascentMessageMemoryList()); |
| | | if (isAlarmDeviceClick) { |
| | | //设备报警 |
| | | mList.addAll(HdlMessageLogic.getInstance().getNascentMessageMemoryList()); |
| | | } else { |
| | | //报警记录 |
| | | mList.addAll(HdlMessageLogic.getInstance().getRecoverMessageMemoryList()); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | private void nullDataUpdateUi() { |
| | | HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.nullDataIc.getRoot(), viewBinding.nullDataIc.nullDataGifAnimationIv, viewBinding.nullDataIc.nullDataTv, getString(R.string.message_alarm_data_null), mList.size() > 0); |
| | | } |
| | | |
| | | /** |
| | | * 查找过滤值 |
| | | * |
| | | * @param title 标题 |
| | | * @return 过滤值 |
| | | */ |
| | | public String findFilterValueString(String title) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put(getString(R.string.alarm_all_device), "");//设备全部 |
| | | 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"); |
| | | map.put(getString(R.string.alarm_all_grade_tip), "EVENT"); |
| | | map.put(getString(R.string.alarm_all_time), "");//时间全部 |
| | | map.put(getString(R.string.alarm_all_time_same_day), "TODAY"); |
| | | map.put(getString(R.string.alarm_all_time_3), "LAST_3_DAYS"); |
| | | map.put(getString(R.string.alarm_all_time_7), "LAST_7_DAYS"); |
| | | map.put(getString(R.string.alarm_all_time_30), "LAST_30_DAYS"); |
| | | |
| | | for (Map.Entry<String, String> entry : map.entrySet()) { |
| | | if (title.equals(entry.getKey())) { |
| | | return entry.getValue(); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 获取类型列表 |
| | | * |
| | | * @param filterType 过滤类型 |
| | | * @return 返回类型列表 |
| | | */ |
| | | private List<String> getTypeList(String filterType) { |
| | | List<String> stringList = new ArrayList<>(); |
| | | switch (filterType) { |
| | | case FilterType.deviceType: { |
| | | stringList.add(getString(R.string.alarm_all_device)); |
| | | 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: { |
| | | stringList.add(getString(R.string.alarm_all_grade)); |
| | | stringList.add(getString(R.string.alarm_all_grade_malfunction)); |
| | | stringList.add(getString(R.string.alarm_all_grade_warning)); |
| | | stringList.add(getString(R.string.alarm_all_grade_tip)); |
| | | } |
| | | break; |
| | | case FilterType.timeType: { |
| | | stringList.add(getString(R.string.alarm_all_time)); |
| | | stringList.add(getString(R.string.alarm_all_time_same_day)); |
| | | stringList.add(getString(R.string.alarm_all_time_3)); |
| | | stringList.add(getString(R.string.alarm_all_time_7)); |
| | | stringList.add(getString(R.string.alarm_all_time_30)); |
| | | } |
| | | break; |
| | | } |
| | | 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(); |
| | | } |
| | | } |