@NonNull public static User showUserAlternative( final Twitter twitter, final long id, final String screenName) throws TwitterException { final String searchScreenName; if (screenName != null) { searchScreenName = screenName; } else if (id != -1) { searchScreenName = twitter.showFriendship(id).getTargetUserScreenName(); } else throw new IllegalArgumentException(); final Paging paging = new Paging(); paging.count(1); for (final User user : twitter.searchUsers(searchScreenName, paging)) { if (user.getId() == id || searchScreenName.equalsIgnoreCase(user.getScreenName())) return user; } if (id != -1) { final ResponseList<Status> timeline = twitter.getUserTimeline(id, paging); for (final Status status : timeline) { final User user = status.getUser(); if (user.getId() == id) return user; } } else { final ResponseList<Status> timeline = twitter.getUserTimeline(screenName, paging); for (final Status status : timeline) { final User user = status.getUser(); if (searchScreenName.equalsIgnoreCase(user.getScreenName())) return user; } } throw new TwitterException("can't find user"); }
public static SingleResponse<Boolean> deleteProfileBannerImage( final Context context, final long account_id) { final Twitter twitter = TwitterAPIFactory.getTwitterInstance(context, account_id, false); if (twitter == null) return new SingleResponse<>(false, null); try { twitter.removeProfileBannerImage(); return new SingleResponse<>(true, null); } catch (final TwitterException e) { return new SingleResponse<>(false, e); } }
@NonNull public static User showUser(final Twitter twitter, final long id, final String screenName) throws TwitterException { // if (twitter.getId() == id || twitter.getScreenName().equalsIgnoreCase(screenName)) { // return twitter.verifyCredentials(); // } else if (id != -1) { return twitter.showUser(id); } else if (screenName != null) { return twitter.showUser(screenName); } throw new IllegalArgumentException(); }
public static User updateProfileImage( final Context context, final Twitter twitter, final Uri imageUri, final boolean deleteImage) throws FileNotFoundException, TwitterException { InputStream is = null; try { is = context.getContentResolver().openInputStream(imageUri); return twitter.updateProfileImage(new FileTypedData(is, "image", -1, null)); } finally { Utils.closeSilently(is); if (deleteImage && "file".equals(imageUri.getScheme())) { final File file = new File(imageUri.getPath()); if (!file.delete()) { Log.w(LOGTAG, String.format("Unable to delete %s", file)); } } } }
@Override protected final PageableResponseList<User> getCursoredUsers( final Twitter twitter, final Paging paging) throws TwitterException { if (twitter == null) return null; return twitter.getBlocksList(paging); }
@Override protected IDs getIDs(final Twitter twitter, final Paging paging) throws TwitterException { if (twitter == null) return null; if (mStatusId > 0) return twitter.getStatusActivitySummary(mStatusId).getFavoriters(); return null; }