use of com.ichi2.libanki.Collection in project Anki-Android by Ramblurr.
the class DeckTask method doInBackgroundSearchCards.
private TaskData doInBackgroundSearchCards(TaskData... params) {
Log.i(AnkiDroidApp.TAG, "doInBackgroundSearchCards");
Collection col = (Collection) params[0].getObjArray()[0];
HashMap<String, String> deckNames = (HashMap<String, String>) params[0].getObjArray()[1];
String query = (String) params[0].getObjArray()[2];
String order = (String) params[0].getObjArray()[3];
TaskData result = new TaskData(col.findCardsForCardBrowser(query, order, deckNames));
if (DeckTask.taskIsCancelled()) {
return null;
} else {
publishProgress(result);
}
return new TaskData(col.cardCount(col.getDecks().allIds()));
}
use of com.ichi2.libanki.Collection in project Anki-Android by Ramblurr.
the class DeckTask method doInBackgroundRestoreDeck.
private TaskData doInBackgroundRestoreDeck(TaskData... params) {
Log.i(AnkiDroidApp.TAG, "doInBackgroundRestoreDeck");
Object[] data = params[0].getObjArray();
Collection col = (Collection) data[0];
if (col != null) {
col.close(false);
}
return new TaskData(BackupManager.restoreBackup((String) data[1], (String) data[2]));
}
use of com.ichi2.libanki.Collection in project Anki-Android by Ramblurr.
the class DeckTask method doInBackgroundCloseCollection.
private TaskData doInBackgroundCloseCollection(TaskData... params) {
Log.i(AnkiDroidApp.TAG, "doInBackgroundCloseCollection");
Collection col = params[0].getCollection();
if (col != null) {
try {
WidgetStatus.waitToFinish();
String path = col.getPath();
AnkiDroidApp.closeCollection(true);
BackupManager.performBackup(path);
} catch (RuntimeException e) {
Log.i(AnkiDroidApp.TAG, "doInBackgroundCloseCollection: error occurred - collection not properly closed");
}
}
return null;
}
use of com.ichi2.libanki.Collection in project Anki-Android by Ramblurr.
the class DeckTask method doInBackgroundSaveCollection.
private TaskData doInBackgroundSaveCollection(TaskData... params) {
Log.i(AnkiDroidApp.TAG, "doInBackgroundSaveCollection");
Collection col = params[0].getCollection();
if (col != null) {
try {
col.save();
} catch (RuntimeException e) {
Log.e(AnkiDroidApp.TAG, "Error on saving deck in background: " + e);
}
}
return null;
}
use of com.ichi2.libanki.Collection in project Anki-Android by Ramblurr.
the class DeckTask method doInBackgroundRepairDeck.
private TaskData doInBackgroundRepairDeck(TaskData... params) {
Log.i(AnkiDroidApp.TAG, "doInBackgroundRepairDeck");
String deckPath = params[0].getString();
Collection col = params[0].getCollection();
if (col != null) {
col.close(false);
}
return new TaskData(BackupManager.repairDeck(deckPath));
}
Aggregations