| | |
| | | import android.annotation.SuppressLint; |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.os.AsyncTask; |
| | | import android.os.Bundle; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | |
| | | import com.hdl.photovoltaic.ui.bean.UnCountBean; |
| | | import com.hdl.photovoltaic.widget.BTypeTitleListDialog; |
| | | 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.EventBus; |
| | |
| | | viewBinding.allClearIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | showLoading(); |
| | | // showLoading(); |
| | | HdlMessageLogic.getInstance().messageAllRead("", new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | hideLoading(); |
| | | // hideLoading(); |
| | | loadNextPageMessageList(true, 1, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue, true); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | hideLoading(); |
| | | // hideLoading(); |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | |
| | | viewBinding.allGradeTitleIv.setBackgroundResource(R.drawable.down); |
| | | viewBinding.allTimeTitleIv.setBackgroundResource(R.drawable.up); |
| | | setTypeTitleListDialog(viewBinding.allTimeTitleTv, FilterType.timeType, getTypeList(FilterType.timeType)); |
| | | } |
| | | }); |
| | | |
| | | //下拉按钮 |
| | | viewBinding.messageSrl.setColorSchemeResources(R.color.text_FF245EC3); |
| | | viewBinding.messageSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
| | | @Override |
| | | public void onRefresh() { |
| | | viewBinding.messageSrl.setRefreshing(false); |
| | | loadNextPageMessageList(true, 1, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue, true); |
| | | } |
| | | }); |
| | | //上拉按钮 |
| | | viewBinding.messageRcv.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(false, ++mCurrentPage, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue, false); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | if (mMessageAdapter != null) { |
| | |
| | | mMessageAdapter = new MessageAdapter(_mActivity); |
| | | viewBinding.messageRcv.setLayoutManager(new LinearLayoutManager(_mActivity)); |
| | | viewBinding.messageRcv.setAdapter(mMessageAdapter); |
| | | pullToRefresh(); |
| | | } |
| | | |
| | | /** |
| | | * 下拉刷新的逻辑 |
| | | */ |
| | | protected void pullToRefresh() { |
| | | viewBinding.messageSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() { |
| | | @Override |
| | | public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) { |
| | | new AsyncTask<Void, Void, Void>() { |
| | | |
| | | @Override |
| | | protected Void doInBackground(Void... params) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected void onPostExecute(Void aVoid) { |
| | | // 执行任务(如更新UI、跳转等) |
| | | viewBinding.messageSrl.endRefreshing(); |
| | | loadNextPageMessageList(false, 1, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue, true); |
| | | |
| | | } |
| | | }.execute(); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) { |
| | | new AsyncTask<Void, Void, Void>() { |
| | | @Override |
| | | protected Void doInBackground(Void... params) { |
| | | try { |
| | | Thread.sleep(10); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected void onPostExecute(Void aVoid) { |
| | | viewBinding.messageSrl.endLoadingMore(); |
| | | //加载最新数据完成 |
| | | if (!isLoadingMore) { |
| | | // 滑动到了底部,执行相应的操作 |
| | | loadNextPageMessageList(false, ++mCurrentPage, mDeviceTypeFilterKye, mDeviceTypeFilterValue, mTypeFilterKye, mTypeFilterValue, mTimeTypeFilterKye, mTimeTypeFilterValue, false); |
| | | } |
| | | } |
| | | }.execute(); |
| | | 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.messageSrl.setRefreshViewHolder(hdlRefreshViewHolder); |
| | | } |
| | | |
| | | |
| | | private void initData() { |
| | | //进来读取一次数据(为了更新currentPage,currentTotal这个值),app启动时候读取,为了刷新消息模块的角标 |
| | |
| | | return; |
| | | } |
| | | refreshUnreadCount(unCountBean.getUnreadCount()); |
| | | if (isRefreshTotalCount) { |
| | | isRefreshTotalCount = false; |
| | | refreshNascentTotalCount(unCountBean.getUntreatedCount()); |
| | | refreshRecoverTotalCount(unCountBean.getProcessedCount()); |
| | | } |
| | | // if (isRefreshTotalCount) { |
| | | // isRefreshTotalCount = false; |
| | | refreshNascentTotalCount(unCountBean.getUntreatedCount()); |
| | | refreshRecoverTotalCount(unCountBean.getProcessedCount()); |
| | | // } |
| | | } |
| | | |
| | | }); |