mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-18 18:28:20 +00:00
Fix LayoutParams cast exception in drag-n-drop
Test: Pick up a widget from home screen. Then drop it and immediately
pick it up again before the resize frame is dismissed. No crash
is observed.
Bug: 186663184
Change-Id: Ia40676fbbf5d6dc2e2043aa7acd6ae00f1fa4179
This commit is contained in:
@@ -71,6 +71,22 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
|
||||
|
||||
private final View[] mDragHandles = new View[HANDLE_COUNT];
|
||||
private final List<Rect> mSystemGestureExclusionRects = new ArrayList<>(HANDLE_COUNT);
|
||||
private final OnAttachStateChangeListener mWidgetViewAttachStateChangeListener =
|
||||
new OnAttachStateChangeListener() {
|
||||
@Override
|
||||
public void onViewAttachedToWindow(View view) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDetachedFromWindow(View view) {
|
||||
// When the app widget view is detached, we should close the resize frame.
|
||||
// An example is when the dragging starts, the widget view is detached from
|
||||
// CellLayout and then reattached to DragLayout.
|
||||
close(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private LauncherAppWidgetHostView mWidgetView;
|
||||
private CellLayout mCellLayout;
|
||||
@@ -191,7 +207,11 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
|
||||
private void setupForWidget(LauncherAppWidgetHostView widgetView, CellLayout cellLayout,
|
||||
DragLayer dragLayer) {
|
||||
mCellLayout = cellLayout;
|
||||
if (mWidgetView != null) {
|
||||
mWidgetView.removeOnAttachStateChangeListener(mWidgetViewAttachStateChangeListener);
|
||||
}
|
||||
mWidgetView = widgetView;
|
||||
mWidgetView.addOnAttachStateChangeListener(mWidgetViewAttachStateChangeListener);
|
||||
LauncherAppWidgetProviderInfo info = (LauncherAppWidgetProviderInfo)
|
||||
widgetView.getAppWidgetInfo();
|
||||
mResizeMode = info.resizeMode;
|
||||
@@ -641,6 +661,9 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
|
||||
@Override
|
||||
protected void handleClose(boolean animate) {
|
||||
mDragLayer.removeView(this);
|
||||
if (mWidgetView != null) {
|
||||
mWidgetView.removeOnAttachStateChangeListener(mWidgetViewAttachStateChangeListener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user