summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/View.java
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-03-08 11:14:07 -0800
committerRomain Guy <romainguy@google.com>2012-03-08 15:05:12 -0800
commitbb9908b828a8cfd5965553be66faa6af89973697 (patch)
tree33ab74a9cb8ad69058cece5ae83d4b82f7b51633 /core/java/android/view/View.java
parent3bef5e9f3aa90465ee3ab66ef33d7a88d1b0c5c1 (diff)
downloadframeworks_base-bb9908b828a8cfd5965553be66faa6af89973697.zip
frameworks_base-bb9908b828a8cfd5965553be66faa6af89973697.tar.gz
frameworks_base-bb9908b828a8cfd5965553be66faa6af89973697.tar.bz2
Dispatch screen state change events to Views
Bug #6120957 Using this new callback, views can interrupt and resume their animations or other periodic tasks based on the current state of the display. Change-Id: I398f4abd421e9c5f207107bf1009a7b92cf45daa
Diffstat (limited to 'core/java/android/view/View.java')
-rw-r--r--core/java/android/view/View.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 94531c8..14e2d6f 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1994,6 +1994,20 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
public static final int FIND_VIEWS_WITH_ACCESSIBILITY_NODE_PROVIDERS = 0x00000004;
/**
+ * Indicates that the screen has changed state and is now off.
+ *
+ * @see #onScreenStateChanged(int)
+ */
+ public static final int SCREEN_STATE_OFF = 0x0;
+
+ /**
+ * Indicates that the screen has changed state and is now on.
+ *
+ * @see #onScreenStateChanged(int
+ */
+ public static final int SCREEN_STATE_ON = 0x1;
+
+ /**
* Controls the over-scroll mode for this view.
* See {@link #overScrollBy(int, int, int, int, int, int, int, int, boolean)},
* {@link #OVER_SCROLL_ALWAYS}, {@link #OVER_SCROLL_IF_CONTENT_SCROLLS},
@@ -9604,6 +9618,25 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
}
/**
+ * @see #onScreenStateChanged(int)
+ */
+ void dispatchScreenStateChanged(int screenState) {
+ onScreenStateChanged(screenState);
+ }
+
+ /**
+ * This method is called whenever the state of the screen this view is
+ * attached to changes. A state change will usually occurs when the screen
+ * turns on or off (whether it happens automatically or the user does it
+ * manually.)
+ *
+ * @param screenState The new state of the screen. Can be either
+ * {@link #SCREEN_STATE_ON} or {@link #SCREEN_STATE_OFF}
+ */
+ public void onScreenStateChanged(int screenState) {
+ }
+
+ /**
* Resolve and cache the layout direction. LTR is set initially. This is implicitly supposing
* that the parent directionality can and will be resolved before its children.
*/