From 33cd18099ba9ad779257d3c347b699651d46c987 Mon Sep 17 00:00:00 2001 From: Agnieszka C <85929121+Aga-C@users.noreply.github.com> Date: Sun, 16 Jul 2023 17:27:40 +0200 Subject: [PATCH] Reverting dragged view instead of refreshing calendar --- .../calendar/pro/fragments/WeekFragment.kt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt index fc6dad119..681971e15 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt @@ -191,6 +191,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { fun updateCalendar() { if (context != null) { + currentlyDraggedView = null WeeklyCalendarImpl(this, requireContext()).updateWeeklyCalendar(weekTimestamp) } } @@ -299,9 +300,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { activity.hideKeyboard() when (it) { null -> { - // force update by removing hash - lastHash = 0 - updateCalendar() + revertDraggedEvent() } EDIT_SELECTED_OCCURRENCE -> { context?.eventsHelper?.editSelectedOccurrence(newEvent, false) { @@ -323,8 +322,12 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } } else { - context?.eventsHelper?.updateEvent(newEvent, updateAtCalDAV = true, showToasts = false) { - updateCalendar() + if (event.startTS == newEvent.startTS && event.endTS == newEvent.endTS) { + revertDraggedEvent() + } else { + context?.eventsHelper?.updateEvent(newEvent, updateAtCalDAV = true, showToasts = false) { + updateCalendar() + } } } } @@ -340,6 +343,13 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } + private fun revertDraggedEvent() { + activity?.runOnUiThread { + currentlyDraggedView?.beVisible() + currentlyDraggedView = null + } + } + private fun getViewGestureDetector(view: ViewGroup, index: Int): GestureDetector { return GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() { override fun onSingleTapUp(event: MotionEvent): Boolean { @@ -932,7 +942,6 @@ class WeekFragment : Fragment(), WeeklyCalendar { if (!dragEvent.result) { view.beVisible() } - currentlyDraggedView = null true } else -> false