@Override
    public int getItemCount() {
      int count = mInternalAdapter.getItemCount();
      if (mIsFooterEnable) count++;

      return count;
    }
 private void doRestoreState(Adapter adapter) {
   if (stateRestored || adapter == null || adapter.getItemCount() == 0) return;
   stateRestored = true;
   if (delayedState != null) {
     super.onRestoreInstanceState(delayedState);
     delayedState = null;
   }
 }
  /** invalidate the empty view's presentation. */
  public void invalidateEmptyView() {
    isEmptyViewCreated = false;
    emptyBox.removeAllViews();

    // if the empty view was displayed, it will refresh it.
    if (0 == listAdapter.getItemCount()) {
      showEmptyView();
    }
  }
Beispiel #4
0
 @Override
 public void onChanged() {
   Adapter<?> adapter = getAdapter();
   if (adapter != null && emptyView != null) {
     if (adapter.getItemCount() == 0) {
       emptyView.setVisibility(View.VISIBLE);
       MyRecyclerView.this.setVisibility(View.GONE);
     } else {
       emptyView.setVisibility(View.GONE);
       MyRecyclerView.this.setVisibility(View.VISIBLE);
     }
   }
 }
  /** notify the list data was changed. so refresh the list. */
  public void notifyDataSetChanged() {
    if (refreshLayout.isRefreshing()) {
      refreshLayout.setRefreshing(false);
    }

    if (0 == listAdapter.getItemCount()
        && (null == getDataProvider() || getDataProvider().isLastPage())) {
      showEmptyView();
    } else {
      hideEmptyView();
    }

    listAdapter.notifyDataSetChanged();
  }