aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/net/lacolaco/smileessence/twitter/task/SavedSearches.java
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-12-07 22:09:43 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-12-07 22:09:43 +0900
commit35894c897b0c0bfc0432ccc8f9324f92337524b6 (patch)
treeeb2642116fcfa27b4c601a516fb754df6f222e96 /app/src/main/java/net/lacolaco/smileessence/twitter/task/SavedSearches.java
parent47b16cd68f45bf21efe1c25590a7d912d2e68a81 (diff)
parentdd1a0764274ef3c22b3d7e62a28184768755f411 (diff)
downloadSmileEssence-35894c897b0c0bfc0432ccc8f9324f92337524b6.tar.gz
Merge branch 'topic/saved-search-from-twitter'
* topic/saved-search-from-twitter: saved search from twitter
Diffstat (limited to 'app/src/main/java/net/lacolaco/smileessence/twitter/task/SavedSearches.java')
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/twitter/task/SavedSearches.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/SavedSearches.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SavedSearches.java
new file mode 100644
index 00000000..38177274
--- /dev/null
+++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SavedSearches.java
@@ -0,0 +1,54 @@
+package net.lacolaco.smileessence.twitter.task;
+
+import net.lacolaco.smileessence.data.Account;
+import net.lacolaco.smileessence.entity.SavedSearch;
+import net.lacolaco.smileessence.util.BackgroundTask;
+import net.lacolaco.smileessence.util.ListUtils;
+
+import java.util.List;
+
+public class SavedSearches {
+ public static class Create extends BackgroundTask<SavedSearch, Void> {
+ private final Account account;
+ private final String query;
+
+ public Create(Account account, String query) {
+ this.account = account;
+ this.query = query;
+ }
+
+ @Override
+ protected SavedSearch doInBackground() throws Exception {
+ return SavedSearch.fromTwitter(account.getTwitter().savedSearches().createSavedSearch(query));
+ }
+ }
+
+ public static class Destroy extends BackgroundTask<Void, Void> {
+ private final Account account;
+ private final long id;
+
+ public Destroy(Account account, long id) {
+ this.account = account;
+ this.id = id;
+ }
+
+ @Override
+ protected Void doInBackground() throws Exception {
+ account.getTwitter().savedSearches().destroySavedSearch(id);
+ return null;
+ }
+ }
+
+ public static class All extends BackgroundTask<List<SavedSearch>, Void> {
+ private final Account account;
+
+ public All(Account account) {
+ this.account = account;
+ }
+
+ @Override
+ protected List<SavedSearch> doInBackground() throws Exception {
+ return ListUtils.map(account.getTwitter().savedSearches().getSavedSearches(), SavedSearch::fromTwitter);
+ }
+ }
+}