diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-09-12 18:25:10 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-09-12 18:25:10 +0900 |
commit | 97e4fbe6c0a81ec43b163bdcc6a4012039b8753a (patch) | |
tree | ceaa7f4daee2190661888e49df04b09c2b9c22c7 /app/src/main/java/net/lacolaco/smileessence | |
parent | caed849d1f2357e1357be5436e6800ba72b17b39 (diff) | |
download | SmileEssence-97e4fbe6c0a81ec43b163bdcc6a4012039b8753a.tar.gz |
TwitterTask から Activity が見えるのはどうかと思う
Diffstat (limited to 'app/src/main/java/net/lacolaco/smileessence')
55 files changed, 194 insertions, 277 deletions
diff --git a/app/src/main/java/net/lacolaco/smileessence/IntentRouter.java b/app/src/main/java/net/lacolaco/smileessence/IntentRouter.java index 4d20b660..28a51a21 100644 --- a/app/src/main/java/net/lacolaco/smileessence/IntentRouter.java +++ b/app/src/main/java/net/lacolaco/smileessence/IntentRouter.java @@ -137,7 +137,7 @@ public class IntentRouter { @Override public void error() { - Notificator.publish(activity, R.string.error_intent_status_cannot_load, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.error_intent_status_cannot_load, NotificationType.ALERT); } }); } diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java index bc2f1f6b..8145ae7f 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java @@ -119,7 +119,7 @@ public class EditTabActivity extends Activity { putVisibility(R.string.key_page_search_visibility, search.isChecked()); EditableCheckBoxModel list = (EditableCheckBoxModel) adapter.getItem(6); putVisibility(R.string.key_page_list_visibility, list.isChecked()); - new Notificator(this, R.string.notice_tab_editted).makeToast().show(); + Notificator.getInstance().publish(R.string.notice_tab_editted); super.onDestroy(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java index c81d16eb..3fe3370c 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java @@ -26,7 +26,6 @@ package net.lacolaco.smileessence.activity; import android.app.ActionBar; import android.app.Activity; -import android.app.Fragment; import android.content.Intent; import android.database.Cursor; import android.net.Uri; @@ -46,6 +45,8 @@ import net.lacolaco.smileessence.IntentRouter; import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.UserListCache; import net.lacolaco.smileessence.entity.*; +import net.lacolaco.smileessence.entity.DirectMessage; +import net.lacolaco.smileessence.entity.User; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; @@ -61,10 +62,7 @@ import net.lacolaco.smileessence.view.adapter.*; import net.lacolaco.smileessence.view.dialog.ConfirmDialogFragment; import net.lacolaco.smileessence.viewmodel.*; import net.lacolaco.smileessence.viewmodel.menu.MainActivityMenuHelper; -import twitter4j.Paging; -import twitter4j.QueryResult; -import twitter4j.Twitter; -import twitter4j.TwitterStream; +import twitter4j.*; import java.util.Collection; import java.util.HashMap; @@ -184,10 +182,6 @@ public class MainActivity extends Activity { return pageIndexUserList; } - public PageListAdapter getPagerAdapter() { - return pagerAdapter; - } - public int getThemeIndex() { return ((Application) getApplication()).getThemeIndex(); } @@ -289,6 +283,7 @@ public class MainActivity extends Activity { } else { startOAuthActivity(); } + Notificator.initialize(this); Logger.debug("onCreate"); } @@ -304,6 +299,7 @@ public class MainActivity extends Activity { if (stream != null) { stream.shutdown(); } + Notificator.getInstance().stopNotification(); Logger.debug("onDestroy"); } @@ -323,7 +319,7 @@ public class MainActivity extends Activity { super.onPause(); Logger.debug("onPause"); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - Notificator.stopNotification(); + Notificator.getInstance().stopNotification(); } @Override @@ -331,7 +327,7 @@ public class MainActivity extends Activity { super.onResume(); Logger.debug("onResume"); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - Notificator.startNotification(); + Notificator.getInstance().startNotification(); } // -------------------------- OTHER METHODS -------------------------- @@ -373,10 +369,10 @@ public class MainActivity extends Activity { PostState.getState().beginTransaction() .setMediaFilePath(rotatedPath) .commitWithOpen(this); - Notificator.publish(this, R.string.notice_select_image_succeeded); + Notificator.getInstance().publish(R.string.notice_select_image_succeeded); } catch (Exception e) { e.printStackTrace(); - Notificator.publish(this, R.string.notice_select_image_failed, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_select_image_failed, NotificationType.ALERT); } } @@ -419,14 +415,18 @@ public class MainActivity extends Activity { startTwitter(); } - public void startNewSearch(final Twitter twitter, final String query) { - setLastSearch(query); - if (!TextUtils.isEmpty(query)) { + public void startNewSearch(final Twitter twitter, final String queryString) { + setLastSearch(queryString); + if (!TextUtils.isEmpty(queryString)) { final SearchListAdapter adapter = (SearchListAdapter) getListAdapter(AdapterID.Search); - adapter.initSearch(query); + adapter.initSearch(queryString); adapter.clear(); adapter.updateForce(); - new SearchTask(twitter, query, this) { + final Query query = new Query(); + query.setQuery(queryString); + query.setCount(TwitterUtils.getPagingCount(this)); + query.setResultType(Query.RECENT); + new SearchTask(twitter, query) { @Override protected void onPostExecute(QueryResult queryResult) { super.onPostExecute(queryResult); @@ -543,7 +543,7 @@ public class MainActivity extends Activity { private void getImageUri(int requestCode, int resultCode, Intent data) { if (resultCode != RESULT_OK) { Logger.error(requestCode); - Notificator.publish(this, R.string.notice_select_image_failed); + Notificator.getInstance().publish(R.string.notice_select_image_failed); finish(); return; } @@ -557,7 +557,7 @@ public class MainActivity extends Activity { } private void initHome(final Twitter twitter, final Paging paging) { - new HomeTimelineTask(twitter, this, paging) { + new HomeTimelineTask(twitter, paging) { @Override protected void onPostExecute(List<Tweet> tweets) { super.onPostExecute(tweets); @@ -578,7 +578,7 @@ public class MainActivity extends Activity { } private void initMentions(final Twitter twitter, final Paging paging) { - new MentionsTimelineTask(twitter, this, paging) { + new MentionsTimelineTask(twitter, paging) { @Override protected void onPostExecute(List<Tweet> tweets) { super.onPostExecute(tweets); @@ -595,7 +595,7 @@ public class MainActivity extends Activity { if (pageIndexMessages == PAGE_INDEX_GONE) { return; } - new DirectMessagesTask(twitter, this, paging) { + new DirectMessagesTask(twitter, paging) { @Override protected void onPostExecute(List<DirectMessage> directMessages) { super.onPostExecute(directMessages); @@ -606,7 +606,7 @@ public class MainActivity extends Activity { adapter.notifyDataSetChanged(); } }.execute(); - new SentDirectMessagesTask(twitter, this, paging) { + new SentDirectMessagesTask(twitter, paging) { @Override protected void onPostExecute(List<DirectMessage> directMessages) { super.onPostExecute(directMessages); @@ -679,7 +679,7 @@ public class MainActivity extends Activity { private void receiveOAuth(int requestCode, int resultCode, Intent data) { if (resultCode != RESULT_OK) { Logger.error(requestCode); - Notificator.publish(this, R.string.notice_error_authenticate); + Notificator.getInstance().publish(R.string.notice_error_authenticate); finish(); } else { Account account = new Account(data.getStringExtra(OAuthSession.KEY_TOKEN), diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/OAuthActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/OAuthActivity.java index 6d571466..68052ddd 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/OAuthActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/OAuthActivity.java @@ -68,7 +68,7 @@ public class OAuthActivity extends Activity implements View.OnClickListener, Tex if (!TextUtils.isEmpty(url)) { linkTextView.setText(url); } else { - new Notificator(this, R.string.notice_error_authenticate_request).makeToast().show(); + Notificator.getInstance().publish(R.string.notice_error_authenticate_request); finish(); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenUserDetail.java b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenUserDetail.java index 09f0593c..3867a548 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenUserDetail.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/CommandOpenUserDetail.java @@ -76,7 +76,7 @@ public class CommandOpenUserDetail extends Command { fragment.setUserID(user.getId()); DialogHelper.showDialog(getActivity(), fragment); } else { - Notificator.publish(getActivity(), R.string.notice_error_show_user, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_error_show_user, NotificationType.ALERT); } } }.execute(); diff --git a/app/src/main/java/net/lacolaco/smileessence/command/CommandSaveAsTemplate.java b/app/src/main/java/net/lacolaco/smileessence/command/CommandSaveAsTemplate.java index 5783cfd0..f3f02e78 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/CommandSaveAsTemplate.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/CommandSaveAsTemplate.java @@ -60,7 +60,7 @@ public class CommandSaveAsTemplate extends Command { @Override public boolean execute() { new Template(text, 0).save(); - new Notificator(getActivity(), R.string.notice_save_as_template).publish(); + Notificator.getInstance().publish(R.string.notice_save_as_template); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandCopyTextToClipboard.java b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandCopyTextToClipboard.java index 7c598b89..4c8088b0 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandCopyTextToClipboard.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandCopyTextToClipboard.java @@ -59,7 +59,7 @@ public class MessageCommandCopyTextToClipboard extends MessageCommand { public boolean execute() { ClipboardManager manager = (ClipboardManager) getActivity().getSystemService(Activity.CLIPBOARD_SERVICE); manager.setPrimaryClip(ClipData.newPlainText("message text", getMessage().getText())); - Notificator.publish(getActivity(), R.string.notice_copy_clipboard); + Notificator.getInstance().publish(R.string.notice_copy_clipboard); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandTofuBuster.java b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandTofuBuster.java index 5e46dbdd..22a055c2 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandTofuBuster.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/message/MessageCommandTofuBuster.java @@ -66,7 +66,7 @@ public class MessageCommandTofuBuster extends MessageCommand { try { getActivity().startActivity(i); } catch (ActivityNotFoundException e) { - new Notificator(getActivity(), R.string.notice_tofubuster_not_found).publish(); + Notificator.getInstance().publish( R.string.notice_tofubuster_not_found); } return true; } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandAddToReply.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandAddToReply.java index f845258d..39c1b80e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandAddToReply.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandAddToReply.java @@ -59,7 +59,7 @@ public class StatusCommandAddToReply extends StatusCommand { public boolean execute() { String text = String.format("@%s ", getOriginalStatus().getUser().getScreenName()); PostState.getState().beginTransaction().insertText(0, text).moveCursor(text.length()).commit(); - Notificator.publish(getActivity(), R.string.notice_add_to_reply); + Notificator.getInstance().publish(R.string.notice_add_to_reply); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCongratulate.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCongratulate.java index 577ad7f1..63c898cc 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCongratulate.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCongratulate.java @@ -35,7 +35,6 @@ import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.FavoriteTask; import net.lacolaco.smileessence.twitter.task.TweetTask; -import twitter4j.Status; import twitter4j.StatusUpdate; import twitter4j.Twitter; @@ -93,8 +92,8 @@ public class StatusCommandCongratulate extends StatusCommand implements IConfirm .setInReplyToStatusID(getOriginalStatus().getId()) .build(); Twitter twitter = new TwitterApi(account).getTwitter(); - new TweetTask(twitter, update, getActivity()).execute(); - new FavoriteTask(twitter, getOriginalStatus().getId(), getActivity()).execute(); + new TweetTask(twitter, update).execute(); + new FavoriteTask(twitter, getOriginalStatus().getId()).execute(); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyTextToClipboard.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyTextToClipboard.java index 65c38867..b36849b5 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyTextToClipboard.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyTextToClipboard.java @@ -60,7 +60,7 @@ public class StatusCommandCopyTextToClipboard extends StatusCommand { public boolean execute() { ClipboardManager manager = (ClipboardManager) getActivity().getSystemService(Activity.CLIPBOARD_SERVICE); manager.setPrimaryClip(ClipData.newPlainText("tweet text", getOriginalStatus().getText())); - Notificator.publish(getActivity(), R.string.notice_copy_clipboard); + Notificator.getInstance().publish(R.string.notice_copy_clipboard); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyURLToClipboard.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyURLToClipboard.java index 65dbffea..1b0c740c 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyURLToClipboard.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandCopyURLToClipboard.java @@ -62,7 +62,7 @@ public class StatusCommandCopyURLToClipboard extends StatusCommand { String statusURL = getOriginalStatus().getTwitterUrl(); ClipboardManager manager = (ClipboardManager) getActivity().getSystemService(Activity.CLIPBOARD_SERVICE); manager.setPrimaryClip(ClipData.newPlainText("tweet url", statusURL)); - Notificator.publish(getActivity(), R.string.notice_copy_clipboard); + Notificator.getInstance().publish(R.string.notice_copy_clipboard); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandFavAndRT.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandFavAndRT.java index d7de6df7..d5b21ae4 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandFavAndRT.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandFavAndRT.java @@ -66,8 +66,8 @@ public class StatusCommandFavAndRT extends StatusCommand implements IConfirmable @Override public boolean execute() { - new FavoriteTask(new TwitterApi(account).getTwitter(), getOriginalStatus().getId(), getActivity()).execute(); - new RetweetTask(new TwitterApi(account).getTwitter(), getOriginalStatus().getId(), getActivity()).execute(); + new FavoriteTask(new TwitterApi(account).getTwitter(), getOriginalStatus().getId()).execute(); + new RetweetTask(new TwitterApi(account).getTwitter(), getOriginalStatus().getId()).execute(); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandMakeAnonymous.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandMakeAnonymous.java index a0253e2b..f564897e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandMakeAnonymous.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandMakeAnonymous.java @@ -35,7 +35,6 @@ import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.FavoriteTask; import net.lacolaco.smileessence.twitter.task.TweetTask; -import twitter4j.Status; import twitter4j.StatusUpdate; import twitter4j.Twitter; @@ -85,8 +84,8 @@ public class StatusCommandMakeAnonymous extends StatusCommand implements IConfir public boolean execute() { StatusUpdate update = new TweetBuilder().setText(build(getActivity(), getOriginalStatus(), account)).build(); Twitter twitter = new TwitterApi(account).getTwitter(); - new TweetTask(twitter, update, getActivity()).execute(); - new FavoriteTask(twitter, getOriginalStatus().getId(), getActivity()).execute(); + new TweetTask(twitter, update).execute(); + new FavoriteTask(twitter, getOriginalStatus().getId()).execute(); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandNanigaja.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandNanigaja.java index 1e6ce199..9b42db56 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandNanigaja.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandNanigaja.java @@ -35,7 +35,6 @@ import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.FavoriteTask; import net.lacolaco.smileessence.twitter.task.TweetTask; -import twitter4j.Status; import twitter4j.StatusUpdate; import twitter4j.Twitter; @@ -86,8 +85,8 @@ public class StatusCommandNanigaja extends StatusCommand implements IConfirmable .setInReplyToStatusID(getOriginalStatus().getId()) .build(); Twitter twitter = new TwitterApi(account).getTwitter(); - new TweetTask(twitter, update, getActivity()).execute(); - new FavoriteTask(twitter, getOriginalStatus().getId(), getActivity()).execute(); + new TweetTask(twitter, update).execute(); + new FavoriteTask(twitter, getOriginalStatus().getId()).execute(); return true; } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTofuBuster.java b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTofuBuster.java index 223f5dcd..9f681ed5 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTofuBuster.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/status/StatusCommandTofuBuster.java @@ -67,7 +67,7 @@ public class StatusCommandTofuBuster extends StatusCommand { try { getActivity().startActivity(i); } catch (ActivityNotFoundException e) { - new Notificator(getActivity(), R.string.notice_tofubuster_not_found).publish(); + Notificator.getInstance().publish(R.string.notice_tofubuster_not_found); } return true; } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandAddToReply.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandAddToReply.java index bd0ae429..fa3ba714 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandAddToReply.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandAddToReply.java @@ -58,7 +58,7 @@ public class UserCommandAddToReply extends UserCommand { public boolean execute() { String text = String.format("@%s ", getUser().getScreenName()); PostState.getState().beginTransaction().insertText(0, text).moveCursor(text.length()).commit(); - Notificator.publish(getActivity(), R.string.notice_add_to_reply); + Notificator.getInstance().publish(R.string.notice_add_to_reply); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandBlock.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandBlock.java index 159d551a..b3e4f616 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandBlock.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandBlock.java @@ -63,7 +63,7 @@ public class UserCommandBlock extends UserCommand implements IConfirmable { @Override public boolean execute() { - new BlockTask(TwitterApi.getTwitter(account), getUser().getId(), getActivity()).execute(); + new BlockTask(TwitterApi.getTwitter(account), getUser().getId()).execute(); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandReportForSpam.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandReportForSpam.java index 79b037cc..d910d031 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandReportForSpam.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandReportForSpam.java @@ -63,7 +63,7 @@ public class UserCommandReportForSpam extends UserCommand implements IConfirmabl @Override public boolean execute() { - new ReportForSpamTask(new TwitterApi(account).getTwitter(), getUser().getId(), getActivity()).execute(); + new ReportForSpamTask(new TwitterApi(account).getTwitter(), getUser().getId()).execute(); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandUnblock.java b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandUnblock.java index db271821..d788feac 100644 --- a/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandUnblock.java +++ b/app/src/main/java/net/lacolaco/smileessence/command/user/UserCommandUnblock.java @@ -63,7 +63,7 @@ public class UserCommandUnblock extends UserCommand implements IConfirmable { @Override public boolean execute() { - new UnblockTask(new TwitterApi(account).getTwitter(), getUser().getId(), getActivity()).execute(); + new UnblockTask(new TwitterApi(account).getTwitter(), getUser().getId()).execute(); return true; } } diff --git a/app/src/main/java/net/lacolaco/smileessence/notification/Notificator.java b/app/src/main/java/net/lacolaco/smileessence/notification/Notificator.java index 6a75e2eb..4488253d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/notification/Notificator.java +++ b/app/src/main/java/net/lacolaco/smileessence/notification/Notificator.java @@ -34,69 +34,70 @@ import de.keyboardsurfer.android.widget.crouton.Style; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.util.UIHandler; -public class Notificator { - - // ------------------------------ FIELDS ------------------------------ +import java.util.concurrent.ConcurrentLinkedDeque; +import java.util.concurrent.ConcurrentLinkedQueue; +public class Notificator { + private static Notificator instance; private static final int DURATION = 1000; - private static boolean isRunning; private Activity activity; - private String text; - private NotificationType type; - - // -------------------------- STATIC METHODS -------------------------- - - public Notificator(Activity activity, int resID) { - this(activity, resID, NotificationType.INFO); - } + private boolean isRunning; - public Notificator(Activity activity, String text) { - this(activity, text, NotificationType.INFO); + public static void initialize(Activity activity) { + instance = new Notificator(activity); } - public Notificator(Activity activity, int resID, NotificationType type) { - this(activity, activity.getString(resID), type); + public static Notificator getInstance() { + if (instance == null) { + throw new IllegalStateException("Notificatior is not initialized"); + } + return instance; } - public Notificator(Activity activity, String text, NotificationType type) { - this.activity = activity; - this.text = text; - this.type = type; + private Notificator(Activity a) { + activity = a; } - public static void startNotification() { - isRunning = true; + public void publish(int resID) { + publish(activity.getString(resID)); } - public static void stopNotification() { - isRunning = false; - Crouton.cancelAllCroutons(); + public void publish(String text) { + publish(text, NotificationType.INFO); } - // --------------------------- CONSTRUCTORS --------------------------- - - /** - * Notify self on cronton or toast. - */ - public static void publish(Activity activity, int resID) { - publish(activity, activity.getString(resID)); + public void publish(int resID, NotificationType type) { + publish(activity.getString(resID), type); } - public static void publish(Activity activity, String text) { - new Notificator(activity, text, NotificationType.INFO).publish(); + public void publish(String text, NotificationType type) { + if (activity.isFinishing()) { + return; + } + new UIHandler() { + @Override + public void run() { + if (isRunning) { + Logger.debug(String.format("notify by crouton %s", text)); + Crouton.makeText(activity, text, getStyle(type)).show(); + } else { + Logger.debug(String.format("notify by toast %s", text)); + Toast.makeText(activity, text, Toast.LENGTH_LONG).show(); + } + } + }.post(); } - public static void publish(Activity activity, int resID, NotificationType type) { - publish(activity, activity.getString(resID), type); + public void startNotification() { + isRunning = true; } - public static void publish(Activity activity, String text, NotificationType type) { - new Notificator(activity, text, type).publish(); + public void stopNotification() { + isRunning = false; + Crouton.cancelAllCroutons(); } - // --------------------- GETTER / SETTER METHODS --------------------- - - private Style getStyle() { + private Style getStyle(NotificationType type) { Configuration.Builder conf = new Configuration.Builder(); conf.setDuration(DURATION); Style.Builder style = new Style.Builder(); @@ -113,35 +114,4 @@ public class Notificator { } return style.build(); } - - // -------------------------- OTHER METHODS -------------------------- - - public Crouton makeCrouton() { - return Crouton.makeText(activity, text, getStyle()); - } - - public Toast makeToast() { - return Toast.makeText(activity, text, Toast.LENGTH_LONG); - } - - /** - * Notify self on cronton or toast. - */ - public void publish() { - if (activity == null || activity.isFinishing()) { - return; - } - new UIHandler() { - @Override - public void run() { - if (isRunning) { - Logger.debug(String.format("notify by crouton %s", text)); - makeCrouton().show(); - } else { - Logger.debug(String.format("notify by toast %s", text)); - makeToast().show(); - } - } - }.post(); - } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/UserStreamListener.java b/app/src/main/java/net/lacolaco/smileessence/twitter/UserStreamListener.java index 3321df20..fd7455de 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/UserStreamListener.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/UserStreamListener.java @@ -62,10 +62,6 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect return activity.getCurrentAccount().userID; } - private int getPagerCount() { - return activity.getPagerAdapter().getCount(); - } - // ------------------------ INTERFACE METHODS ------------------------ @@ -74,13 +70,13 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect @Override public void onConnect() { activity.setStreaming(true); - new Notificator(activity, R.string.notice_stream_connect).publish(); + Notificator.getInstance().publish(R.string.notice_stream_connect); } @Override public void onDisconnect() { activity.setStreaming(false); - new Notificator(activity, R.string.notice_stream_disconnect).publish(); + Notificator.getInstance().publish(R.string.notice_stream_disconnect); } @Override @@ -101,7 +97,7 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect }// else if (viewModel.isMention()) { // addToMentions(viewModel); // EventViewModel mentioned = new EventViewModel(EnumEvent.MENTIONED, status.getUser(), status); - // Notificator.publish(activity, mentioned.getFormattedString(activity)); + // Notificator.getInstance().publish(mentioned.getFormattedString(activity)); //} StatusFilter.filter(activity, vm); FavoriteCache.getInstance().put(status); @@ -272,7 +268,7 @@ public class UserStreamListener implements twitter4j.UserStreamListener, Connect private void addToHistory(EventViewModel mentioned) { EventListAdapter history = (EventListAdapter) activity.getListAdapter(MainActivity.AdapterID.History); - Notificator.publish(activity, mentioned.getFormattedString(activity)); + Notificator.getInstance().publish(mentioned.getFormattedString(activity)); history.addToTop(mentioned); history.update(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/BlockTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/BlockTask.java index d0f9728d..a3f5481f 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/BlockTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/BlockTask.java @@ -40,14 +40,12 @@ public class BlockTask extends TwitterTask<User> { // ------------------------------ FIELDS ------------------------------ private final long userID; - private final Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public BlockTask(Twitter twitter, long userID, Activity activity) { + public BlockTask(Twitter twitter, long userID) { super(twitter); this.userID = userID; - this.activity = activity; } // ------------------------ OVERRIDE METHODS ------------------------ @@ -55,9 +53,9 @@ public class BlockTask extends TwitterTask<User> { @Override protected void onPostExecute(User user) { if (user != null) { - new Notificator(activity, R.string.notice_block_succeeded).publish(); + Notificator.getInstance().publish(R.string.notice_block_succeeded); } else { - new Notificator(activity, R.string.notice_block_failed, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_block_failed, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteMessageTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteMessageTask.java index 36ad887f..71d3f410 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteMessageTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteMessageTask.java @@ -40,14 +40,12 @@ public class DeleteMessageTask extends TwitterTask<DirectMessage> { // ------------------------------ FIELDS ------------------------------ private final long messageID; - private final Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public DeleteMessageTask(Twitter twitter, long messageID, Activity activity) { + public DeleteMessageTask(Twitter twitter, long messageID) { super(twitter); this.messageID = messageID; - this.activity = activity; } // ------------------------ OVERRIDE METHODS ------------------------ @@ -55,9 +53,9 @@ public class DeleteMessageTask extends TwitterTask<DirectMessage> { @Override protected void onPostExecute(DirectMessage message) { if (message != null) { - new Notificator(activity, R.string.notice_message_delete_succeeded).publish(); + Notificator.getInstance().publish(R.string.notice_message_delete_succeeded); } else { - new Notificator(activity, R.string.notice_message_delete_failed, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_message_delete_failed, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteStatusTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteStatusTask.java index c770f5f7..69e390cd 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteStatusTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/DeleteStatusTask.java @@ -41,14 +41,12 @@ public class DeleteStatusTask extends TwitterTask<Tweet> { // ------------------------------ FIELDS ------------------------------ private final long statusID; - private final Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public DeleteStatusTask(Twitter twitter, long statusID, Activity activity) { + public DeleteStatusTask(Twitter twitter, long statusID) { super(twitter); this.statusID = statusID; - this.activity = activity; } // ------------------------ OVERRIDE METHODS ------------------------ @@ -57,9 +55,9 @@ public class DeleteStatusTask extends TwitterTask<Tweet> { protected void onPostExecute(Tweet tweet) { if (tweet != null) { Tweet.remove(tweet.getId()); - new Notificator(activity, R.string.notice_status_delete_succeeded).publish(); + Notificator.getInstance().publish(R.string.notice_status_delete_succeeded); } else { - new Notificator(activity, R.string.notice_status_delete_failed, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_status_delete_failed, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/DirectMessagesTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/DirectMessagesTask.java index 481a0e6f..8590c935 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/DirectMessagesTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/DirectMessagesTask.java @@ -43,14 +43,12 @@ public class DirectMessagesTask extends TwitterTask<List<DirectMessage>> { // ------------------------------ FIELDS ------------------------------ - private final Activity activity; private final Paging paging; // --------------------------- CONSTRUCTORS --------------------------- - public DirectMessagesTask(Twitter twitter, Activity activity, Paging paging) { + public DirectMessagesTask(Twitter twitter, Paging paging) { super(twitter); - this.activity = activity; this.paging = paging; } @@ -68,9 +66,9 @@ public class DirectMessagesTask extends TwitterTask<List<DirectMessage>> { e.printStackTrace(); Logger.error(e.toString()); if (e.exceededRateLimitation()) { - Notificator.publish(activity, R.string.notice_error_rate_limit, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_error_rate_limit, NotificationType.ALERT); } else { - Notificator.publish(activity, R.string.notice_error_get_messages, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_error_get_messages, NotificationType.ALERT); } return Collections.emptyList(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/FavoriteTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/FavoriteTask.java index 491437c6..4f93239d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/FavoriteTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/FavoriteTask.java @@ -41,14 +41,12 @@ public class FavoriteTask extends TwitterTask<Tweet> { // ------------------------------ FIELDS ------------------------------ private final long statusID; - private final Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public FavoriteTask(Twitter twitter, long statusID, Activity activity) { + public FavoriteTask(Twitter twitter, long statusID) { super(twitter); this.statusID = statusID; - this.activity = activity; } // ------------------------ OVERRIDE METHODS ------------------------ @@ -56,9 +54,9 @@ public class FavoriteTask extends TwitterTask<Tweet> { @Override protected void onPostExecute(Tweet tweet) { if (tweet != null) { - new Notificator(activity, R.string.notice_favorite_succeeded).publish(); + Notificator.getInstance().publish(R.string.notice_favorite_succeeded); } else { - new Notificator(activity, R.string.notice_favorite_failed, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_favorite_failed, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/FollowTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/FollowTask.java index 604d41ce..9b99abf2 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/FollowTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/FollowTask.java @@ -40,14 +40,12 @@ public class FollowTask extends TwitterTask<User> { // ------------------------------ FIELDS ------------------------------ private final long userID; - private final Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public FollowTask(Twitter twitter, long userID, Activity activity) { + public FollowTask(Twitter twitter, long userID) { super(twitter); this.userID = userID; - this.activity = activity; } // ------------------------ OVERRIDE METHODS ------------------------ @@ -55,9 +53,9 @@ public class FollowTask extends TwitterTask<User> { @Override protected void onPostExecute(User user) { if (user != null) { - new Notificator(activity, R.string.notice_follow_succeeded).publish(); + Notificator.getInstance().publish(R.string.notice_follow_succeeded); } else { - new Notificator(activity, R.string.notice_follow_failed, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_follow_failed, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/HomeTimelineTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/HomeTimelineTask.java index 2b56969f..a57fbeaa 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/HomeTimelineTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/HomeTimelineTask.java @@ -45,13 +45,11 @@ public class HomeTimelineTask extends TwitterTask<List<Tweet>> { // ------------------------------ FIELDS ------------------------------ private final Paging paging; - private final Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public HomeTimelineTask(Twitter twitter, Activity activity, Paging paging) { + public HomeTimelineTask(Twitter twitter, Paging paging) { super(twitter); - this.activity = activity; this.paging = paging; } @@ -72,9 +70,9 @@ public class HomeTimelineTask extends TwitterTask<List<Tweet>> { e.printStackTrace(); Logger.error(e.toString()); if (e.exceededRateLimitation()) { - Notificator.publish(activity, R.string.notice_error_rate_limit, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_error_rate_limit, NotificationType.ALERT); } else { - Notificator.publish(activity, R.string.notice_error_get_home, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_error_get_home, NotificationType.ALERT); } return Collections.emptyList(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/MentionsTimelineTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/MentionsTimelineTask.java index d38bb380..236d37b3 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/MentionsTimelineTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/MentionsTimelineTask.java @@ -42,14 +42,12 @@ public class MentionsTimelineTask extends TwitterTask<List<Tweet>> { // ------------------------------ FIELDS ------------------------------ - private final Activity activity; private final Paging paging; // --------------------------- CONSTRUCTORS --------------------------- - public MentionsTimelineTask(Twitter twitter, Activity activity, Paging paging) { + public MentionsTimelineTask(Twitter twitter, Paging paging) { super(twitter); - this.activity = activity; this.paging = paging; } @@ -70,9 +68,9 @@ public class MentionsTimelineTask extends TwitterTask<List<Tweet>> { e.printStackTrace(); Logger.error(e.toString()); if (e.exceededRateLimitation()) { - Notificator.publish(activity, R.string.notice_error_rate_limit, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_error_rate_limit, NotificationType.ALERT); } else { - Notificator.publish(activity, R.string.notice_error_get_mentions, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_error_get_mentions, NotificationType.ALERT); } return Collections.emptyList(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/ReportForSpamTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/ReportForSpamTask.java index 38b88f4b..51eb4b26 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/ReportForSpamTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/ReportForSpamTask.java @@ -40,14 +40,12 @@ public class ReportForSpamTask extends TwitterTask<User> { // ------------------------------ FIELDS ------------------------------ private final long userID; - private final Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public ReportForSpamTask(Twitter twitter, long userID, Activity activity) { + public ReportForSpamTask(Twitter twitter, long userID) { super(twitter); this.userID = userID; - this.activity = activity; } // ------------------------ OVERRIDE METHODS ------------------------ @@ -55,9 +53,9 @@ public class ReportForSpamTask extends TwitterTask<User> { @Override protected void onPostExecute(User user) { if (user != null) { - new Notificator(activity, R.string.notice_r4s_succeeded).publish(); + Notificator.getInstance().publish(R.string.notice_r4s_succeeded); } else { - new Notificator(activity, R.string.notice_r4s_failed, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_r4s_failed, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/RetweetTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/RetweetTask.java index 3770588a..100f5ce4 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/RetweetTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/RetweetTask.java @@ -41,14 +41,12 @@ public class RetweetTask extends TwitterTask<Tweet> { // ------------------------------ FIELDS ------------------------------ private final long statusID; - private final Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public RetweetTask(Twitter twitter, long statusID, Activity activity) { + public RetweetTask(Twitter twitter, long statusID) { super(twitter); this.statusID = statusID; - this.activity = activity; } // ------------------------ OVERRIDE METHODS ------------------------ @@ -56,9 +54,9 @@ public class RetweetTask extends TwitterTask<Tweet> { @Override protected void onPostExecute(Tweet tweet) { if (tweet != null) { - new Notificator(activity, R.string.notice_retweet_succeeded).publish(); + Notificator.getInstance().publish(R.string.notice_retweet_succeeded); } else { - new Notificator(activity, R.string.notice_retweet_failed, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_retweet_failed, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/SearchTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SearchTask.java index 3bf715e3..2fabfb1c 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/SearchTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SearchTask.java @@ -44,32 +44,15 @@ public class SearchTask extends TwitterTask<QueryResult> { // ------------------------------ FIELDS ------------------------------ - private final MainActivity activity; private final Query query; - // -------------------------- STATIC METHODS -------------------------- - - public SearchTask(Twitter twitter, String queryString, MainActivity activity) { - this(twitter, getBaseQuery(activity, queryString), activity); - } - // --------------------------- CONSTRUCTORS --------------------------- - public SearchTask(Twitter twitter, Query query, MainActivity activity) { + public SearchTask(Twitter twitter, Query query) { super(twitter); - this.activity = activity; this.query = query; } - public static Query getBaseQuery(MainActivity activity, String queryString) { - Configuration config = activity.getResources().getConfiguration(); - Query query = new Query(); - query.setQuery(queryString); - query.setCount(TwitterUtils.getPagingCount(activity)); - query.setResultType(Query.RECENT); - return query; - } - // ------------------------ OVERRIDE METHODS ------------------------ @Override @@ -90,9 +73,9 @@ public class SearchTask extends TwitterTask<QueryResult> { e.printStackTrace(); Logger.debug(e); if (e.exceededRateLimitation()) { - Notificator.publish(activity, R.string.notice_error_rate_limit, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_error_rate_limit, NotificationType.ALERT); } else { - Notificator.publish(activity, R.string.notice_error_search, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_error_search, NotificationType.ALERT); } return null; } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/SendMessageTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SendMessageTask.java index eb4cd835..ae6036bb 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/SendMessageTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SendMessageTask.java @@ -41,15 +41,13 @@ public class SendMessageTask extends TwitterTask<DirectMessage> { private final String userID; private final String text; - private final Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public SendMessageTask(Twitter twitter, String screenName, String text, Activity activity) { + public SendMessageTask(Twitter twitter, String screenName, String text) { super(twitter); this.userID = screenName; this.text = text; - this.activity = activity; } // ------------------------ OVERRIDE METHODS ------------------------ @@ -57,9 +55,9 @@ public class SendMessageTask extends TwitterTask<DirectMessage> { @Override protected void onPostExecute(DirectMessage message) { if (message != null) { - new Notificator(activity, R.string.notice_message_send_succeeded).publish(); + Notificator.getInstance().publish(R.string.notice_message_send_succeeded); } else { - new Notificator(activity, R.string.notice_message_send_failed, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_message_send_failed, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/SentDirectMessagesTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SentDirectMessagesTask.java index f6c28fd6..324d57f2 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/SentDirectMessagesTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/SentDirectMessagesTask.java @@ -43,14 +43,12 @@ public class SentDirectMessagesTask extends TwitterTask<List<DirectMessage>> { // ------------------------------ FIELDS ------------------------------ - private final Activity activity; private final Paging paging; // --------------------------- CONSTRUCTORS --------------------------- - public SentDirectMessagesTask(Twitter twitter, Activity activity, Paging paging) { + public SentDirectMessagesTask(Twitter twitter, Paging paging) { super(twitter); - this.activity = activity; this.paging = paging; } @@ -68,9 +66,9 @@ public class SentDirectMessagesTask extends TwitterTask<List<DirectMessage>> { e.printStackTrace(); Logger.error(e.toString()); if (e.exceededRateLimitation()) { - Notificator.publish(activity, R.string.notice_error_rate_limit, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_error_rate_limit, NotificationType.ALERT); } else { - Notificator.publish(activity, R.string.notice_error_get_messages, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_error_get_messages, NotificationType.ALERT); } return Collections.emptyList(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/TweetTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/TweetTask.java index 0e3c8ff0..ff5cf9d1 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/TweetTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/TweetTask.java @@ -38,7 +38,6 @@ import net.lacolaco.smileessence.notification.Notificator; import net.lacolaco.smileessence.preference.UserPreferenceHelper; import net.lacolaco.smileessence.twitter.TwitterApi; -import twitter4j.Status; import twitter4j.StatusUpdate; import twitter4j.Twitter; import twitter4j.TwitterException; @@ -53,27 +52,26 @@ public class TweetTask extends TwitterTask<Tweet> { private final StatusUpdate update; private final String mediaPath; - private final Activity activity; private String tempFilePath; + private boolean resizeFlag; // --------------------------- CONSTRUCTORS --------------------------- - public TweetTask(Twitter twitter, StatusUpdate update, Activity activity) { - this(twitter, update, null, activity); + public TweetTask(Twitter twitter, StatusUpdate update) { + this(twitter, update, null, false); } - public TweetTask(Twitter twitter, StatusUpdate update, String mediaPath, Activity activity) { + public TweetTask(Twitter twitter, StatusUpdate update, String mediaPath, boolean resize) { super(twitter); this.update = update; this.mediaPath = mediaPath; - this.activity = activity; + resizeFlag = resize; } // --------------------- GETTER / SETTER METHODS --------------------- public File getMediaFile() { File file = new File(mediaPath); - boolean resizeFlag = new UserPreferenceHelper(activity).getValue(R.string.key_setting_resize_post_image, false); if (file.length() >= TwitterApi.MEDIA_SIZE_LIMIT && resizeFlag) { BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inJustDecodeBounds = true; //decoder is not return bitmap but set option @@ -111,9 +109,9 @@ public class TweetTask extends TwitterTask<Tweet> { @Override protected void onPostExecute(Tweet tweet) { if (tweet != null) { - new Notificator(activity, R.string.notice_tweet_succeeded).publish(); + Notificator.getInstance().publish(R.string.notice_tweet_succeeded); } else { - new Notificator(activity, R.string.notice_tweet_failed, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_tweet_failed, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnblockTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnblockTask.java index a1092a1f..d741b73c 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnblockTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnblockTask.java @@ -40,14 +40,12 @@ public class UnblockTask extends TwitterTask<User> { // ------------------------------ FIELDS ------------------------------ private final long userID; - private final Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public UnblockTask(Twitter twitter, long userID, Activity activity) { + public UnblockTask(Twitter twitter, long userID) { super(twitter); this.userID = userID; - this.activity = activity; } // ------------------------ OVERRIDE METHODS ------------------------ @@ -55,9 +53,9 @@ public class UnblockTask extends TwitterTask<User> { @Override protected void onPostExecute(User user) { if (user != null) { - new Notificator(activity, R.string.notice_unblock_succeeded).publish(); + Notificator.getInstance().publish(R.string.notice_unblock_succeeded); } else { - new Notificator(activity, R.string.notice_unblock_failed, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_unblock_failed, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfavoriteTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfavoriteTask.java index 46e70cb5..c936f4be 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfavoriteTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfavoriteTask.java @@ -41,14 +41,12 @@ public class UnfavoriteTask extends TwitterTask<Tweet> { // ------------------------------ FIELDS ------------------------------ private final long statusID; - private final Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public UnfavoriteTask(Twitter twitter, long statusID, Activity activity) { + public UnfavoriteTask(Twitter twitter, long statusID) { super(twitter); this.statusID = statusID; - this.activity = activity; } // ------------------------ OVERRIDE METHODS ------------------------ @@ -56,9 +54,9 @@ public class UnfavoriteTask extends TwitterTask<Tweet> { @Override protected void onPostExecute(Tweet tweet) { if (tweet != null) { - new Notificator(activity, R.string.notice_unfavorite_succeeded).publish(); + Notificator.getInstance().publish(R.string.notice_unfavorite_succeeded); } else { - new Notificator(activity, R.string.notice_unfavorite_failed, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_unfavorite_failed, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfollowTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfollowTask.java index c0d890fa..53722bb0 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfollowTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UnfollowTask.java @@ -40,14 +40,12 @@ public class UnfollowTask extends TwitterTask<User> { // ------------------------------ FIELDS ------------------------------ private final long userID; - private final Activity activity; // --------------------------- CONSTRUCTORS --------------------------- - public UnfollowTask(Twitter twitter, long userID, Activity activity) { + public UnfollowTask(Twitter twitter, long userID) { super(twitter); this.userID = userID; - this.activity = activity; } // ------------------------ OVERRIDE METHODS ------------------------ @@ -55,9 +53,9 @@ public class UnfollowTask extends TwitterTask<User> { @Override protected void onPostExecute(User user) { if (user != null) { - new Notificator(activity, R.string.notice_unfollow_succeeded).publish(); + Notificator.getInstance().publish(R.string.notice_unfollow_succeeded); } else { - new Notificator(activity, R.string.notice_unfollow_failed, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_unfollow_failed, NotificationType.ALERT); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/twitter/task/UserTimelineTask.java b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UserTimelineTask.java index ce5a8ed2..9faeb077 100644 --- a/app/src/main/java/net/lacolaco/smileessence/twitter/task/UserTimelineTask.java +++ b/app/src/main/java/net/lacolaco/smileessence/twitter/task/UserTimelineTask.java @@ -55,8 +55,6 @@ public class UserTimelineTask extends TwitterTask<List<Tweet>> { @Override protected void onPostExecute(List<Tweet> tweets) { - for (Tweet tweet : tweets) { - } } @Override diff --git a/app/src/main/java/net/lacolaco/smileessence/util/IntentUtils.java b/app/src/main/java/net/lacolaco/smileessence/util/IntentUtils.java index 580db527..567939d5 100644 --- a/app/src/main/java/net/lacolaco/smileessence/util/IntentUtils.java +++ b/app/src/main/java/net/lacolaco/smileessence/util/IntentUtils.java @@ -51,7 +51,7 @@ public class IntentUtils { activity.startActivity(intent); return true; } else { - new Notificator(activity, R.string.notice_error_start_activity, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_error_start_activity, NotificationType.ALERT); } return false; } @@ -82,7 +82,7 @@ public class IntentUtils { activity.startActivityForResult(intent, requestCode); return true; } else { - new Notificator(activity, R.string.notice_error_start_activity, NotificationType.ALERT).publish(); + Notificator.getInstance().publish(R.string.notice_error_start_activity, NotificationType.ALERT); } return false; } diff --git a/app/src/main/java/net/lacolaco/smileessence/view/CustomListFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/CustomListFragment.java index d422b770..e9eccabc 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/CustomListFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/CustomListFragment.java @@ -129,7 +129,7 @@ public abstract class CustomListFragment extends PageFragment implements AbsList } protected void notifyListUpdated(int increments) { - Notificator.publish(getActivity(), getString(R.string.notice_timeline_new, increments)); + Notificator.getInstance().publish(getString(R.string.notice_timeline_new, increments)); } protected void updateListViewWithNotice(AbsListView absListView, CustomListAdapter<?> adapter, boolean addedToTop) { diff --git a/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java index 56fe628d..f9b8262a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java @@ -90,7 +90,7 @@ public class HomeFragment extends CustomListFragment { if (adapter.getCount() > 0) { paging.setSinceId(adapter.getTopID()); } - new HomeTimelineTask(twitter, activity, paging) { + new HomeTimelineTask(twitter, paging) { @Override protected void onPostExecute(List<Tweet> tweets) { super.onPostExecute(tweets); @@ -116,7 +116,7 @@ public class HomeFragment extends CustomListFragment { if (adapter.getCount() > 0) { paging.setMaxId(adapter.getLastID() - 1); } - new HomeTimelineTask(twitter, activity, paging) { + new HomeTimelineTask(twitter, paging) { @Override protected void onPostExecute(List<Tweet> tweets) { super.onPostExecute(tweets); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java index 056c274a..2b0e95ef 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java @@ -76,7 +76,7 @@ public class MentionsFragment extends CustomListFragment { if (adapter.getCount() > 0) { paging.setSinceId(adapter.getTopID()); } - new MentionsTimelineTask(twitter, activity, paging) { + new MentionsTimelineTask(twitter, paging) { @Override protected void onPostExecute(List<Tweet> tweets) { super.onPostExecute(tweets); @@ -99,7 +99,7 @@ public class MentionsFragment extends CustomListFragment { if (adapter.getCount() > 0) { paging.setMaxId(adapter.getLastID() - 1); } - new MentionsTimelineTask(twitter, activity, paging) { + new MentionsTimelineTask(twitter, paging) { @Override protected void onPostExecute(List<Tweet> tweets) { super.onPostExecute(tweets); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java index a3985574..8f0232c5 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java @@ -79,7 +79,7 @@ public class MessagesFragment extends CustomListFragment { if (adapter.getCount() > 0) { paging.setSinceId(adapter.getTopID()); } - new DirectMessagesTask(twitter, activity, paging) { + new DirectMessagesTask(twitter, paging) { @Override protected void onPostExecute(List<DirectMessage> directMessages) { super.onPostExecute(directMessages); @@ -102,7 +102,7 @@ public class MessagesFragment extends CustomListFragment { if (adapter.getCount() > 0) { paging.setMaxId(adapter.getLastID() - 1); } - new DirectMessagesTask(twitter, activity, paging) { + new DirectMessagesTask(twitter, paging) { @Override protected void onPostExecute(List<DirectMessage> directMessages) { super.onPostExecute(directMessages); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java index 3e2a7095..22daa18c 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java @@ -24,7 +24,6 @@ package net.lacolaco.smileessence.view; -import android.app.Fragment; import android.content.Context; import android.content.Intent; import android.net.Uri; @@ -57,7 +56,6 @@ import net.lacolaco.smileessence.view.dialog.PostMenuDialogFragment; import net.lacolaco.smileessence.view.dialog.SelectImageDialogFragment; import net.lacolaco.smileessence.viewmodel.StatusViewModel; -import twitter4j.Status; import twitter4j.StatusUpdate; import java.io.File; @@ -384,7 +382,8 @@ public class PostFragment extends PageFragment implements TextWatcher, View.OnFo PostState state = PostState.getState(); StatusUpdate statusUpdate = state.toStatusUpdate(); MainActivity mainActivity = (MainActivity) getActivity(); - TweetTask tweetTask = new TweetTask(TwitterApi.getTwitter(mainActivity.getCurrentAccount()), statusUpdate, state.getMediaFilePath(), mainActivity); + boolean resizeFlag = new UserPreferenceHelper(mainActivity).getValue(R.string.key_setting_resize_post_image, false); + TweetTask tweetTask = new TweetTask(TwitterApi.getTwitter(mainActivity.getCurrentAccount()), statusUpdate, state.getMediaFilePath(), resizeFlag); tweetTask.execute(); PostState.newState().beginTransaction().commit(); mainActivity.setSelectedPageIndex(mainActivity.getPageIndexHome()); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java index 9bf86771..381affba 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java @@ -29,7 +29,6 @@ import android.os.Bundle; import android.text.Spannable; import android.text.TextUtils; import android.text.method.ArrowKeyMovementMethod; -import android.util.Log; import android.view.*; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; @@ -53,6 +52,7 @@ import net.lacolaco.smileessence.notification.Notificator; import net.lacolaco.smileessence.twitter.StatusFilter; import net.lacolaco.smileessence.twitter.TwitterApi; import net.lacolaco.smileessence.twitter.task.SearchTask; +import net.lacolaco.smileessence.twitter.util.TwitterUtils; import net.lacolaco.smileessence.util.UIHandler; import net.lacolaco.smileessence.view.adapter.SearchListAdapter; import net.lacolaco.smileessence.view.dialog.SelectSearchQueryDialogFragment; @@ -146,11 +146,14 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi }.post(); return; } - final Query query = SearchTask.getBaseQuery(activity, queryString); + final Query query = new Query(); + query.setQuery(queryString); + query.setCount(TwitterUtils.getPagingCount(activity)); + query.setResultType(Query.RECENT); if (adapter.getCount() > 0) { query.setSinceId(adapter.getTopID()); } - new SearchTask(twitter, query, activity) { + new SearchTask(twitter, query) { @Override protected void onPostExecute(QueryResult queryResult) { super.onPostExecute(queryResult); @@ -189,11 +192,14 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi }.post(); return; } - final Query query = SearchTask.getBaseQuery(activity, queryString); + final Query query = new Query(); + query.setQuery(queryString); + query.setCount(TwitterUtils.getPagingCount(activity)); + query.setResultType(Query.RECENT); if (adapter.getCount() > 0) { query.setMaxId(adapter.getLastID() - 1); } - new SearchTask(twitter, query, activity) { + new SearchTask(twitter, query) { @Override protected void onPostExecute(QueryResult queryResult) { super.onPostExecute(queryResult); @@ -305,12 +311,12 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi } private void notifyTextEmpty(MainActivity activity) { - Notificator.publish(activity, R.string.notice_search_text_empty); + Notificator.getInstance().publish(R.string.notice_search_text_empty); } private void openSearchQueryDialog(final MainActivity mainActivity) { if (SearchQuery.getAll().size() == 0) { - Notificator.publish(mainActivity, R.string.notice_no_query_exists); + Notificator.getInstance().publish(R.string.notice_no_query_exists); return; } DialogHelper.showDialog(mainActivity, new SelectSearchQueryDialogFragment() { @@ -327,10 +333,10 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi private void saveQuery() { String text = editText.getText().toString(); if (TextUtils.isEmpty(text)) { - Notificator.publish(getActivity(), R.string.notice_query_is_empty, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_query_is_empty, NotificationType.ALERT); } else { SearchQuery.saveIfNotFound(text); - Notificator.publish(getActivity(), R.string.notice_query_saved); + Notificator.getInstance().publish(R.string.notice_query_saved); } } @@ -338,7 +344,7 @@ public class SearchFragment extends CustomListFragment implements View.OnClickLi if (editText != null) { String text = editText.getText().toString(); if (TextUtils.isEmpty(text)) { - Notificator.publish(getActivity(), R.string.notice_query_is_empty, NotificationType.ALERT); + Notificator.getInstance().publish(R.string.notice_query_is_empty, NotificationType.ALERT); } else { ((MainActivity) getActivity()).openSearchPage(text); hideIME(); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/SettingFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/SettingFragment.java index f45e11e8..e3f813c2 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/SettingFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/SettingFragment.java @@ -60,9 +60,9 @@ public class SettingFragment extends PreferenceFragment implements OnSharedPrefe if (UserPreferenceHelper.TEXT_SIZE_MIN <= newTextSize && newTextSize <= UserPreferenceHelper.TEXT_SIZE_MAX) { return true; } - Notificator.publish(getActivity(), R.string.error_setting_text_size_range); + Notificator.getInstance().publish(R.string.error_setting_text_size_range); } else { - Notificator.publish(getActivity(), R.string.error_setting_text_size_not_number); + Notificator.getInstance().publish(R.string.error_setting_text_size_not_number); } return false; } else if (preference.getKey().contentEquals(getString(R.string.key_setting_timelines))) { @@ -71,13 +71,13 @@ public class SettingFragment extends PreferenceFragment implements OnSharedPrefe if (UserPreferenceHelper.TIMELINES_MIN <= newTextSize && newTextSize <= UserPreferenceHelper.TIMELINES_MAX) { return true; } - Notificator.publish(getActivity(), R.string.error_setting_timelines_range); + Notificator.getInstance().publish(R.string.error_setting_timelines_range); } else { - Notificator.publish(getActivity(), R.string.error_setting_timelines_not_number); + Notificator.getInstance().publish(R.string.error_setting_timelines_not_number); } return false; } else if (preference.getKey().contentEquals(getString(R.string.key_setting_theme))) { - Notificator.publish(getActivity(), R.string.notice_theme_changed); + Notificator.getInstance().publish(R.string.notice_theme_changed); } return true; } @@ -96,7 +96,7 @@ public class SettingFragment extends PreferenceFragment implements OnSharedPrefe ConfirmDialogFragment.show(getActivity(), getString(R.string.dialog_confirm_clear_account), new Runnable() { @Override public void run() { - Notificator.publish(getActivity(), R.string.notice_cleared_account); + Notificator.getInstance().publish(R.string.notice_cleared_account); Account.deleteAll(); finishActivity(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java index 63c43645..620584eb 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java @@ -204,7 +204,7 @@ public class UserListFragment extends CustomListFragment implements View.OnClick } private void notifyTextEmpty(MainActivity activity) { - Notificator.publish(activity, R.string.notice_userlist_not_selected); + Notificator.getInstance().publish(R.string.notice_userlist_not_selected); } private void openUserListsDialog(final MainActivity mainActivity) { diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageDetailDialogFragment.java index bbe71d47..dec88dda 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageDetailDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageDetailDialogFragment.java @@ -119,7 +119,7 @@ public class MessageDetailDialogFragment extends StackableDialogFragment impleme DirectMessage selectedMessage = DirectMessage.fetch(getMessageID()); if (selectedMessage == null) { - Notificator.publish(getActivity(), R.string.notice_error_get_messages); + Notificator.getInstance().publish(R.string.notice_error_get_messages); return new DisposeDialog(getActivity()); } View header = getTitleView(activity, account, selectedMessage); @@ -173,7 +173,7 @@ public class MessageDetailDialogFragment extends StackableDialogFragment impleme ConfirmDialogFragment.show(getActivity(), getString(R.string.dialog_confirm_commands), new Runnable() { @Override public void run() { - new DeleteMessageTask(new TwitterApi(account).getTwitter(), message.getId(), getActivity()).execute(); + new DeleteMessageTask(new TwitterApi(account).getTwitter(), message.getId()).execute(); dismiss(); } }); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/PostMenuDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/PostMenuDialogFragment.java index 761ed5d3..bfb1d36e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/PostMenuDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/PostMenuDialogFragment.java @@ -50,7 +50,7 @@ public class PostMenuDialogFragment extends MenuDialogFragment { List<Command> commands = getCommands(activity); Command.filter(commands); if (commands.isEmpty()) { - Notificator.publish(getActivity(), R.string.notice_no_commands_available); + Notificator.getInstance().publish(R.string.notice_no_commands_available); dismiss(); } for (Command command : commands) { diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectSearchQueryDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectSearchQueryDialogFragment.java index 2e2a05ed..78d8fb3e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectSearchQueryDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SelectSearchQueryDialogFragment.java @@ -58,7 +58,7 @@ public class SelectSearchQueryDialogFragment extends MenuDialogFragment implemen adapter.update(); command.getQuery().delete(); - Notificator.publish(getActivity(), R.string.notice_search_query_deleted); + Notificator.getInstance().publish(R.string.notice_search_query_deleted); } }, false); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/SendMessageDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SendMessageDialogFragment.java index 7e350648..b17e77c2 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/SendMessageDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/SendMessageDialogFragment.java @@ -157,7 +157,7 @@ public class SendMessageDialogFragment extends StackableDialogFragment implement MainActivity activity = (MainActivity) getActivity(); Twitter twitter = TwitterApi.getTwitter(activity.getCurrentAccount()); String text = editText.getText().toString(); - new SendMessageTask(twitter, screenName, text, activity).execute(); + new SendMessageTask(twitter, screenName, text).execute(); hideIME(); dismiss(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java index 137c8ebd..2f0a50dc 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java @@ -159,7 +159,7 @@ public class StatusDetailDialogFragment extends StackableDialogFragment implemen confirm(activity, new Runnable() { @Override public void run() { - new DeleteStatusTask(TwitterApi.getTwitter(account), tweet.getOriginalTweet().getId(), activity).execute(); + new DeleteStatusTask(TwitterApi.getTwitter(account), tweet.getOriginalTweet().getId()).execute(); dismiss(); } }); @@ -288,9 +288,9 @@ public class StatusDetailDialogFragment extends StackableDialogFragment implemen private void toggleFavorite(MainActivity activity, Account account, Tweet tweet, Boolean isFavorited) { long statusID = tweet.getOriginalTweet().getId(); if (isFavorited) { - new UnfavoriteTask(TwitterApi.getTwitter(account), statusID, activity).execute(); + new UnfavoriteTask(TwitterApi.getTwitter(account), statusID).execute(); } else { - new FavoriteTask(TwitterApi.getTwitter(account), statusID, activity).execute(); + new FavoriteTask(TwitterApi.getTwitter(account), statusID).execute(); } } @@ -299,9 +299,9 @@ public class StatusDetailDialogFragment extends StackableDialogFragment implemen @Override public void run() { if (retweetID != -1L) { - new DeleteStatusTask(TwitterApi.getTwitter(account), retweetID, activity).execute(); + new DeleteStatusTask(TwitterApi.getTwitter(account), retweetID).execute(); } else { - new RetweetTask(TwitterApi.getTwitter(account), tweet.getOriginalTweet().getId(), activity).execute(); + new RetweetTask(TwitterApi.getTwitter(account), tweet.getOriginalTweet().getId()).execute(); } } }); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java index d38d1677..8c7cdd53 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java @@ -375,7 +375,7 @@ public class UserDetailDialogFragment extends StackableDialogFragment implements Boolean isFollowing = buttonFollow.getTag() != null ? (Boolean) buttonFollow.getTag() : false; Twitter twitter = new TwitterApi(account).getTwitter(); if (isFollowing) { - new UnfollowTask(twitter, user.getId(), activity) { + new UnfollowTask(twitter, user.getId()) { @Override public void onPostExecute(User result) { super.onPostExecute(result); @@ -384,7 +384,7 @@ public class UserDetailDialogFragment extends StackableDialogFragment implements } }.execute(); } else { - new FollowTask(twitter, user.getId(), activity) { + new FollowTask(twitter, user.getId()) { @Override public void onPostExecute(User result) { super.onPostExecute(result); |