comboctl-main: Only receive frames if long RT button press was skipped

The code in adjustQuantityOnScreen() needs an current quantity. This is
determined during the long button press. If no such long button press
happens, get the quantity by explicitly receiving parsed frames. But
don't read those parsed frames if a long button press happened; this
is redundant and just slows down the function.

Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
Carlos Rafael Giani 2022-11-20 18:34:59 +01:00
parent 03a32f09cf
commit 8b2666ff74

View file

@ -706,6 +706,8 @@ suspend fun adjustQuantityOnScreen(
return
}
val currentQuantity: Int
if (longRTButtonPressPredicate(targetQuantity, initialQuantity)) {
val needToIncrement = checkIfNeedsToIncrement(initialQuantity)
logger(LogLevel.DEBUG) {
@ -815,17 +817,17 @@ suspend fun adjustQuantityOnScreen(
"Second phase: last seen quantity $lastQuantity is not the target quantity; " +
"short-pressing RT button(s) to finetune it"
}
}
val currentQuantity: Int
while (true) {
val parsedDisplayFrame = rtNavigationContext.getParsedDisplayFrame(filterDuplicates = true) ?: continue
val parsedScreen = parsedDisplayFrame.parsedScreen
val quantity = getQuantity(parsedScreen)
if (quantity != null) {
currentQuantity = quantity
break
currentQuantity = lastQuantity!!
} else {
while (true) {
val parsedDisplayFrame = rtNavigationContext.getParsedDisplayFrame(filterDuplicates = true) ?: continue
val parsedScreen = parsedDisplayFrame.parsedScreen
val quantity = getQuantity(parsedScreen)
if (quantity != null) {
currentQuantity = quantity
break
}
}
}