use of com.ichi2.async.DeckTask.TaskData 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.async.DeckTask.TaskData in project Anki-Android by Ramblurr.
the class DeckTask method doInBackgroundUpdateValuesFromDeck.
private TaskData doInBackgroundUpdateValuesFromDeck(TaskData... params) {
Log.i(AnkiDroidApp.TAG, "doInBackgroundUpdateValuesFromDeck");
try {
Sched sched = params[0].getCollection().getSched();
Object[] obj = params[0].getObjArray();
boolean reset = (Boolean) obj[0];
if (reset) {
sched.reset();
}
int[] counts = sched.counts();
int totalNewCount = sched.totalNewForCurrentDeck();
int totalCount = sched.cardCount();
double progressMature = ((double) sched.matureCount()) / ((double) totalCount);
double progressAll = 1 - (((double) (totalNewCount + counts[1])) / ((double) totalCount));
double[][] serieslist = null;
// only calculate stats if necessary
if ((Boolean) obj[1]) {
serieslist = Stats.getSmallDueStats(sched.getCol());
}
return new TaskData(new Object[] { counts[0], counts[1], counts[2], totalNewCount, totalCount, progressMature, progressAll, sched.eta(counts), serieslist });
} catch (RuntimeException e) {
Log.e(AnkiDroidApp.TAG, "doInBackgroundUpdateValuesFromDeck - an error occurred: " + e);
return null;
}
}
use of com.ichi2.async.DeckTask.TaskData 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.async.DeckTask.TaskData 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.async.DeckTask.TaskData 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;
}
Aggregations