Reverting dragged view instead of refreshing calendar

This commit is contained in:
Agnieszka C 2023-07-16 17:27:40 +02:00
parent 1e2ba7d0d5
commit 33cd18099b
1 changed files with 15 additions and 6 deletions

View File

@ -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) {
@ -322,6 +321,9 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
}
}
} else {
if (event.startTS == newEvent.startTS && event.endTS == newEvent.endTS) {
revertDraggedEvent()
} else {
context?.eventsHelper?.updateEvent(newEvent, updateAtCalDAV = true, showToasts = false) {
updateCalendar()
@ -329,6 +331,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
}
}
}
true
} catch (ignored: Exception) {
false
@ -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