mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 10:54:36 -06:00
[UI] Fix updating event dialog when editing or removing.
This commit is contained in:
parent
5eaa754401
commit
ec765c9070
@ -32,7 +32,7 @@ import kotlin.coroutines.CoroutineContext
|
||||
|
||||
class EventDetailsDialog(
|
||||
val activity: AppCompatActivity,
|
||||
val event: EventFull,
|
||||
var event: EventFull,
|
||||
val onShowListener: ((tag: String) -> Unit)? = null,
|
||||
val onDismissListener: ((tag: String) -> Unit)? = null
|
||||
) : CoroutineScope {
|
||||
@ -139,6 +139,7 @@ class EventDetailsDialog(
|
||||
launch(Dispatchers.Default) {
|
||||
app.db.eventDao().replace(event)
|
||||
}
|
||||
update()
|
||||
b.checkDoneButton.isChecked = true
|
||||
}
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
@ -149,6 +150,7 @@ class EventDetailsDialog(
|
||||
launch(Dispatchers.Default) {
|
||||
app.db.eventDao().replace(event)
|
||||
}
|
||||
update()
|
||||
}
|
||||
}
|
||||
b.checkDoneButton.attachToastHint(R.string.hint_mark_as_done)
|
||||
@ -160,6 +162,14 @@ class EventDetailsDialog(
|
||||
activity,
|
||||
event.profileId,
|
||||
editingEvent = event,
|
||||
onSaveListener = {
|
||||
if (it == null) {
|
||||
dialog.dismiss()
|
||||
return@EventManualDialog
|
||||
}
|
||||
event = it
|
||||
update()
|
||||
},
|
||||
onShowListener = onShowListener,
|
||||
onDismissListener = onDismissListener
|
||||
)
|
||||
@ -327,8 +337,6 @@ class EventDetailsDialog(
|
||||
removeEventDialog?.dismiss()
|
||||
dialog.dismiss()
|
||||
Toast.makeText(activity, R.string.removed, Toast.LENGTH_SHORT).show()
|
||||
if (activity is MainActivity && activity.navTargetId == MainActivity.DRAWER_ITEM_AGENDA)
|
||||
activity.reloadTarget()
|
||||
}
|
||||
|
||||
private fun openInCalendar() { launch {
|
||||
|
@ -48,6 +48,7 @@ class EventManualDialog(
|
||||
val defaultTime: Time? = null,
|
||||
val defaultType: Long? = null,
|
||||
val editingEvent: EventFull? = null,
|
||||
val onSaveListener: ((event: EventFull?) -> Unit)? = null,
|
||||
val onShowListener: ((tag: String) -> Unit)? = null,
|
||||
val onDismissListener: ((tag: String) -> Unit)? = null
|
||||
) : CoroutineScope {
|
||||
@ -596,6 +597,7 @@ class EventManualDialog(
|
||||
}
|
||||
}
|
||||
|
||||
onSaveListener?.invoke(eventObject.withMetadata(metadataObject))
|
||||
dialog.dismiss()
|
||||
Toast.makeText(activity, R.string.saved, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
@ -608,6 +610,7 @@ class EventManualDialog(
|
||||
}
|
||||
|
||||
removeEventDialog?.dismiss()
|
||||
onSaveListener?.invoke(null)
|
||||
dialog.dismiss()
|
||||
Toast.makeText(activity, R.string.removed, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user