use of com.ichi2.async.TaskData in project AnkiChinaAndroid by ankichinateam.
the class SelfStudyActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// FIXME:
Timber.d("onActivityResult(requestCode=%d, resultCode=%d)", requestCode, resultCode);
if (data != null) {
Timber.d("onActivityResult data (reloadRequired=%s, noteChanged=%s)", data.getBooleanExtra("reloadRequired", false), data.getBooleanExtra("noteChanged", false));
}
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == DeckPicker.RESULT_DB_ERROR) {
closeCardBrowser(DeckPicker.RESULT_DB_ERROR);
}
if (requestCode == EDIT_CARD && resultCode != RESULT_CANCELED) {
Timber.i("CardBrowser:: CardBrowser: Saving card...");
CollectionTask.launchCollectionTask(UPDATE_NOTE, updateCardHandler(), new TaskData(sCardBrowserCard, false));
} else if (requestCode == ADD_NOTE && resultCode == RESULT_OK) {
if (mSearchView != null) {
mSearchTerms = mSearchView.getQuery().toString();
searchCards();
} else {
Timber.w("Note was added from browser and on return mSearchView == null");
}
}
// }
if (requestCode == PREVIEW_CARDS && data != null && (data.getBooleanExtra("reloadRequired", false) || data.getBooleanExtra("noteChanged", false))) {
searchCards();
if (getReviewerCardId() == mCurrentCardId) {
mReloadRequired = true;
}
}
if (requestCode == EDIT_CARD && data != null && (data.getBooleanExtra("reloadRequired", false) || data.getBooleanExtra("noteChanged", false))) {
// if reloadRequired or noteChanged flag was sent from note editor then reload card list
searchCards();
// in use by reviewer?
if (getReviewerCardId() == mCurrentCardId) {
mReloadRequired = true;
}
}
// maybe the availability of undo changed
invalidateOptionsMenu();
}
use of com.ichi2.async.TaskData in project AnkiChinaAndroid by ankichinateam.
the class UIUtils method saveCollectionInBackground.
public static void saveCollectionInBackground(boolean syncIgnoresDatabaseModification) {
if (CollectionHelper.getInstance().colIsOpen()) {
TaskListener listener = new TaskListener() {
@Override
public void onPreExecute() {
Timber.d("saveCollectionInBackground: start");
}
@Override
public void onPostExecute(TaskData result) {
Timber.d("saveCollectionInBackground: finished");
}
};
CollectionTask.launchCollectionTask(SAVE_COLLECTION, listener, new TaskData(syncIgnoresDatabaseModification));
}
}
use of com.ichi2.async.TaskData in project AnkiChinaAndroid by ankichinateam.
the class Previewer2 method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_edit:
editCard();
return true;
case R.id.action_suspend:
if (mCurrentCard != null && mCurrentCard.getQueue() == Consts.QUEUE_TYPE_SUSPENDED) {
Toast.makeText(Previewer2.this, "已恢复该卡牌", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(Previewer2.this, "已暂停该卡牌", Toast.LENGTH_SHORT).show();
}
blockControls(false);
CollectionTask.launchCollectionTask(DISMISS, mDismissCardHandler, new TaskData(new Object[] { mCurrentCard, Collection.DismissType.SUSPEND_CARD }));
return true;
case R.id.action_delete:
showDeleteNoteDialog();
return true;
case R.id.action_flag_zero:
flagTask(0);
return true;
case R.id.action_flag_one:
flagTask(1);
return true;
case R.id.action_flag_two:
flagTask(2);
return true;
case R.id.action_flag_three:
flagTask(3);
return true;
case R.id.action_flag_four:
flagTask(4);
return true;
case R.id.action_mark_card:
onMark(mCurrentCard);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
use of com.ichi2.async.TaskData in project AnkiChinaAndroid by ankichinateam.
the class Previewer2 method showDeleteNoteDialog.
@Override
protected void showDeleteNoteDialog() {
Resources res = getResources();
new MaterialDialog.Builder(this).title(res.getString(R.string.delete_card_title)).iconAttr(R.attr.dialogErrorIcon).content(res.getString(R.string.delete_note_message, Utils.stripHTML(mCurrentCard.q(true)))).positiveText(res.getString(R.string.dialog_positive_delete)).negativeText(res.getString(R.string.dialog_cancel)).onPositive((dialog, which) -> {
Timber.i("AbstractFlashcardViewer:: OK button pressed to delete note %d", mCurrentCard.getNid());
mSoundPlayer.stopSounds();
blockControls(false);
CollectionTask.launchCollectionTask(DISMISS, mDismissCardHandler, new TaskData(new Object[] { mCurrentCard, Collection.DismissType.DELETE_NOTE }));
mCardList[mIndex] = mCardList[mCardList.length - 1];
// 数组缩容
mCardList = Arrays.copyOf(mCardList, mCardList.length - 1);
mIndex--;
mNextCardLayout.performClick();
// updateScreenCounts();
Toast.makeText(Previewer2.this, "成功删除卡牌", Toast.LENGTH_SHORT).show();
}).build().show();
}
use of com.ichi2.async.TaskData in project AnkiChinaAndroid by ankichinateam.
the class Reviewer method performReload.
@Override
protected void performReload() {
getCol().getSched().deferReset();
CollectionTask.launchCollectionTask(ANSWER_CARD, mAnswerCardHandler(false), new TaskData(null, 0));
}
Aggregations