diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-11-11 10:41:26 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-11-11 13:43:13 -0800 |
commit | 0bbd5548ac4b8d6f1c28ee5c83363af3fe29a650 (patch) | |
tree | e103595168a4ab8a759dc5c091be0d004d50d59c /src/com/android/launcher3/Launcher.java | |
parent | 47a96054d97c042bd97b61795accbb9a59fd8ad0 (diff) | |
download | android_packages_apps_Trebuchet-0bbd5548ac4b8d6f1c28ee5c83363af3fe29a650.tar.gz android_packages_apps_Trebuchet-0bbd5548ac4b8d6f1c28ee5c83363af3fe29a650.tar.bz2 android_packages_apps_Trebuchet-0bbd5548ac4b8d6f1c28ee5c83363af3fe29a650.zip |
Moving the setContentView at the end of onCreate
In multi-window mode, when the activity is resized, the window might
exist even before onCreate, which could call onAttachToWindow while
they are being inflated. Many Views in Launcher assume
onAttachToWindow to be called after onCreate has completed.
Bug: 32745705
Change-Id: Id6ee68826c4f3cc579880540812fd8ed834f8267
Diffstat (limited to 'src/com/android/launcher3/Launcher.java')
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 0540249b6..0a5d44e20 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -392,7 +392,7 @@ public class Launcher extends Activity // LauncherModel load. mPaused = false; - setContentView(R.layout.launcher); + mLauncherView = getLayoutInflater().inflate(R.layout.launcher, null); setupViews(); mDeviceProfile.layout(this, false /* notifyListeners */); @@ -444,12 +444,18 @@ public class Launcher extends Activity // we want the screen to auto-rotate based on the current orientation setOrientation(); + setContentView(mLauncherView); if (mLauncherCallbacks != null) { mLauncherCallbacks.onCreate(savedInstanceState); } } @Override + public View findViewById(int id) { + return mLauncherView.findViewById(id); + } + + @Override public void onExtractedColorsChanged() { loadExtractedColorsAndColorItems(); } @@ -1268,7 +1274,6 @@ public class Launcher extends Activity * Finds all the views we need and configure them properly. */ private void setupViews() { - mLauncherView = findViewById(R.id.launcher); mDragLayer = (DragLayer) findViewById(R.id.drag_layer); mFocusHandler = mDragLayer.getFocusIndicatorHelper(); mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace); |