properly unregister some widgets for changes
This commit is contained in:
parent
10373af40d
commit
72c6801bc0
|
@ -91,13 +91,9 @@ 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)
|
||||
|
||||
post {
|
||||
removeView(widgetViews.firstOrNull { it.tag == item.widgetId })
|
||||
}
|
||||
removeItemFromHomeScreen(item)
|
||||
post {
|
||||
removeView(widgetViews.firstOrNull { it.tag == item.widgetId })
|
||||
}
|
||||
|
||||
gridItems.removeIf { it.id == item.id }
|
||||
|
@ -105,6 +101,18 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||
}
|
||||
}
|
||||
|
||||
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