Back to project page ReadabilitySDK.
The source code is released under:
MIT License
If you think the Android project ReadabilitySDK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.idemidov.readability; /* www . j a va2s. c o m*/ import android.content.Context; import com.idemidov.readability.command.AddTagsToBookmarkCommand; import com.idemidov.readability.command.AuthCommand; import com.idemidov.readability.command.DeleteBookmarkByIdCommand; import com.idemidov.readability.command.DeleteTagByIdCommand; import com.idemidov.readability.command.DeleteTagFromBookmarkById; import com.idemidov.readability.command.GetArticleByIdCommand; import com.idemidov.readability.command.GetBookmarkByIdCommand; import com.idemidov.readability.command.GetBookmarkTagsByIdCommand; import com.idemidov.readability.command.GetBookmarksCommand; import com.idemidov.readability.command.GetTagByIdCommand; import com.idemidov.readability.command.GetTagsCommand; import com.idemidov.readability.command.GetUserCurrentCommand; import com.idemidov.readability.command.PostBookmarkCommand; import com.idemidov.readability.command.UpdateBookmarkByIdCommand; import com.idemidov.readability.command.params_builders.GetBookmarksParamsBuilder; import com.idemidov.readability.command.params_builders.PostBookmarkParamsBuilder; import com.idemidov.readability.command.params_builders.UpdateBookmarkByIdParamsBuilder; import com.idemidov.readability.data.Article; import com.idemidov.readability.data.Bookmark; import com.idemidov.readability.data.BookmarksRootResponse; import com.idemidov.readability.data.CommandResponse; import com.idemidov.readability.data.Tag; import com.idemidov.readability.data.User; import com.idemidov.readability.util.CommandExecutor; import com.idemidov.readability.util.ResultCode; import java.util.ArrayList; import java.util.HashMap; import oauth.signpost.OAuthConsumer; import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; public class ApiClient { private OAuthConsumer consumer; public ApiClient(String consumerKey, String consumerSecret) { consumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret); } public ResultCode auth(Context context, String userName, String password) { AuthCommand authCommand = new AuthCommand(consumer, userName, password); CommandResponse<HashMap<String, String>> response = CommandExecutor.execute(authCommand, context); if (response.getCode() == ResultCode.CODE_OK) { consumer.setTokenWithSecret(response.getData().get(AuthCommand.OAUTH_TOKEN), response.getData().get(AuthCommand.OAUTH_TOKEN_SECRET)); } return response.getCode(); } public CommandResponse<BookmarksRootResponse> getBookmarks(Context context, GetBookmarksParamsBuilder paramsBuilder) { GetBookmarksCommand getBookmarksCommand = new GetBookmarksCommand(consumer, paramsBuilder); return CommandExecutor.execute(getBookmarksCommand, context); } public CommandResponse<Bookmark> getBookmarkById(Context context, String bookmarkId) { GetBookmarkByIdCommand getTagByIdCommand = new GetBookmarkByIdCommand(consumer, bookmarkId); return CommandExecutor.execute(getTagByIdCommand, context); } public CommandResponse<User> getCurrentUser(Context context) { GetUserCurrentCommand getUserCurrentCommand = new GetUserCurrentCommand(consumer); return CommandExecutor.execute(getUserCurrentCommand, context); } public CommandResponse<ArrayList<Tag>> getTags(Context context) { GetTagsCommand getTagsCommand = new GetTagsCommand(consumer); return CommandExecutor.execute(getTagsCommand, context); } public CommandResponse<Tag> getTagById(Context context, int tagId) { GetTagByIdCommand getTagByIdCommand = new GetTagByIdCommand(consumer, tagId); return CommandExecutor.execute(getTagByIdCommand, context); } public CommandResponse<ArrayList<Tag>> getBookmarksTags(Context context, String bookmarkId) { GetBookmarkTagsByIdCommand getBookmarkTagsByIdCommand = new GetBookmarkTagsByIdCommand(consumer, bookmarkId); return CommandExecutor.execute(getBookmarkTagsByIdCommand, context); } public CommandResponse<Article> getArticleById(Context context, String articleId) { GetArticleByIdCommand getArticleByIdCommand = new GetArticleByIdCommand(consumer, articleId); return CommandExecutor.execute(getArticleByIdCommand, context); } public CommandResponse<Bookmark> postBookmark(Context context, PostBookmarkParamsBuilder paramsBuilder) { PostBookmarkCommand postBookmarkCommand = new PostBookmarkCommand(consumer, paramsBuilder); return CommandExecutor.execute(postBookmarkCommand, context); } public CommandResponse<Bookmark> updateBookmark(Context context, int bookmarkId, UpdateBookmarkByIdParamsBuilder paramsBuilder) { UpdateBookmarkByIdCommand updateBookmarkCommand = new UpdateBookmarkByIdCommand(consumer, bookmarkId, paramsBuilder); return CommandExecutor.execute(updateBookmarkCommand, context); } public CommandResponse<ArrayList<Tag>> addTagsToBookmark(Context context, String bookmarkId, String... tags) { AddTagsToBookmarkCommand addTagsToBookmarkCommand = new AddTagsToBookmarkCommand(consumer, bookmarkId, tags); return CommandExecutor.execute(addTagsToBookmarkCommand, context); } public ResultCode deleteTag(Context context, int tagId) { DeleteTagByIdCommand deleteTagByIdCommand = new DeleteTagByIdCommand(consumer, tagId); return CommandExecutor.execute(deleteTagByIdCommand, context).getCode(); } public ResultCode deleteTagFromBookmark(Context context, int tagId, int bookmarkId) { DeleteTagFromBookmarkById deleteTagFromBookmarkById = new DeleteTagFromBookmarkById(consumer, tagId, bookmarkId); return CommandExecutor.execute(deleteTagFromBookmarkById, context).getCode(); } public ResultCode deleteBookmark(Context context, int bookmarkId) { DeleteBookmarkByIdCommand deleteBookmarkByIdCommand = new DeleteBookmarkByIdCommand(consumer, bookmarkId); return CommandExecutor.execute(deleteBookmarkByIdCommand, context).getCode(); } }