Add EventHub, add fav, reblog events, improve timelines (#562)
* Add AppStore, add fav, reblog events * Add events, add handling to Timeline * Add event handling to Notifications * Mostly finish events * Fix unsubscribing * Cleanup timeline * Fix newStatusEvent in thread, fix deleteEvent * Insert new toots only in specific timelines * Add missing else * Rename AppStore to EventHub * Fix tests * Use DiffUtils for timeline * Fix empty timeline bug. Improve loading placeholder * Fix AsyncListDiff, loading indicator, "load more" * Timeline fixes & improvements. Fix infinite loading. Remove spinner correctly. Don't refresh timeline without need.
This commit is contained in:
parent
3a8d96346b
commit
3756a1fd20
31 changed files with 1064 additions and 542 deletions
|
@ -20,18 +20,12 @@ import android.support.v7.widget.RecyclerView;
|
|||
|
||||
public abstract class EndlessOnScrollListener extends RecyclerView.OnScrollListener {
|
||||
private static final int VISIBLE_THRESHOLD = 15;
|
||||
private int currentPage;
|
||||
private int previousTotalItemCount;
|
||||
private boolean loading;
|
||||
private int startingPageIndex;
|
||||
private LinearLayoutManager layoutManager;
|
||||
|
||||
public EndlessOnScrollListener(LinearLayoutManager layoutManager) {
|
||||
this.layoutManager = layoutManager;
|
||||
currentPage = 0;
|
||||
previousTotalItemCount = 0;
|
||||
loading = true;
|
||||
startingPageIndex = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,28 +33,21 @@ public abstract class EndlessOnScrollListener extends RecyclerView.OnScrollListe
|
|||
int totalItemCount = layoutManager.getItemCount();
|
||||
int lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition();
|
||||
if (totalItemCount < previousTotalItemCount) {
|
||||
currentPage = startingPageIndex;
|
||||
previousTotalItemCount = totalItemCount;
|
||||
if (totalItemCount == 0) {
|
||||
loading = true;
|
||||
}
|
||||
|
||||
}
|
||||
if (loading && totalItemCount > previousTotalItemCount) {
|
||||
loading = false;
|
||||
if (totalItemCount != previousTotalItemCount) {
|
||||
previousTotalItemCount = totalItemCount;
|
||||
}
|
||||
if (!loading && lastVisibleItemPosition + VISIBLE_THRESHOLD > totalItemCount) {
|
||||
currentPage++;
|
||||
onLoadMore(currentPage, totalItemCount, view);
|
||||
loading = true;
|
||||
|
||||
if (lastVisibleItemPosition + VISIBLE_THRESHOLD > totalItemCount) {
|
||||
onLoadMore(totalItemCount, view);
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
currentPage = startingPageIndex;
|
||||
previousTotalItemCount = 0;
|
||||
loading = true;
|
||||
}
|
||||
|
||||
public abstract void onLoadMore(int page, int totalItemsCount, RecyclerView view);
|
||||
public abstract void onLoadMore(int totalItemsCount, RecyclerView view);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue