properly unregister some widgets for changes
This commit is contained in:
parent
10373af40d
commit
72c6801bc0
|
@ -91,20 +91,28 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||
|
||||
fun removeAppIcon(item: HomeScreenGridItem) {
|
||||
ensureBackgroundThread {
|
||||
context.homeScreenGridItemsDB.deleteById(item.id!!)
|
||||
if (item.type == ITEM_TYPE_WIDGET) {
|
||||
appWidgetHost.deleteAppWidgetId(item.widgetId)
|
||||
|
||||
removeItemFromHomeScreen(item)
|
||||
post {
|
||||
removeView(widgetViews.firstOrNull { it.tag == item.widgetId })
|
||||
}
|
||||
}
|
||||
|
||||
gridItems.removeIf { it.id == item.id }
|
||||
redrawGrid()
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeItemFromHomeScreen(item: HomeScreenGridItem) {
|
||||
ensureBackgroundThread {
|
||||
if (item.id != null) {
|
||||
context.homeScreenGridItemsDB.deleteById(item.id!!)
|
||||
}
|
||||
|
||||
if (item.type == ITEM_TYPE_WIDGET) {
|
||||
appWidgetHost.deleteAppWidgetId(item.widgetId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun itemDraggingStarted(draggedGridItem: HomeScreenGridItem) {
|
||||
draggedItem = draggedGridItem
|
||||
if (draggedItem!!.drawable == null) {
|
||||
|
@ -288,19 +296,15 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||
activity.handleWidgetConfigureScreen(appWidgetHost, appWidgetId) { success ->
|
||||
if (success) {
|
||||
placeAppWidget(appWidgetId, appWidgetProviderInfo, item)
|
||||
} else if (item.id != null) {
|
||||
ensureBackgroundThread {
|
||||
context.homeScreenGridItemsDB.deleteById(item.id!!)
|
||||
}
|
||||
} else {
|
||||
removeItemFromHomeScreen(item)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
placeAppWidget(appWidgetId, appWidgetProviderInfo, item)
|
||||
}
|
||||
} else if (item.id != null) {
|
||||
ensureBackgroundThread {
|
||||
context.homeScreenGridItemsDB.deleteById(item.id!!)
|
||||
}
|
||||
} else {
|
||||
removeItemFromHomeScreen(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue