diff options
author | paphonb <paphonb@gmail.com> | 2019-09-19 23:14:18 +0700 |
---|---|---|
committer | Bruno Martins <bgcngm@gmail.com> | 2019-10-20 14:00:37 +0100 |
commit | 8318a4cea906ae62a062a0543cf03eafe54084e6 (patch) | |
tree | 8c65ea84c0199c207bdac336341f42e3d5682787 | |
parent | 83fa69f574dabe6c411f89f173fe6251e26fc0c2 (diff) | |
download | android_packages_apps_Trebuchet-8318a4cea906ae62a062a0543cf03eafe54084e6.tar.gz android_packages_apps_Trebuchet-8318a4cea906ae62a062a0543cf03eafe54084e6.tar.bz2 android_packages_apps_Trebuchet-8318a4cea906ae62a062a0543cf03eafe54084e6.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( |