private void initData() { startProgressDialog(); UserInfoDataprovider.getInstance().addOnRequestedListener(mOnUserInfoRequestedListener); mTaskCount++; TweetsDataprovider.getInstance().addOnRequestedListener(mOnTweetsRequestedListener); mTaskCount++; mMomentsListView.setOnLoadListener(this); mMomentsListView.setOnRefreshListener(this); }
/** 初始化Moments列表数据 */ private void initMomentsListData() { // 第一次最多加载5条数据 if (mAllTweets.size() >= mLastPos + MomentsListView.DEFAULT_LOAD_COUNT) { mCurrentShowTweets.addAll(mAllTweets.subList(mLastPos, MomentsListView.DEFAULT_LOAD_COUNT)); } else { mCurrentShowTweets.addAll(mAllTweets.subList(mLastPos, mAllTweets.size())); } mLastPos = mCurrentShowTweets.size() - 1; mCommentsAdapter = new MomentsAdapter(this, mCurrentShowTweets); mMomentsListView.setAdapter(mCommentsAdapter); mMomentsListView.setResultSize(mLastPos + 1); }
@Override public void onRequested(UserInfo info, VolleyError error) { // 网络任务结束,计数器-1 mTaskCount--; // 计数器<=0时,说明网络任务结束,此时需要隐藏进度框 if (mTaskCount <= 0) { stopProgressDialog(); } Log.d(TAG, "info = " + info + ",error = " + error); mMomentsListView.setUserInfo(info); }