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)); } } }
@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); }
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); }
private void setCommentsRefreshing(boolean refreshing, boolean loadMore) { mAdapter.setProgressVisible(refreshing && (mCommentAdapter.getItemCount() == 0 || loadMore)); }