List of usage examples for twitter4j PagableResponseList getPreviousCursor
@Override
long getPreviousCursor();
From source file:com.dwdesign.tweetings.loader.UserListMembersLoader.java
License:Open Source License
@Override public List<ParcelableUser> getUsers() throws TwitterException { final Twitter twitter = getTwitter(); if (twitter == null) return null; final PagableResponseList<User> users; if (mListId > 0) { if (mUserListId <= 0) { mUserListId = mListId;/*from w ww . j a v a2s.co m*/ } if (mOwnerId <= 0) { final UserList list = twitter.showUserList(mListId); final User owner = list != null ? list.getUser() : null; mOwnerId = owner != null ? owner.getId() : -1; } users = twitter.getUserListMembers(mListId, mCursor); } else { final UserList list = findUserList(twitter, mUserId, mScreenName, mListName); if (list == null) return null; if (mOwnerId <= 0) { final User owner = list.getUser(); mOwnerId = owner != null ? owner.getId() : -1; } if (list != null && list.getId() > 0) { if (mUserListId <= 0) { mUserListId = list.getId(); } users = twitter.getUserListMembers(list.getId(), mCursor); } else return null; } mNextCursor = users.getNextCursor(); mPrevCursor = users.getPreviousCursor(); final List<ParcelableUser> result = new ArrayList<ParcelableUser>(); final int size = users.size(); for (int i = 0; i < size; i++) { result.add(new ParcelableUser(users.get(i), mAccountId, (mCursor + 1) * 20 + i)); } return result; }
From source file:com.dwdesign.tweetings.loader.UserListSubscribersLoader.java
License:Open Source License
@Override public List<ParcelableUser> getUsers() throws TwitterException { final Twitter twitter = getTwitter(); if (twitter == null) return null; final PagableResponseList<User> users; if (mListId > 0) { users = twitter.getUserListSubscribers(mListId, mCursor); } else {//from w ww.jav a 2 s .c om final UserList list = findUserList(twitter, mUserId, mScreenName, mListName); if (list != null && list.getId() > 0) { users = twitter.getUserListSubscribers(list.getId(), mCursor); } else return null; } mNextCursor = users.getNextCursor(); mPrevCursor = users.getPreviousCursor(); final List<ParcelableUser> result = new ArrayList<ParcelableUser>(); final int size = users.size(); for (int i = 0; i < size; i++) { result.add(new ParcelableUser(users.get(i), mAccountId, (mCursor + 1) * 20 + i)); } return result; }
From source file:com.marpies.ane.twitter.utils.UserUtils.java
License:Apache License
/** * Creates JSON from given response list and dispatches generic event. * Helper method for queries like getFollowers and getFriends. * @param users/*from w w w. j ava2s.c om*/ * @param callbackID */ public static void dispatchUsers(PagableResponseList<User> users, final int callbackID) { try { AIR.log("Got response with " + users.size() + " users"); /* Create array of JSON users */ JSONArray usersJSON = new JSONArray(); for (User user : users) { /* Create JSON for each user and put it to the array */ JSONObject userJSON = getJSON(user); usersJSON.put(userJSON.toString()); } JSONObject result = new JSONObject(); result.put("users", usersJSON); if (users.hasNext()) { result.put("nextCursor", users.getNextCursor()); } if (users.hasPrevious()) { result.put("previousCursor", users.getPreviousCursor()); } result.put("listenerID", callbackID); AIR.dispatchEvent(AIRTwitterEvent.USERS_QUERY_SUCCESS, result.toString()); } catch (JSONException e) { AIR.dispatchEvent(AIRTwitterEvent.USERS_QUERY_ERROR, StringUtils.getEventErrorJSON(callbackID, "Error creating result JSON: " + e.getMessage())); } }