fix dragged view showing in previous location briefly

This commit is contained in:
darthpaul 2021-09-24 22:43:35 +01:00
parent f033539193
commit f87ca68946
1 changed files with 7 additions and 3 deletions

View File

@ -286,7 +286,12 @@ class WeekFragment : Fragment(), WeeklyCalendar {
event?.let { event?.let {
val currentStartTime = Formatter.getDateTimeFromTS(it.startTS) val currentStartTime = Formatter.getDateTimeFromTS(it.startTS)
val startTime = Formatter.getDateTimeFromTS(weekTimestamp + index * DAY_SECONDS) val startTime = Formatter.getDateTimeFromTS(weekTimestamp + index * DAY_SECONDS)
.withTime(startHour, currentStartTime.minuteOfHour, currentStartTime.secondOfMinute, currentStartTime.millisOfSecond).seconds() .withTime(
startHour,
currentStartTime.minuteOfHour,
currentStartTime.secondOfMinute,
currentStartTime.millisOfSecond
).seconds()
val currentEventDuration = event.endTS - event.startTS val currentEventDuration = event.endTS - event.startTS
val endTime = startTime + currentEventDuration val endTime = startTime + currentEventDuration
context?.eventsHelper?.updateEvent( context?.eventsHelper?.updateEvent(
@ -771,14 +776,13 @@ class WeekFragment : Fragment(), WeeklyCalendar {
return when (dragEvent.action) { return when (dragEvent.action) {
DragEvent.ACTION_DRAG_STARTED -> currentlyDraggedView == view DragEvent.ACTION_DRAG_STARTED -> currentlyDraggedView == view
DragEvent.ACTION_DRAG_ENTERED -> { DragEvent.ACTION_DRAG_ENTERED -> {
view.beInvisible() view.beGone()
false false
} }
// handle ACTION_DRAG_LOCATION due to https://stackoverflow.com/a/19460338 // handle ACTION_DRAG_LOCATION due to https://stackoverflow.com/a/19460338
DragEvent.ACTION_DRAG_LOCATION -> true DragEvent.ACTION_DRAG_LOCATION -> true
DragEvent.ACTION_DRAG_ENDED -> { DragEvent.ACTION_DRAG_ENDED -> {
currentlyDraggedView = null currentlyDraggedView = null
view.beVisible()
true true
} }
else -> false else -> false