Improve blocker flashing
This commit is contained in:
parent
0e9a480dd8
commit
25875b162e
@ -403,12 +403,10 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
var isFlashing: Boolean
|
||||
get() {
|
||||
if (flashingSince == null) {
|
||||
return false
|
||||
}
|
||||
val flashingSince = flashingSince ?: return false
|
||||
|
||||
if (flashingSince!!.millis >= 1200L) {
|
||||
flashingSince = null
|
||||
if (flashingSince.millis >= 1200L) {
|
||||
this.flashingSince = null
|
||||
return false
|
||||
}
|
||||
|
||||
@ -416,8 +414,14 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
set(value) {
|
||||
if (value) {
|
||||
flashingSince = SystemTime()
|
||||
popup()
|
||||
if (screen is MatteryScreen<*>) {
|
||||
screen.popup(findAbsoluteRoot() as EditablePanel<MatteryScreen<*>>)
|
||||
}
|
||||
|
||||
if (!flashAnyBlocker(true)) {
|
||||
flashingSince = SystemTime()
|
||||
findAbsoluteRoot().requestFocus()
|
||||
}
|
||||
} else {
|
||||
flashingSince = null
|
||||
}
|
||||
@ -466,23 +470,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
protected fun flashAnyBlocker(doFlash: Boolean = true): Boolean {
|
||||
var blockingWindow = blockingWindow
|
||||
var parent = parent
|
||||
|
||||
while (blockingWindow == null && parent != null) {
|
||||
blockingWindow = parent.blockingWindow
|
||||
parent = parent.parent
|
||||
}
|
||||
|
||||
if (blockingWindow == null) {
|
||||
return flashAnyBlockerInner(doFlash)
|
||||
}
|
||||
|
||||
if (doFlash) {
|
||||
blockingWindow.isFlashing = true
|
||||
}
|
||||
|
||||
return true
|
||||
return findAbsoluteRoot().flashAnyBlockerInner(doFlash)
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
@ -1732,17 +1720,17 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
isRemoved = true
|
||||
}
|
||||
|
||||
fun popup(focus: Boolean = true) {
|
||||
fun popup(focus: Boolean = true, doFlash: Boolean = true) {
|
||||
if (isRemoved) {
|
||||
return
|
||||
}
|
||||
|
||||
if (screen is MatteryScreen<*> && parent == null) {
|
||||
screen.popup(this as EditablePanel<MatteryScreen<*>>)
|
||||
if (screen is MatteryScreen<*>) {
|
||||
screen.popup(findAbsoluteRoot() as EditablePanel<MatteryScreen<*>>)
|
||||
}
|
||||
|
||||
if (focus) {
|
||||
requestFocus()
|
||||
if (focus && !flashAnyBlocker(doFlash)) {
|
||||
findAbsoluteRoot().requestFocus()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user