| 423 | // --- Input handling --- |
| 424 | |
| 425 | void FontDownloadActivity::loop() { |
| 426 | if (state_ == FAMILY_LIST) { |
| 427 | if (mappedInput.wasPressed(MappedInputManager::Button::Back)) { |
| 428 | finish(); |
| 429 | return; |
| 430 | } |
| 431 | |
| 432 | const int listSize = listItemCount(); |
| 433 | const int pageItems = UITheme::getNumberOfItemsPerPage(renderer, true, false, true, false); |
| 434 | |
| 435 | buttonNavigator_.onNextRelease([this, listSize] { |
| 436 | selectedIndex_ = ButtonNavigator::nextIndex(selectedIndex_, listSize); |
| 437 | requestUpdate(); |
| 438 | }); |
| 439 | |
| 440 | buttonNavigator_.onPreviousRelease([this, listSize] { |
| 441 | selectedIndex_ = ButtonNavigator::previousIndex(selectedIndex_, listSize); |
| 442 | requestUpdate(); |
| 443 | }); |
| 444 | |
| 445 | buttonNavigator_.onNextContinuous([this, listSize, pageItems] { |
| 446 | selectedIndex_ = ButtonNavigator::nextPageIndex(selectedIndex_, listSize, pageItems); |
| 447 | requestUpdate(); |
| 448 | }); |
| 449 | |
| 450 | buttonNavigator_.onPreviousContinuous([this, listSize, pageItems] { |
| 451 | selectedIndex_ = ButtonNavigator::previousPageIndex(selectedIndex_, listSize, pageItems); |
| 452 | requestUpdate(); |
| 453 | }); |
| 454 | |
| 455 | if (mappedInput.wasPressed(MappedInputManager::Button::Confirm)) { |
| 456 | if (!families_.empty()) { |
| 457 | if (isDownloadAllRow(selectedIndex_)) { |
| 458 | currentFileIndex_ = 0; |
| 459 | currentFileTotal_ = 0; |
| 460 | for (const auto& f : families_) { |
| 461 | if (!f.installed) currentFileTotal_ += f.files.size(); |
| 462 | } |
| 463 | |
| 464 | downloadAll(); |
| 465 | } else if (isUpdateAllRow(selectedIndex_)) { |
| 466 | currentFileIndex_ = 0; |
| 467 | currentFileTotal_ = 0; |
| 468 | for (const auto& f : families_) { |
| 469 | if (f.hasUpdate) currentFileTotal_ += f.files.size(); |
| 470 | } |
| 471 | updateAll(); |
| 472 | } else { |
| 473 | auto& family = families_[familyIndexFromList(selectedIndex_)]; |
| 474 | if (!family.installed || family.hasUpdate) { |
| 475 | currentFileIndex_ = 0; |
| 476 | currentFileTotal_ = family.files.size(); |
| 477 | downloadFamily(family); |
| 478 | } else { |
| 479 | promptDeleteSelectedFamily(); |
| 480 | return; |
| 481 | } |
| 482 | } |
nothing calls this directly
no test coverage detected