Fixing widgets get deteled because of double bind
If the AppWidgetHost starts listening in the middle of bind, it rebinds the old widgets before a new widget is bound, leading to double bind. We should clear all pending binds, before starting a rebind. As an extra check only rebind a view which is attached to the screen. Bug: 73814840 Change-Id: Ie3af683dc4095b158547e700d11e4faf7999466f
This commit is contained in:
parent
efa671294e
commit
c11fac355d
|
@ -2239,6 +2239,7 @@ public class Launcher extends BaseActivity
|
||||||
// Clear the workspace because it's going to be rebound
|
// Clear the workspace because it's going to be rebound
|
||||||
mWorkspace.clearDropTargets();
|
mWorkspace.clearDropTargets();
|
||||||
mWorkspace.removeAllWorkspaceScreens();
|
mWorkspace.removeAllWorkspaceScreens();
|
||||||
|
mAppWidgetHost.clearViews();
|
||||||
|
|
||||||
if (mHotseat != null) {
|
if (mHotseat != null) {
|
||||||
mHotseat.resetLayout();
|
mHotseat.resetLayout();
|
||||||
|
|
|
@ -236,7 +236,7 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void clearViews() {
|
public void clearViews() {
|
||||||
super.clearViews();
|
super.clearViews();
|
||||||
mViews.clear();
|
mViews.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -488,13 +488,14 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView
|
||||||
// Only reinflate when the final configuration is same as the required configuration
|
// Only reinflate when the final configuration is same as the required configuration
|
||||||
if (mReinflateOnConfigChange && isSameOrientation()) {
|
if (mReinflateOnConfigChange && isSameOrientation()) {
|
||||||
mReinflateOnConfigChange = false;
|
mReinflateOnConfigChange = false;
|
||||||
if (isAttachedToWindow()) {
|
reInflate();
|
||||||
reInflate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reInflate() {
|
public void reInflate() {
|
||||||
|
if (!isAttachedToWindow()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) getTag();
|
LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) getTag();
|
||||||
// Remove and rebind the current widget (which was inflated in the wrong
|
// Remove and rebind the current widget (which was inflated in the wrong
|
||||||
// orientation), but don't delete it from the database
|
// orientation), but don't delete it from the database
|
||||||
|
|
Loading…
Reference in New Issue