Fix widgets getting stuck or disappearing #83
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is it?
Description of the changes in your PR
A Widget
gridItem
is created withwidgetId -1
.When a Widget was binded for the first time, a
widgetId
is generated byappWidgetHost
.However, this
widgetId
was not saved at DB.During an
onResume()
,refreshLaunchers()
would be called, and then callfetchGridItems()
.This would reset the
widgetId
to-1
and disconnect it from thewidgetId
generated byappWidgetHost
, causing weird behaviors.Another problem is that a new
widgetId
was being generated everytime we replaced the Widget at a restart process.Changed so
bindWidget()
is only called when binding the Widget for the first time, and then we save thewidgetId
at the DB.Later on, when recreating the screen, we retrieve the
widgetId
from DB and callplaceAppWidget()
to replace the Widget where it was.Fixes the following issue(s)
There are many Widget related issues.
Acknowledgement