|
|
|
@ -407,7 +407,15 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (fromId != null || adapter.getItemCount() <= 1) { |
|
|
|
|
setFooterState(FooterViewHolder.State.LOADING); |
|
|
|
|
/* When this is called by the EndlessScrollListener it cannot refresh the footer state |
|
|
|
|
* using adapter.notifyItemChanged. So its necessary to postpone doing so until a |
|
|
|
|
* convenient time for the UI thread using a Runnable. */ |
|
|
|
|
recyclerView.post(new Runnable() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
adapter.setFooterState(FooterViewHolder.State.LOADING); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Callback<List<Account>> cb = new Callback<List<Account>>() { |
|
|
|
@ -468,9 +476,9 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi |
|
|
|
|
} |
|
|
|
|
fulfillAnyQueuedFetches(fetchEnd); |
|
|
|
|
if (accounts.size() == 0 && adapter.getItemCount() == 1) { |
|
|
|
|
setFooterState(FooterViewHolder.State.EMPTY); |
|
|
|
|
adapter.setFooterState(FooterViewHolder.State.EMPTY); |
|
|
|
|
} else { |
|
|
|
|
setFooterState(FooterViewHolder.State.END); |
|
|
|
|
adapter.setFooterState(FooterViewHolder.State.END); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -479,20 +487,6 @@ public class AccountListFragment extends BaseFragment implements AccountActionLi |
|
|
|
|
fulfillAnyQueuedFetches(fetchEnd); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* This needs to be called from the endless scroll listener, which does not allow notifying the |
|
|
|
|
* adapter during the callback. So, this is the workaround. */ |
|
|
|
|
private void setFooterState(FooterViewHolder.State state) { |
|
|
|
|
// Set the adapter to set its state when it's bound, if the current Footer is offscreen.
|
|
|
|
|
adapter.setFooterState(state); |
|
|
|
|
// Check if it's onscreen, and update it directly if it is.
|
|
|
|
|
RecyclerView.ViewHolder viewHolder = |
|
|
|
|
recyclerView.findViewHolderForAdapterPosition(adapter.getItemCount() - 1); |
|
|
|
|
if (viewHolder != null) { |
|
|
|
|
FooterViewHolder holder = (FooterViewHolder) viewHolder; |
|
|
|
|
holder.setState(state); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void onRefresh() { |
|
|
|
|
fetchAccounts(null, adapter.getTopId(), FetchEnd.TOP); |
|
|
|
|
} |
|
|
|
|