-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweak withProgress() to work without collection; handle colpkg progress
- Loading branch information
Showing
3 changed files
with
32 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import com.ichi2.libanki.CollectionV16 | |
import com.ichi2.libanki.awaitBackupCompletion | ||
import com.ichi2.libanki.createBackup | ||
import kotlinx.coroutines.* | ||
import timber.log.Timber | ||
|
||
fun DeckPicker.performBackupInBackground() { | ||
val col = CollectionHelper.getInstance().getCol(baseContext).newBackend | ||
|
@@ -33,12 +34,20 @@ fun DeckPicker.performBackupInBackground() { | |
} | ||
} | ||
|
||
// TODO: show progress indicator | ||
fun DeckPicker.importColpkg(colpkgPath: String) { | ||
val deckPicker = this | ||
catchingLifecycleScope(this) { | ||
runInBackground { | ||
CollectionHelper.getInstance().importColpkg(baseContext, colpkgPath) | ||
val helper = CollectionHelper.getInstance() | ||
val backend = helper.getOrCreateBackend(baseContext) | ||
backend.withProgress({ | ||
if (it.hasImporting()) { | ||
// TODO: show progress in GUI | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dae
Author
Contributor
|
||
Timber.i("%s", it.importing) | ||
} | ||
}) { | ||
helper.importColpkg(baseContext, colpkgPath) | ||
} | ||
deckPicker.updateDeckList() | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
could be captured as part of GSoC notification project - "there should be a generic facility for posting sticky foreground notifications that accept notification content updates (for progress indication)"