Exemplo n.º 1
0
 private void fixCommentCount() {
   Broadcast broadcast = mBroadcastAdapter.getBroadcast();
   if (broadcast != null) {
     int commentCount = mCommentAdapter.getItemCount();
     if (broadcast.commentCount < commentCount) {
       broadcast.commentCount = commentCount;
       EventBus.getDefault().post(new BroadcastUpdatedEvent(broadcast));
     }
   }
 }
Exemplo n.º 2
0
  @Override
  public void onStart() {
    super.onStart();

    // Only auto-load when initially empty, not loaded but empty.
    boolean autoLoadComments = mCommentAdapter.getItemCount() == 0 && mCanLoadMoreComments;
    if (mBroadcastAdapter.getItemCount() == 0) {
      loadBroadcast(autoLoadComments);
    } else if (autoLoadComments) {
      loadCommentList(false);
    }

    EventBus.getDefault().register(this);
  }
Exemplo n.º 3
0
  private void loadCommentList(boolean loadMore) {

    if (mLoadingBroadcastOrCommentList || (loadMore && !mCanLoadMoreComments)) {
      return;
    }

    Integer start = loadMore ? mCommentAdapter.getItemCount() : null;
    final int count = COMMENT_COUNT_PER_LOAD;
    ApiRequest<CommentList> request =
        ApiRequests.newBroadcastCommentListRequest(mBroadcastId, start, count, this);
    LoadCommentListState state = new LoadCommentListState(loadMore, count);
    RequestFragment.startRequest(REQUEST_CODE_LOAD_COMMENT_LIST, request, state, this);

    mLoadingBroadcastOrCommentList = true;
    setCommentsRefreshing(true, loadMore);
  }
Exemplo n.º 4
0
 private void setCommentsRefreshing(boolean refreshing, boolean loadMore) {
   mAdapter.setProgressVisible(refreshing && (mCommentAdapter.getItemCount() == 0 || loadMore));
 }