Update task type events as well on drag-n-drop

Fixes https://github.com/SimpleMobileTools/Simple-Calendar/issues/1709
This commit is contained in:
Naveen 2022-05-16 03:24:12 +05:30
parent 096685dc2a
commit 0649f10cec
2 changed files with 4 additions and 3 deletions

View File

@ -35,8 +35,6 @@ import kotlinx.android.synthetic.main.week_event_marker.view.*
import org.joda.time.DateTime import org.joda.time.DateTime
import org.joda.time.Days import org.joda.time.Days
import java.util.* import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.LinkedHashMap
class WeekFragment : Fragment(), WeeklyCalendar { class WeekFragment : Fragment(), WeeklyCalendar {
private val WEEKLY_EVENT_ID_LABEL = "event_id_label" private val WEEKLY_EVENT_ID_LABEL = "event_id_label"
@ -268,7 +266,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
val eventId = dragEvent.clipData.getItemAt(0).text.toString().toLong() val eventId = dragEvent.clipData.getItemAt(0).text.toString().toLong()
val startHour = (dragEvent.y / rowHeight).toInt() val startHour = (dragEvent.y / rowHeight).toInt()
ensureBackgroundThread { ensureBackgroundThread {
val event = context?.eventsDB?.getEventWithId(eventId) val event = context?.eventsDB?.getEventOrTaskWithId(eventId)
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)

View File

@ -21,6 +21,9 @@ interface EventsDao {
@Query("SELECT * FROM events WHERE id = :id AND type = $TYPE_TASK") @Query("SELECT * FROM events WHERE id = :id AND type = $TYPE_TASK")
fun getTaskWithId(id: Long): Event? fun getTaskWithId(id: Long): Event?
@Query("SELECT * FROM events WHERE id = :id AND type = $TYPE_EVENT OR type = $TYPE_TASK")
fun getEventOrTaskWithId(id: Long): Event?
@Query("SELECT * FROM events WHERE import_id = :importId AND type = $TYPE_EVENT") @Query("SELECT * FROM events WHERE import_id = :importId AND type = $TYPE_EVENT")
fun getEventWithImportId(importId: String): Event? fun getEventWithImportId(importId: String): Event?