コード例 #1
0
  public void getDataTask(final boolean isClear) {
    if (mLoadingFooter.getState() == LoadingFooter.State.Loading
        || (!isClear && mLoadingFooter.getState() == LoadingFooter.State.TheEnd)) {
      return;
    }
    mLoadingFooter.setState(LoadingFooter.State.Loading);

    view.postDelayed(
        new Runnable() {
          @Override
          public void run() {
            refreshComplete();
            recyclerAdapter.setFooterView(mLoadingFooter);
            if (isClear) {
              recyclerAdapter.clear();
            }
            List<RecyclerBean> result = getData();
            if (result == null || result.size() < size) {
              mLoadingFooter.setState(LoadingFooter.State.TheEnd, false);
              recyclerAdapter.removeFooterView();
            } else {
              mLoadingFooter.setState(LoadingFooter.State.Normal);
            }
            if (result != null && result.size() > 0) {
              recyclerAdapter.addAll(result);
              lastPosition = lastPosition + result.size();
            }
          }
        },
        1000);
  }