mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
Reset event type if last used event type was deleted
This commit is contained in:
@@ -17,6 +17,7 @@ import com.simplemobiletools.calendar.pro.extensions.*
|
|||||||
import com.simplemobiletools.calendar.pro.helpers.*
|
import com.simplemobiletools.calendar.pro.helpers.*
|
||||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||||
import com.simplemobiletools.calendar.pro.models.Event
|
import com.simplemobiletools.calendar.pro.models.Event
|
||||||
|
import com.simplemobiletools.calendar.pro.models.EventType
|
||||||
import com.simplemobiletools.calendar.pro.models.Reminder
|
import com.simplemobiletools.calendar.pro.models.Reminder
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
@@ -57,9 +58,11 @@ class TaskActivity : SimpleActivity() {
|
|||||||
return@ensureBackgroundThread
|
return@ensureBackgroundThread
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val storedEventTypes = eventTypesDB.getEventTypes().toMutableList() as ArrayList<EventType>
|
||||||
|
val localEventType = storedEventTypes.firstOrNull { it.id == config.lastUsedLocalEventTypeId }
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (!isDestroyed && !isFinishing) {
|
if (!isDestroyed && !isFinishing) {
|
||||||
gotTask(savedInstanceState, task)
|
gotTask(savedInstanceState, localEventType, task)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +129,11 @@ class TaskActivity : SimpleActivity() {
|
|||||||
updateTimeText()
|
updateTimeText()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotTask(savedInstanceState: Bundle?, task: Event?) {
|
private fun gotTask(savedInstanceState: Bundle?, localEventType: EventType?, task: Event?) {
|
||||||
|
if (localEventType == null) {
|
||||||
|
config.lastUsedLocalEventTypeId = REGULAR_EVENT_TYPE_ID
|
||||||
|
}
|
||||||
|
|
||||||
mEventTypeId = if (config.defaultEventTypeId == -1L) config.lastUsedLocalEventTypeId else config.defaultEventTypeId
|
mEventTypeId = if (config.defaultEventTypeId == -1L) config.lastUsedLocalEventTypeId else config.defaultEventTypeId
|
||||||
|
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
|
Reference in New Issue
Block a user