[UI] Update indentation, again. Fix manual event color selecting.

This commit is contained in:
Kuba Szczodrzyński 2019-11-21 18:43:01 +01:00
parent ce06084e6f
commit 82852389fa

View File

@ -57,8 +57,7 @@ class EventManualV2Dialog(
private lateinit var event: Event
private var customColor: Int? = null
init {
run {
init { run {
if (activity.isFinishing)
return@run
job = Job()
@ -89,8 +88,7 @@ class EventManualV2Dialog(
}*/
}
b.showMore.onClick {
// TODO iconics is broken
b.showMore.onClick { // TODO iconics is broken
it.apply {
refreshDrawableState()
@ -102,11 +100,9 @@ class EventManualV2Dialog(
}
loadLists()
}
}
}}
private fun loadLists() {
launch {
private fun loadLists() { launch {
val deferred = async(Dispatchers.Default) {
// get the team list
val teams = app.db.teamDao().getAllNow(profileId)
@ -174,16 +170,15 @@ class EventManualV2Dialog(
}
b.typeDropdown.setOnChangeListener {
b.typeDropdown.background.colorFilter = PorterDuffColorFilter((it.tag as EventType).color, PorterDuff.Mode.SRC_ATOP)
b.typeColor.background.colorFilter = PorterDuffColorFilter((it.tag as EventType).color, PorterDuff.Mode.SRC_ATOP)
customColor = null
return@setOnChangeListener true
}
customColor?.let {
b.typeDropdown.background.colorFilter = PorterDuffColorFilter(it, PorterDuff.Mode.SRC_ATOP)
(customColor ?: Event.COLOR_DEFAULT).let {
b.typeColor.background.colorFilter = PorterDuffColorFilter(it, PorterDuff.Mode.SRC_ATOP)
}
b.typeColor.onClick {
val currentColor = (b.typeDropdown?.selected?.tag as EventType?)?.color
?: Event.COLOR_DEFAULT
val currentColor = (b.typeDropdown?.selected?.tag as EventType?)?.color ?: Event.COLOR_DEFAULT
val colorPickerDialog = ColorPickerDialog.newBuilder()
.setColor(currentColor)
.create()
@ -191,7 +186,7 @@ class EventManualV2Dialog(
object : ColorPickerDialogListener {
override fun onDialogDismissed(dialogId: Int) {}
override fun onColorSelected(dialogId: Int, color: Int) {
b.typeDropdown.background.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)
b.typeColor.background.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)
customColor = color
}
})
@ -199,11 +194,9 @@ class EventManualV2Dialog(
}
loadDates()
}
}
}}
private fun loadDates() {
launch {
private fun loadDates() { launch {
val date = Date.getToday()
val today = date.value
var weekDay = date.weekDay
@ -349,8 +342,7 @@ class EventManualV2Dialog(
}
loadHours()
}
}
}}
private fun loadHours(defaultHour: Time? = null) {
b.timeDropdown.isEnabled = false
@ -378,7 +370,8 @@ class EventManualV2Dialog(
lesson.displayStartTime?.stringHM ?: "",
lesson.displaySubjectName?.let {
when {
lesson.type == Lesson.TYPE_CANCELLED -> it.asStrikethroughSpannable()
lesson.type == Lesson.TYPE_CANCELLED
|| lesson.type == Lesson.TYPE_SHIFTED_SOURCE -> it.asStrikethroughSpannable()
lesson.type != Lesson.TYPE_NORMAL -> it.asItalicSpannable()
else -> it
}
@ -405,7 +398,8 @@ class EventManualV2Dialog(
// clear subject, teacher selection
b.subjectDropdown.deselect()
b.teacherDropdown.deselect()
} else {
}
else {
editingEvent?.let {
b.timeDropdown.select(it.startTime?.value?.toLong())
}