diff options
Diffstat (limited to 'app/src')
3 files changed, 10 insertions, 20 deletions
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 50230313..eab7152f 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java @@ -46,7 +46,6 @@ import net.lacolaco.smileessence.R; import net.lacolaco.smileessence.data.PostState; 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; @@ -61,14 +60,9 @@ import net.lacolaco.smileessence.util.*; import net.lacolaco.smileessence.view.*; 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.*; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; - public class MainActivity extends Activity { // ------------------------------ FIELDS ------------------------------ @@ -253,7 +247,7 @@ public class MainActivity extends Activity { if (stream != null) { stream.shutdown(); } - Notificator.getInstance().stopNotification(); + Notificator.getInstance().onBackground(); Logger.debug("onDestroy"); } @@ -273,7 +267,7 @@ public class MainActivity extends Activity { super.onPause(); Logger.debug("onPause"); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - Notificator.getInstance().stopNotification(); + Notificator.getInstance().onBackground(); } @Override @@ -281,7 +275,7 @@ public class MainActivity extends Activity { super.onResume(); Logger.debug("onResume"); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - Notificator.getInstance().startNotification(); + Notificator.getInstance().onForeground(); } // -------------------------- OTHER METHODS -------------------------- @@ -500,5 +494,4 @@ public class MainActivity extends Activity { private void startOAuthActivity() { startActivityForResult(new Intent(this, OAuthActivity.class), REQUEST_OAUTH); } - } 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 4488253d..16662337 100644 --- a/app/src/main/java/net/lacolaco/smileessence/notification/Notificator.java +++ b/app/src/main/java/net/lacolaco/smileessence/notification/Notificator.java @@ -34,14 +34,11 @@ import de.keyboardsurfer.android.widget.crouton.Style; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.util.UIHandler; -import java.util.concurrent.ConcurrentLinkedDeque; -import java.util.concurrent.ConcurrentLinkedQueue; - public class Notificator { private static Notificator instance; private static final int DURATION = 1000; private Activity activity; - private boolean isRunning; + private boolean isForeground; public static void initialize(Activity activity) { instance = new Notificator(activity); @@ -77,7 +74,7 @@ public class Notificator { new UIHandler() { @Override public void run() { - if (isRunning) { + if (isForeground) { Logger.debug(String.format("notify by crouton %s", text)); Crouton.makeText(activity, text, getStyle(type)).show(); } else { @@ -88,12 +85,12 @@ public class Notificator { }.post(); } - public void startNotification() { - isRunning = true; + public void onForeground() { + isForeground = true; } - public void stopNotification() { - isRunning = false; + public void onBackground() { + isForeground = false; Crouton.cancelAllCroutons(); } 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 d82b740a..a7075cc6 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java @@ -81,7 +81,7 @@ public class SearchFragment extends CustomListFragment<SearchListAdapter> implem // ------------------------ INTERFACE METHODS ------------------------ - @Override // onCreate って Fragment のインスタンスが作られるときは必ず呼ばれるって認識でいいんだよね? + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); |