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