summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/ViewRootImpl.java
diff options
context:
space:
mode:
authorFilip Gruszczynski <gruszczy@google.com>2015-03-12 15:12:43 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-03-12 15:12:45 +0000
commitc6ee744a90a4a84df93b6631ca7df8736ef320e1 (patch)
treed0a3ddbfc27576225908af776a964af848ba8822 /core/java/android/view/ViewRootImpl.java
parent80c24d4a27573b90368e78a155abe90849db1b06 (diff)
parent954289d9a9b1a26b1621037a427269bdbd67d5bc (diff)
downloadframeworks_base-c6ee744a90a4a84df93b6631ca7df8736ef320e1.zip
frameworks_base-c6ee744a90a4a84df93b6631ca7df8736ef320e1.tar.gz
frameworks_base-c6ee744a90a4a84df93b6631ca7df8736ef320e1.tar.bz2
Merge "Allow polling for WindowInsets."
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
-rw-r--r--core/java/android/view/ViewRootImpl.java35
1 files changed, 29 insertions, 6 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 7cd12d5..f970e88 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -265,6 +265,8 @@ public final class ViewRootImpl implements ViewParent,
final Rect mDispatchContentInsets = new Rect();
final Rect mDispatchStableInsets = new Rect();
+ private WindowInsets mLastWindowInsets;
+
final Configuration mLastConfiguration = new Configuration();
final Configuration mPendingConfiguration = new Configuration();
@@ -550,6 +552,11 @@ public final class ViewRootImpl implements ViewParent,
mPendingContentInsets.set(mAttachInfo.mContentInsets);
mPendingStableInsets.set(mAttachInfo.mStableInsets);
mPendingVisibleInsets.set(0, 0, 0, 0);
+ try {
+ relayoutWindow(attrs, getHostVisibility(), false);
+ } catch (RemoteException e) {
+ if (DEBUG_LAYOUT) Log.e(TAG, "failed to relayoutWindow", e);
+ }
if (DEBUG_LAYOUT) Log.v(TAG, "Added window " + mWindow);
if (res < WindowManagerGlobal.ADD_OKAY) {
mAttachInfo.mRootView = null;
@@ -1227,13 +1234,29 @@ public final class ViewRootImpl implements ViewParent,
m.postTranslate(-mAttachInfo.mWindowLeft, -mAttachInfo.mWindowTop);
}
+ /* package */ WindowInsets getWindowInsets(boolean forceConstruct) {
+ if (mLastWindowInsets == null || forceConstruct) {
+ mDispatchContentInsets.set(mAttachInfo.mContentInsets);
+ mDispatchStableInsets.set(mAttachInfo.mStableInsets);
+ Rect contentInsets = mDispatchContentInsets;
+ Rect stableInsets = mDispatchStableInsets;
+ // For dispatch we preserve old logic, but for direct requests from Views we allow to
+ // immediately use pending insets.
+ if (!forceConstruct
+ && (!mPendingContentInsets.equals(contentInsets) ||
+ !mPendingStableInsets.equals(stableInsets))) {
+ contentInsets = mPendingContentInsets;
+ stableInsets = mPendingStableInsets;
+ }
+ final boolean isRound = (mIsEmulator && mIsCircularEmulator) || mWindowIsRound;
+ mLastWindowInsets = new WindowInsets(contentInsets,
+ null /* windowDecorInsets */, stableInsets, isRound);
+ }
+ return mLastWindowInsets;
+ }
+
void dispatchApplyInsets(View host) {
- mDispatchContentInsets.set(mAttachInfo.mContentInsets);
- mDispatchStableInsets.set(mAttachInfo.mStableInsets);
- final boolean isRound = (mIsEmulator && mIsCircularEmulator) || mWindowIsRound;
- host.dispatchApplyWindowInsets(new WindowInsets(
- mDispatchContentInsets, null /* windowDecorInsets */,
- mDispatchStableInsets, isRound));
+ host.dispatchApplyWindowInsets(getWindowInsets(true /* forceConstruct */));
}
private void performTraversals() {