MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / loop

Method loop

src/activities/reader/KOReaderSyncActivity.cpp:391–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389}
390
391void KOReaderSyncActivity::loop() {
392 if (state == NO_CREDENTIALS || state == SYNC_FAILED || state == UPLOAD_COMPLETE) {
393 if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
394 returnToReader();
395 }
396 return;
397 }
398
399 if (state == SHOWING_RESULT) {
400 // Navigate options
401 if (mappedInput.wasReleased(MappedInputManager::Button::Up) ||
402 mappedInput.wasReleased(MappedInputManager::Button::Left)) {
403 selectedOption = (selectedOption + 1) % 2; // Wrap around among 2 options
404 requestUpdate();
405 } else if (mappedInput.wasReleased(MappedInputManager::Button::Down) ||
406 mappedInput.wasReleased(MappedInputManager::Button::Right)) {
407 selectedOption = (selectedOption + 1) % 2; // Wrap around among 2 options
408 requestUpdate();
409 }
410
411 if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
412 if (selectedOption == 0) {
413 saveProgressAndReturn(remotePosition.spineIndex, remotePosition.pageNumber);
414 } else if (selectedOption == 1) {
415 // Upload local progress
416 performUpload();
417 }
418 }
419
420 if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
421 returnToReader();
422 }
423 return;
424 }
425
426 if (state == NO_REMOTE_PROGRESS) {
427 if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
428 // Calculate hash if not done yet
429 if (documentHash.empty()) {
430 if (KOREADER_STORE.getMatchMethod() == DocumentMatchMethod::FILENAME) {
431 documentHash = KOReaderDocumentId::calculateFromFilename(epubPath);
432 } else {
433 documentHash = KOReaderDocumentId::calculate(epubPath);
434 }
435 }
436 performUpload();
437 }
438
439 if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
440 returnToReader();
441 }
442 return;
443 }
444}

Callers

nothing calls this directly

Calls 3

getMatchMethodMethod · 0.80
wasReleasedMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected