| | |
| | | |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.graphics.Typeface; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.os.Looper; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.other.HdlUniLogic; |
| | | import com.hdl.photovoltaic.ui.bean.MessageBean; |
| | | import com.hdl.photovoltaic.ui.bean.UnCountBean; |
| | | 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.photovoltaic.widget.refreshlayout.BGARefreshLayout; |
| | | import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | |
| | | import org.greenrobot.eventbus.Subscribe; |
| | |
| | | * C端消息中心列表 |
| | | */ |
| | | public class MessageCenterList extends CustomBaseActivity { |
| | | |
| | | private Handler handler; |
| | | private Runnable delayedRunnable; |
| | | |
| | | private ActivityMessageCenterListBinding viewBinding; |
| | | |
| | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setStatusBarTranslucent(); |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_FF333738)); |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_FF1C1C1E)); |
| | | //初始化数据 |
| | | initData(); |
| | | //初始化 |
| | | initView(); |
| | | //初始化界面监听器 |
| | | initEvent(); |
| | | getUnreadCount(); |
| | | //进来读取一次数据(为了更新currentPage,currentTotal这个值) |
| | | loadNextPageMessageList(1, true, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | protected void onResume() { |
| | | super.onResume(); |
| | | //进来读取一次数据(为了更新currentPage,currentTotal这个值) |
| | | // loadNextPageMessageList(1, true, mFilterKye, mFilterValue); |
| | | } |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | if (handler != null && delayedRunnable != null) { |
| | | handler.removeCallbacks(delayedRunnable); |
| | | } |
| | | super.onDestroy(); |
| | | } |
| | | |
| | | private void initEvent() { |
| | |
| | | |
| | | } |
| | | }); |
| | | |
| | | //下拉按钮 |
| | | 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 |
| | |
| | | viewBinding.toolbarTopMessageCenterListRl.topBackLl.setVisibility(View.VISIBLE); |
| | | viewBinding.toolbarTopMessageCenterListRl.topTitleTv.setText(R.string.set_message_center); |
| | | viewBinding.toolbarTopMessageCenterListRl.topMoreBtn.setVisibility(View.VISIBLE); |
| | | viewBinding.toolbarTopMessageCenterListRl.topMoreIv.setImageResource(R.drawable.clearall); |
| | | viewBinding.toolbarTopMessageCenterListRl.topMoreIv.setImageResource(R.drawable.clear_all); |
| | | //默认选中全部设备 |
| | | viewBinding.allDeviceTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.down); |
| | |
| | | viewBinding.messageContentRl.setAdapter(messageCenterListAdapter); |
| | | messageCenterListAdapter.setList(mList); |
| | | // this.nullDataUpdateUi(); |
| | | pullToRefresh(); |
| | | } |
| | | |
| | | |
| | | private void initData() { |
| | | try { |
| | |
| | | } |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 下拉刷新的逻辑 |
| | | */ |
| | | protected void pullToRefresh() { |
| | | viewBinding.messageContentSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() { |
| | | @Override |
| | | public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) { |
| | | handler = new Handler(Looper.getMainLooper()); |
| | | |
| | | delayedRunnable = new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | viewBinding.messageContentSrl.endRefreshing(); |
| | | loadNextPageMessageList(1, false, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue); |
| | | } |
| | | }; |
| | | // 延迟 5 秒执行 |
| | | handler.postDelayed(delayedRunnable, 1000); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) { |
| | | |
| | | handler = new Handler(Looper.getMainLooper()); |
| | | delayedRunnable = new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | viewBinding.messageContentSrl.endLoadingMore(); |
| | | if (!isLoadingMore) { |
| | | // 滑动到了底部,执行相应的操作 |
| | | HdlLogLogic.print("--->滑动到了底部"); |
| | | loadNextPageMessageList(++mCurrentPage, false, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue); |
| | | } |
| | | } |
| | | }; |
| | | // 延迟 5 秒执行 |
| | | handler.postDelayed(delayedRunnable, 10); |
| | | |
| | | return true; |
| | | } |
| | | }); |
| | | HDLRefreshViewHolder hdlRefreshViewHolder = new HDLRefreshViewHolder(_mActivity, true); |
| | | hdlRefreshViewHolder.setPullDownImageResource(R.mipmap.loading_44); |
| | | hdlRefreshViewHolder.setChangeToReleaseRefreshAnimResId(R.drawable.loading_refresh); |
| | | hdlRefreshViewHolder.setRefreshingAnimResId(R.drawable.loading_refresh_end); |
| | | viewBinding.messageContentSrl.setRefreshViewHolder(hdlRefreshViewHolder); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (isShowLoading) { |
| | | hideLoading(); |
| | | } |
| | | HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 读取消息【未读数量,未处理总数量,已处理总数量】 |
| | | */ |
| | | private void getUnreadCount() { |
| | | HdlMessageLogic.getInstance().getMessageUntreatedCount(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<UnCountBean>() { |
| | | @Override |
| | | public void onSuccess(UnCountBean unCountBean) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (unCountBean == null) { |
| | | return; |
| | | } |
| | | mTotalCount1 = unCountBean.getUntreatedCount(); |
| | | mTotalCount2 = unCountBean.getProcessedCount(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) |
| | | public void onEventMessage(BaseEventBus eventBus) { |