use of com.ichi2.async.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.TaskData in project Anki-Android by Ramblurr.
the class DeckTask method doInBackgroundUpdateNote.
private TaskData doInBackgroundUpdateNote(TaskData[] params) {
// Log.i(AnkiDroidApp.TAG, "doInBackgroundUpdateNote");
// Save the note
Sched sched = params[0].getSched();
Collection col = sched.getCol();
Card editCard = params[0].getCard();
Note editNote = editCard.note();
boolean fromReviewer = params[0].getBoolean();
// mark undo
col.markUndo(Collection.UNDO_EDIT_NOTE, new Object[] { col.getNote(editNote.getId()), editCard.getId(), fromReviewer });
try {
col.getDb().getDatabase().beginTransaction();
try {
// TODO: undo integration
editNote.flush();
// flush card too, in case, did has been changed
editCard.flush();
if (fromReviewer) {
Card newCard;
if (col.getDecks().active().contains(editCard.getDid())) {
newCard = editCard;
newCard.load();
// reload qa-cache
newCard.getQuestion(true);
} else {
newCard = getCard(sched);
}
publishProgress(new TaskData(newCard));
} else {
publishProgress(new TaskData(editCard, editNote.stringTags()));
}
col.getDb().getDatabase().setTransactionSuccessful();
} finally {
col.getDb().getDatabase().endTransaction();
}
} catch (RuntimeException e) {
Log.e(AnkiDroidApp.TAG, "doInBackgroundUpdateNote - RuntimeException on updating fact: " + e);
AnkiDroidApp.saveExceptionReportFile(e, "doInBackgroundUpdateNote");
return new TaskData(false);
}
return new TaskData(true);
}
use of com.ichi2.async.TaskData in project Anki-Android by Ramblurr.
the class DeckPicker method onStop.
@Override
protected void onStop() {
Log.i(AnkiDroidApp.TAG, "DeckPicker - onStop");
super.onStop();
if (!mDontSaveOnStop) {
if (isFinishing()) {
DeckTask.launchDeckTask(DeckTask.TASK_TYPE_CLOSE_DECK, mCloseCollectionHandler, new TaskData(AnkiDroidApp.getCol()));
} else {
StudyOptionsFragment frag = getFragment();
if (!(frag != null && !frag.dbSaveNecessary())) {
UIUtils.saveCollectionInBackground();
}
}
}
}
use of com.ichi2.async.TaskData in project Anki-Android by Ramblurr.
the class DeckTask method doInBackgroundLoadDeckCounts.
private TaskData doInBackgroundLoadDeckCounts(TaskData... params) {
Log.i(AnkiDroidApp.TAG, "doInBackgroundLoadDeckCounts");
Collection col = params[0].getCollection();
if (col == null) {
return null;
}
try {
return new TaskData(col.getSched().deckCounts());
} catch (RuntimeException e) {
Log.e(AnkiDroidApp.TAG, "doInBackgroundLoadDeckCounts - error: " + e);
return null;
}
}
use of com.ichi2.async.TaskData in project Anki-Android by Ramblurr.
the class DeckTask method doInBackgroundDeleteDeck.
private TaskData doInBackgroundDeleteDeck(TaskData... params) {
// Log.i(AnkiDroidApp.TAG, "doInBackgroundDeleteDeck");
Collection col = params[0].getCollection();
long did = params[0].getLong();
col.getDecks().rem(did, true);
col.getMedia().removeUnusedImages();
return doInBackgroundLoadDeckCounts(new TaskData(col));
}
Aggregations