summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java')
-rw-r--r--src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java17
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(