diff --git a/res/layout/qsb_container.xml b/res/layout/qsb_container.xml index 3de28760f1..55c7390d3e 100644 --- a/res/layout/qsb_container.xml +++ b/res/layout/qsb_container.xml @@ -20,4 +20,11 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/qsb_container" - android:padding="0dp" /> \ No newline at end of file + android:padding="0dp" > + + + \ No newline at end of file diff --git a/src/com/android/launcher3/QsbContainerView.java b/src/com/android/launcher3/QsbContainerView.java index 0a112d23e2..f931aba211 100644 --- a/src/com/android/launcher3/QsbContainerView.java +++ b/src/com/android/launcher3/QsbContainerView.java @@ -18,7 +18,6 @@ package com.android.launcher3; import android.app.Activity; import android.app.Fragment; -import android.app.FragmentManager; import android.app.SearchManager; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; @@ -44,8 +43,6 @@ import com.android.launcher3.compat.AppWidgetManagerCompat; */ public class QsbContainerView extends FrameLayout { - private boolean mBound; - public QsbContainerView(Context context) { super(context); } @@ -58,17 +55,6 @@ public class QsbContainerView extends FrameLayout { super(context, attrs, defStyleAttr); } - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - - if (!mBound) { - FragmentManager fm = ((Launcher) getContext()).getFragmentManager(); - fm.beginTransaction().add(R.id.qsb_container, new QsbFragment()).commit(); - mBound = true; - } - } - @Override public void setPadding(int left, int top, int right, int bottom) { super.setPadding(0, 0, 0, 0); @@ -103,6 +89,8 @@ public class QsbContainerView extends FrameLayout { getContext().registerReceiver(mRebindReceiver, filter); } + private FrameLayout mWrapper; + @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -110,7 +98,12 @@ public class QsbContainerView extends FrameLayout { if (savedInstanceState != null) { sSavedWidgetId = savedInstanceState.getInt(QSB_WIDGET_ID, -1); } + mWrapper = new FrameLayout(getContext()); + mWrapper.addView(createQsb(inflater, mWrapper)); + return mWrapper; + } + private View createQsb(LayoutInflater inflater, ViewGroup container) { Launcher launcher = (Launcher) getActivity(); mWidgetInfo = getSearchWidgetProvider(launcher); if (mWidgetInfo == null) { @@ -222,10 +215,9 @@ public class QsbContainerView extends FrameLayout { } private void rebindFragment() { - if (getActivity() != null) { - // Recreate the fragment. This will cause the qsb to be inflated again. - getActivity().getFragmentManager().beginTransaction() - .replace(R.id.qsb_container, new QsbFragment()).commit(); + if (mWrapper != null && getActivity() != null) { + mWrapper.removeAllViews(); + mWrapper.addView(createQsb(getActivity().getLayoutInflater(), mWrapper)); } }