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