其他分享
首页 > 其他分享> > RxView防抖,解决多次点击问题,多次点击只产生一次请求,防抖动

RxView防抖,解决多次点击问题,多次点击只产生一次请求,防抖动

作者:互联网

 1         RxView.clicks(cb_all).throttleFirst(2000, TimeUnit.MICROSECONDS).subscribe(aVoid -> {
 2             if (cb_all.isChecked()) {
 3                 mSelectedTicketDownInfoBeans.clear();
 4                 if (mTicketDownInfoBeans.size() > 0){
 5                     mSelectedTicketDownInfoBeans.addAll(mTicketDownInfoBeans);
 6                 }else {
 7                     mSelectedTicketDownInfoBeans.addAll(allTypeTickets);
 8                 }
 9             } else {
10                 mSelectedTicketDownInfoBeans.clear();
11                 //allTypeTickets存储到数据库的表中
12 
13             }
14 
15             tv_selected.setText("已选" + mSelectedTicketDownInfoBeans.size() + "项");
16 
17             for (TicketDownInfoBean ticketDownInfoBean : mTicketDownInfoBeans) {
18                 ticketDownInfoBean.setCheck(cb_all.isChecked());
19             }
20             mSelectedTicketDownInfoBeans = new ArrayList(new HashSet(mSelectedTicketDownInfoBeans));
21             mTicketAdapter.setList(mTicketDownInfoBeans);
22             mTicketAdapter.notifyDataSetChanged();
23         });

 

标签:防抖,mSelectedTicketDownInfoBeans,RxView,cb,isChecked,点击,mTicketDownInfoBeans,size
来源: https://www.cnblogs.com/YangBinChina/p/15253873.html