diff options
author | paphonb <paphonb@gmail.com> | 2019-09-19 23:14:18 +0700 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-12-12 15:18:16 +0200 |
commit | e49f77061e4b5582ae1561407bda9f5e209609a8 (patch) | |
tree | 084a77311c5286f3f0ac7fa9ebfbf9f4ec612f58 | |
parent | 23c20a9d2b17e83c2daa0bb11f521d6aef245d2f (diff) | |
download | android_packages_apps_Trebuchet-e49f77061e4b5582ae1561407bda9f5e209609a8.tar.gz android_packages_apps_Trebuchet-e49f77061e4b5582ae1561407bda9f5e209609a8.tar.bz2 android_packages_apps_Trebuchet-e49f77061e4b5582ae1561407bda9f5e209609a8.zip |
Launcher3: Fix launcher preview rendering
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
Change-Id: I8c6fc263a3021f3ff929bc75b2730962b29d3758
Signed-off-by: DennySPB <dennyspb@gmail.com>
-rw-r--r-- | src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java index 31fcc8c64..6866c827d 100644 --- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java +++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java @@ -49,6 +49,7 @@ import com.android.launcher3.allapps.SearchUiManager; import com.android.launcher3.anim.PropertySetter; import com.android.launcher3.graphics.TintedDrawableSpan; import com.android.launcher3.util.ComponentKey; +import com.android.launcher3.views.ActivityContext; import java.util.ArrayList; @@ -61,6 +62,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText private final Launcher mLauncher; + private final ActivityContext mActivity; private final AllAppsSearchBarController mSearchBarController; private final SpannableStringBuilder mSearchQueryBuilder; @@ -82,7 +84,8 @@ public class AppsSearchContainerLayout extends ExtendedEditText public AppsSearchContainerLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - mLauncher = Launcher.getLauncher(context); + mActivity = ActivityContext.lookupContext(context); + mLauncher = tryGetLauncher(context); mSearchBarController = new AllAppsSearchBarController(); mSearchQueryBuilder = new SpannableStringBuilder(); @@ -94,6 +97,14 @@ public class AppsSearchContainerLayout extends ExtendedEditText setHint(prefixTextWithIcon(getContext(), R.drawable.ic_allapps_search, getHint())); } + private Launcher tryGetLauncher(Context context) { + try { + return Launcher.getLauncher(context); + } catch (IllegalArgumentException e) { + return null; + } + } + @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); @@ -109,7 +120,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Update the width to match the grid padding - DeviceProfile dp = mLauncher.getDeviceProfile(); + DeviceProfile dp = mActivity.getDeviceProfile(); int myRequestedWidth = getSize(widthMeasureSpec); int rowWidth = myRequestedWidth - mAppsView.getActiveRecyclerView().getPaddingLeft() - mAppsView.getActiveRecyclerView().getPaddingRight(); @@ -207,7 +218,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText @Override public float getScrollRangeDelta(Rect insets) { - if (mLauncher.getDeviceProfile().isVerticalBarLayout()) { + if (mActivity.getDeviceProfile().isVerticalBarLayout()) { return 0; } else { int topMargin = Math.round(Math.max( |