public boolean setAutoFollow(boolean autofollow) { final APIClient client = new APIClient(context); ContentValues values = new ContentValues(); values.put("autofollow_friends", autofollow ? "true" : "false"); final APIResponse response = client.post(APIConstants.URL_AUTOFOLLOW_PREF, values); return (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected); }
public boolean addCategories(ArrayList<String> categories) { final APIClient client = new APIClient(context); final ValueMultimap values = new ValueMultimap(); for (String category : categories) { values.put(APIConstants.PARAMETER_CATEGORY, URLEncoder.encode(category)); } final APIResponse response = client.post(APIConstants.URL_ADD_CATEGORIES, values, false); return (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected); }
public Boolean unFavouriteComment(String storyId, String commentId, String feedId) { final APIClient client = new APIClient(context); ContentValues values = new ContentValues(); values.put(APIConstants.PARAMETER_STORYID, storyId); values.put(APIConstants.PARAMETER_STORY_FEEDID, feedId); values.put(APIConstants.PARAMETER_COMMENT_USERID, commentId); final APIResponse response = client.post(APIConstants.URL_UNLIKE_COMMENT, values); return (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected); }
public boolean deleteFeed(long feedId, String folderName) { final APIClient client = new APIClient(context); ContentValues values = new ContentValues(); values.put(APIConstants.PARAMETER_FEEDID, Long.toString(feedId)); if (!TextUtils.isEmpty(folderName)) { values.put(APIConstants.PARAMETER_IN_FOLDER, folderName); } final APIResponse response = client.post(APIConstants.URL_DELETE_FEED, values); return (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected); }
public boolean addFeed(String feedUrl, String folderName) { final APIClient client = new APIClient(context); ContentValues values = new ContentValues(); values.put(APIConstants.PARAMETER_URL, feedUrl); if (!TextUtils.isEmpty(folderName)) { values.put(APIConstants.PARAMETER_FOLDER, folderName); } final APIResponse response = client.post(APIConstants.URL_ADD_FEED, values); return (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected); }
public boolean markMultipleStoriesAsRead(ContentValues values) { final APIClient client = new APIClient(context); final APIResponse response = client.post(APIConstants.URL_MARK_FEED_STORIES_AS_READ, values); if (!response.isOffline && response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) { return true; } else { return false; } }
public boolean replyToComment( String storyId, String storyFeedId, String commentUserId, String reply) { final APIClient client = new APIClient(context); ContentValues values = new ContentValues(); values.put(APIConstants.PARAMETER_STORYID, storyId); values.put(APIConstants.PARAMETER_STORY_FEEDID, storyFeedId); values.put(APIConstants.PARAMETER_COMMENT_USERID, commentUserId); values.put(APIConstants.PARAMETER_REPLY_TEXT, reply); final APIResponse response = client.post(APIConstants.URL_REPLY_TO, values); return (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected); }
public boolean unfollowUser(final String userId) { final APIClient client = new APIClient(context); final ContentValues values = new ContentValues(); values.put(APIConstants.PARAMETER_USERID, userId); final APIResponse response = client.post(APIConstants.URL_UNFOLLOW, values); if (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) { return true; } else { return false; } }
public boolean markSocialStoryAsRead(final String updateJson) { final APIClient client = new APIClient(context); final ContentValues values = new ContentValues(); values.put(APIConstants.PARAMETER_MARKSOCIAL_JSON, updateJson); final APIResponse response = client.post(APIConstants.URL_MARK_SOCIALSTORY_AS_READ, values); if (!response.isOffline && response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) { return true; } else { return false; } }
public boolean markAllAsRead() { final APIClient client = new APIClient(context); final ValueMultimap values = new ValueMultimap(); values.put(APIConstants.PARAMETER_DAYS, "0"); final APIResponse response = client.post(APIConstants.URL_MARK_ALL_AS_READ, values, false); if (!response.isOffline && response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) { return true; } else { return false; } }
public boolean trainClassifier(String feedId, String key, int type, int action) { String typeText = null; String actionText = null; switch (type) { case Classifier.AUTHOR: typeText = "author"; break; case Classifier.TAG: typeText = "tag"; break; case Classifier.TITLE: typeText = "title"; break; case Classifier.FEED: typeText = "feed"; break; } switch (action) { case Classifier.CLEAR_LIKE: actionText = "remove_like_"; break; case Classifier.CLEAR_DISLIKE: actionText = "remove_dislike_"; break; case Classifier.LIKE: actionText = "like_"; break; case Classifier.DISLIKE: actionText = "dislike_"; break; } StringBuilder builder = new StringBuilder(); ; builder.append(actionText); builder.append(typeText); ContentValues values = new ContentValues(); if (type == Classifier.FEED) { values.put(builder.toString(), feedId); } else { values.put(builder.toString(), key); } values.put(APIConstants.PARAMETER_FEEDID, feedId); final APIClient client = new APIClient(context); final APIResponse response = client.post(APIConstants.URL_CLASSIFIER_SAVE, values); return (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected); }
public LoginResponse login(final String username, final String password) { final APIClient client = new APIClient(context); final ContentValues values = new ContentValues(); values.put(APIConstants.PARAMETER_USERNAME, username); values.put(APIConstants.PARAMETER_PASSWORD, password); final APIResponse response = client.post(APIConstants.URL_LOGIN, values); if (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) { LoginResponse loginResponse = gson.fromJson(response.responseString, LoginResponse.class); PrefsUtils.saveLogin(context, username, response.cookie); return loginResponse; } else { return new LoginResponse(); } }
public boolean markStoryAsStarred(final String feedId, final String storyId) { final APIClient client = new APIClient(context); final ValueMultimap values = new ValueMultimap(); values.put(APIConstants.PARAMETER_FEEDID, feedId); values.put(APIConstants.PARAMETER_STORYID, storyId); final APIResponse response = client.post(APIConstants.URL_MARK_STORY_AS_STARRED, values, false); if (!response.isOffline && response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) { return true; } else { return false; } }
public boolean markFeedAsRead(final String[] feedIds) { final APIClient client = new APIClient(context); final ValueMultimap values = new ValueMultimap(); for (String feedId : feedIds) { values.put(APIConstants.PARAMETER_FEEDID, feedId); } final APIResponse response = client.post(APIConstants.URL_MARK_FEED_AS_READ, values, false); if (!response.isOffline && response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) { return true; } else { return false; } }
public Boolean shareStory( final String storyId, final String feedId, final String comment, final String sourceUserId) { final APIClient client = new APIClient(context); final ContentValues values = new ContentValues(); if (!TextUtils.isEmpty(comment)) { values.put(APIConstants.PARAMETER_SHARE_COMMENT, comment); } if (!TextUtils.isEmpty(sourceUserId)) { values.put(APIConstants.PARAMETER_SHARE_SOURCEID, sourceUserId); } values.put(APIConstants.PARAMETER_FEEDID, feedId); values.put(APIConstants.PARAMETER_STORYID, storyId); final APIResponse response = client.post(APIConstants.URL_SHARE_STORY, values); if (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) { return true; } else { return false; } }
public LoginResponse signup(final String username, final String password, final String email) { final APIClient client = new APIClient(context); final ContentValues values = new ContentValues(); values.put(APIConstants.PARAMETER_USERNAME, username); values.put(APIConstants.PARAMETER_PASSWORD, password); values.put(APIConstants.PARAMETER_EMAIL, email); final APIResponse response = client.post(APIConstants.URL_SIGNUP, values); if (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected) { LoginResponse loginResponse = gson.fromJson(response.responseString, LoginResponse.class); PrefsUtils.saveLogin(context, username, response.cookie); CookieSyncManager.createInstance(context.getApplicationContext()); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setCookie(".newsblur.com", response.cookie); CookieSyncManager.getInstance().sync(); return loginResponse; } else { return new LoginResponse(); } }