Reputation: 1457
I have TabView
with 3 Tab in MainActivity
.I have set data on Tab1 using RecyclerView
. Recyclerview is in SwipeRefreshView
.When I pull to refresh recyclerview and at same time within second I changed tab the data in RecyclerView at Tab1 get double,triple.How to resolve this to avoid data duplication on Pull to refresh.
This is code to Pull to refresh
pullRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
String NetworkStatus = biz.fyra.bookapp.utils.NetworkStatus.checkConnection(getContext());
if (NetworkStatus.equals("false")) {
pullRefresh.setEnabled(false);
pullRefresh.setRefreshing(false);
} else {
pullRefresh.setEnabled(true);
//pullRefresh.setRefreshing(true);
db.deleteAllQueueFoodieDB();
checkInternet();
}
}
}, 1000);
}
});
Upvotes: 0
Views: 154
Reputation: 592
Call arraylist.clear()
method and recyclerView will not repeat its content after refresh.
Basically arraylist.clear()
removes all the elements from arraylist.
Upvotes: 2