private void getOlderTweets() { long max_id = 0; if (!mAdapter.isEmpty()) { max_id = mAdapter.getItem(mAdapter.getCount() - 1).getId(); } new UserFeedsRequest(mActivity, mScreenName, 0, max_id) { public void onPreExecute() {}; public void onCallBack(String url, Tweet[] result, AjaxStatus status) { mListview.showList(); mListview.hideMoreProgress(); if (result != null) { if (result.length < Constants.TWEETS_COUNT) { mListview.setLoadingMore(false); } mAdapter.addTweets(result); } else { Toast.makeText(mActivity, "Failed to get more feeds", Toast.LENGTH_SHORT).show(); } }; }.get(); }
private void getNewTweets() { long since_id = 0; if (!mAdapter.isEmpty()) { since_id = mAdapter.getItem(0).getId(); } new UserFeedsRequest(mActivity, mScreenName, since_id, 0) { public void onPreExecute() { if (mAdapter.getCount() <= 0) { mListview.showProgress(); } }; public void onCallBack(String url, Tweet[] result, AjaxStatus status) { if (result != null) { mAdapter.insertTweets(0, result); mListview.showList(); } else { if (mAdapter.isEmpty()) { DialogsManager.showRetryRequestDialog( mActivity, this, RequestType.GET, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mAdapter.isEmpty()) { dialog.dismiss(); mActivity.finish(); } } }); } else { mListview.getSwipeToRefresh().setRefreshing(false); DialogsManager.showToast(mActivity, "Failed to get new tweets."); } } }; }.get(); }