Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Unified Diff: base/android/java/src/org/chromium/base/ApplicationStatus.java

Issue 2386323002: Add IntDef support to ApplicationStatus. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/android/java/src/org/chromium/base/ActivityState.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/ApplicationStatus.java
diff --git a/base/android/java/src/org/chromium/base/ApplicationStatus.java b/base/android/java/src/org/chromium/base/ApplicationStatus.java
index d1bd2fb59212c814e20efda98c8113000b98ffa8..7c5bbee74f2aaec53d17e2ce37a95311ab6fadd0 100644
--- a/base/android/java/src/org/chromium/base/ApplicationStatus.java
+++ b/base/android/java/src/org/chromium/base/ApplicationStatus.java
@@ -9,6 +9,8 @@ import android.app.Application;
import android.app.Application.ActivityLifecycleCallbacks;
import android.os.Bundle;
+import org.chromium.base.ActivityState.ActivityStateEnum;
+import org.chromium.base.ApplicationState.ApplicationStateEnum;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.MainDex;
@@ -34,6 +36,7 @@ public class ApplicationStatus {
/**
* @return The current {@link ActivityState} of the activity.
*/
+ @ActivityStateEnum
public int getStatus() {
return mStatus;
}
@@ -41,7 +44,7 @@ public class ApplicationStatus {
/**
* @param status The new {@link ActivityState} of the activity.
*/
- public void setStatus(int status) {
+ public void setStatus(@ActivityStateEnum int status) {
mStatus = status;
}
@@ -54,6 +57,7 @@ public class ApplicationStatus {
}
private static Object sCachedApplicationStateLock = new Object();
+ @ApplicationStateEnum
private static Integer sCachedApplicationState;
/** Last activity that was shown (or null if none or it was destroyed). */
@@ -89,7 +93,7 @@ public class ApplicationStatus {
* Called when the application's state changes.
* @param newState The application state.
*/
- public void onApplicationStateChange(int newState);
+ public void onApplicationStateChange(@ApplicationStateEnum int newState);
}
/**
@@ -101,7 +105,7 @@ public class ApplicationStatus {
* @param activity The activity that had a state change.
* @param newState New activity state.
*/
- public void onActivityStateChange(Activity activity, int newState);
+ public void onActivityStateChange(Activity activity, @ActivityStateEnum int newState);
}
private ApplicationStatus() {}
@@ -170,7 +174,7 @@ public class ApplicationStatus {
* @param activity Current activity.
* @param newState New state value.
*/
- private static void onStateChange(Activity activity, int newState) {
+ private static void onStateChange(Activity activity, @ActivityStateEnum int newState) {
if (activity == null) throw new IllegalArgumentException("null activity is not supported");
if (sActivity == null
@@ -291,6 +295,7 @@ public class ApplicationStatus {
* @param activity The activity whose state is to be returned.
* @return The state of the specified activity (see {@link ActivityState}).
*/
+ @ActivityStateEnum
public static int getStateForActivity(Activity activity) {
ActivityInfo info = sActivityInfo.get(activity);
return info != null ? info.getStatus() : ActivityState.DESTROYED;
@@ -299,6 +304,7 @@ public class ApplicationStatus {
/**
* @return The state of the application (see {@link ApplicationState}).
*/
+ @ApplicationStateEnum
@CalledByNative
public static int getStateForApplication() {
synchronized (sCachedApplicationStateLock) {
@@ -432,6 +438,7 @@ public class ApplicationStatus {
* HAS_STOPPED_ACTIVITIES if none are running/paused and one is stopped.
* HAS_DESTROYED_ACTIVITIES if none are running/paused/stopped.
*/
+ @ApplicationStateEnum
private static int determineApplicationState() {
boolean hasPausedActivity = false;
boolean hasStoppedActivity = false;
@@ -456,5 +463,5 @@ public class ApplicationStatus {
// Called to notify the native side of state changes.
// IMPORTANT: This is always called on the main thread!
- private static native void nativeOnApplicationStateChange(int newState);
+ private static native void nativeOnApplicationStateChange(@ApplicationStateEnum int newState);
}
« no previous file with comments | « base/android/java/src/org/chromium/base/ActivityState.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698