Wrapping thw widgetList inside a layout, so that it has the same view structure as allApps
Change-Id: I28b035beb1c7e13101ec20ff671d3cad5f757c0e
This commit is contained in:
parent
c42ac0a5a6
commit
a6194d3d92
|
@ -34,13 +34,20 @@
|
||||||
android:elevation="2dp"
|
android:elevation="2dp"
|
||||||
android:visibility="invisible" />
|
android:visibility="invisible" />
|
||||||
|
|
||||||
<com.android.launcher3.widget.WidgetsRecyclerView
|
<FrameLayout
|
||||||
android:id="@+id/main_content"
|
android:id="@+id/main_content"
|
||||||
android:theme="@style/Theme.Dark.CustomOverscroll"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:elevation="15dp"
|
android:elevation="15dp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.android.launcher3.widget.WidgetsRecyclerView
|
||||||
|
android:id="@+id/widgets_list_view"
|
||||||
|
android:theme="@style/Theme.Dark.CustomOverscroll"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
||||||
</com.android.launcher3.widget.WidgetsContainerView>
|
</com.android.launcher3.widget.WidgetsContainerView>
|
|
@ -138,6 +138,10 @@ public abstract class BaseContainerView extends FrameLayout implements Insettabl
|
||||||
mRevealView.setBackground(background.getConstantState().newDrawable());
|
mRevealView.setBackground(background.getConstantState().newDrawable());
|
||||||
mContent.setBackground(background);
|
mContent.setBackground(background);
|
||||||
|
|
||||||
|
// We let the content have a intent background, but still have full width.
|
||||||
|
// This allows the scroll bar to be used responsive outside the background bounds as well.
|
||||||
|
mContent.setPadding(0, 0, 0, 0);
|
||||||
|
|
||||||
Rect bgPadding = new Rect();
|
Rect bgPadding = new Rect();
|
||||||
background.getPadding(bgPadding);
|
background.getPadding(bgPadding);
|
||||||
onUpdateBgPadding(padding, bgPadding);
|
onUpdateBgPadding(padding, bgPadding);
|
||||||
|
|
|
@ -371,11 +371,6 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
|
||||||
mAdapter.updateBackgroundPadding(bgPadding);
|
mAdapter.updateBackgroundPadding(bgPadding);
|
||||||
mElevationController.updateBackgroundPadding(bgPadding);
|
mElevationController.updateBackgroundPadding(bgPadding);
|
||||||
|
|
||||||
// Hack: We are going to let the recycler view take the full width, so reset the padding on
|
|
||||||
// the container to zero after setting the background and apply the top-bottom padding to
|
|
||||||
// the content view instead so that the launcher transition clips correctly.
|
|
||||||
getContentView().setPadding(0, 0, 0, 0);
|
|
||||||
|
|
||||||
// Pad the recycler view by the background padding plus the start margin (for the section
|
// Pad the recycler view by the background padding plus the start margin (for the section
|
||||||
// names)
|
// names)
|
||||||
int maxScrollBarWidth = mAppsRecyclerView.getMaxScrollbarWidth();
|
int maxScrollBarWidth = mAppsRecyclerView.getMaxScrollbarWidth();
|
||||||
|
|
|
@ -20,7 +20,6 @@ import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.InsetDrawable;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView.State;
|
import android.support.v7.widget.RecyclerView.State;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
@ -65,7 +64,7 @@ public class WidgetsContainerView extends BaseContainerView
|
||||||
private IconCache mIconCache;
|
private IconCache mIconCache;
|
||||||
|
|
||||||
/* Recycler view related member variables */
|
/* Recycler view related member variables */
|
||||||
private WidgetsRecyclerView mView;
|
private WidgetsRecyclerView mRecyclerView;
|
||||||
private WidgetsListAdapter mAdapter;
|
private WidgetsListAdapter mAdapter;
|
||||||
|
|
||||||
/* Touch handling related member variables. */
|
/* Touch handling related member variables. */
|
||||||
|
@ -74,8 +73,6 @@ public class WidgetsContainerView extends BaseContainerView
|
||||||
/* Rendering related. */
|
/* Rendering related. */
|
||||||
private WidgetPreviewLoader mWidgetPreviewLoader;
|
private WidgetPreviewLoader mWidgetPreviewLoader;
|
||||||
|
|
||||||
private Rect mPadding = new Rect();
|
|
||||||
|
|
||||||
public WidgetsContainerView(Context context) {
|
public WidgetsContainerView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
|
@ -98,11 +95,11 @@ public class WidgetsContainerView extends BaseContainerView
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
mView = (WidgetsRecyclerView) getContentView();
|
mRecyclerView = (WidgetsRecyclerView) getContentView().findViewById(R.id.widgets_list_view);
|
||||||
mView.setAdapter(mAdapter);
|
mRecyclerView.setAdapter(mAdapter);
|
||||||
|
|
||||||
// This extends the layout space so that preloading happen for the {@link RecyclerView}
|
// This extends the layout space so that preloading happen for the {@link RecyclerView}
|
||||||
mView.setLayoutManager(new LinearLayoutManager(getContext()) {
|
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()) {
|
||||||
@Override
|
@Override
|
||||||
protected int getExtraLayoutSpace(State state) {
|
protected int getExtraLayoutSpace(State state) {
|
||||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||||
|
@ -110,8 +107,6 @@ public class WidgetsContainerView extends BaseContainerView
|
||||||
+ grid.availableHeightPx * PRELOAD_SCREEN_HEIGHT_MULTIPLE;
|
+ grid.availableHeightPx * PRELOAD_SCREEN_HEIGHT_MULTIPLE;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mPadding.set(getPaddingLeft(), getPaddingTop(), getPaddingRight(),
|
|
||||||
getPaddingBottom());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -119,7 +114,7 @@ public class WidgetsContainerView extends BaseContainerView
|
||||||
//
|
//
|
||||||
|
|
||||||
public void scrollToTop() {
|
public void scrollToTop() {
|
||||||
mView.scrollToPosition(0);
|
mRecyclerView.scrollToPosition(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -329,14 +324,14 @@ public class WidgetsContainerView extends BaseContainerView
|
||||||
//
|
//
|
||||||
@Override
|
@Override
|
||||||
protected void onUpdateBgPadding(Rect padding, Rect bgPadding) {
|
protected void onUpdateBgPadding(Rect padding, Rect bgPadding) {
|
||||||
mView.updateBackgroundPadding(bgPadding);
|
mRecyclerView.updateBackgroundPadding(bgPadding);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the widget data model.
|
* Initialize the widget data model.
|
||||||
*/
|
*/
|
||||||
public void addWidgets(WidgetsModel model) {
|
public void addWidgets(WidgetsModel model) {
|
||||||
mView.setWidgets(model);
|
mRecyclerView.setWidgets(model);
|
||||||
mAdapter.setWidgetsModel(model);
|
mAdapter.setWidgetsModel(model);
|
||||||
mAdapter.notifyDataSetChanged();
|
mAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue