fix: stop longPressHandler when activity finishes
Some checks failed
Android CI / build (push) Has been cancelled

This commit is contained in:
Josia Pietsch 2025-06-05 12:02:37 +02:00
parent ce939111d0
commit 919108bbd0
Signed by: jrpie
GPG key ID: E70B571D66986A2D

View file

@ -160,7 +160,6 @@ class WidgetManagerView(widgetPanelId: Int, context: Context, attrs: AttributeSe
} }
if (event.actionMasked == MotionEvent.ACTION_UP) { if (event.actionMasked == MotionEvent.ACTION_UP) {
longPressHandler.removeCallbacksAndMessages(null)
val id = selectedWidgetOverlayView?.widgetId ?: return true val id = selectedWidgetOverlayView?.widgetId ?: return true
val widget = Widget.byId(id) ?: return true val widget = Widget.byId(id) ?: return true
widget.position = newPosition widget.position = newPosition
@ -176,9 +175,17 @@ class WidgetManagerView(widgetPanelId: Int, context: Context, attrs: AttributeSe
} }
private fun endInteraction() { private fun endInteraction() {
synchronized(this) {
longPressHandler.removeCallbacksAndMessages(null)
startWidgetPosition = null startWidgetPosition = null
selectedWidgetOverlayView?.mode = null selectedWidgetOverlayView?.mode = null
} }
}
override fun onDetachedFromWindow() {
endInteraction()
super.onDetachedFromWindow()
}
override fun updateWidgets(activity: Activity, widgets: Collection<Widget>?) { override fun updateWidgets(activity: Activity, widgets: Collection<Widget>?) {
super.updateWidgets(activity, widgets) super.updateWidgets(activity, widgets)