Exemplo n.º 1
0
  @Override
  protected Parcelable onSaveInstanceState() {
    Parcelable superState = super.onSaveInstanceState();

    SavedState ss = new SavedState(superState);
    ss.message = message.getText().toString();
    ss.refreshing = swipeRefreshLayout.isRefreshing();
    ss.loading = mAdapter.isLoading();
    ss.resources = new ArrayList<>(mAdapter.getResources());
    return ss;
  }
Exemplo n.º 2
0
 @Override
 public void showFirstLoading() {
   if (mAdapter.getItemCount() > 0) {
     swipeRefreshLayout.setRefreshing(true);
   } else {
     message.setVisibility(View.VISIBLE);
     message.setText(R.string.loading_msg);
   }
 }
Exemplo n.º 3
0
  @Override
  protected void onRestoreInstanceState(Parcelable state) {
    if (!(state instanceof SavedState)) {
      super.onRestoreInstanceState(state);
      return;
    }

    SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());

    mAdapter.setResource(ss.resources);
    if (ss.loading) {
      mAdapter.showLoading();
    }
    swipeRefreshLayout.setRefreshing(ss.refreshing);
    message.setText(ss.message);

    mInited = true;
  }
Exemplo n.º 4
0
 @Override
 public void hideLoading() {
   swipeRefreshLayout.setRefreshing(false);
   message.setVisibility(View.GONE);
   mAdapter.hideLoading();
 }
Exemplo n.º 5
0
 @Override
 public void showNextLoading() {
   mAdapter.showLoading();
 }
Exemplo n.º 6
0
 @Override
 public void updateResource(int id) {
   mAdapter.notifyItemChangedById(id);
 }
Exemplo n.º 7
0
 @Override
 public void showError() {
   mAdapter.setResource(new ArrayList<Resource>());
 }
Exemplo n.º 8
0
 @Override
 public void showResources(List<Resource> resources) {
   mAdapter.setResource(resources);
 }