use of com.ichi2.async.CollectionTask.TASK_TYPE.EMPTY_CRAM in project AnkiChinaAndroid by ankichinateam.
the class StudyOptionsFragment method onMenuItemClick.
@SuppressWarnings("deprecation")
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_browser:
{
Timber.i("DeckPicker:: Old browser button pressed");
getAnkiActivity().openOldCardBrowser();
return true;
}
case R.id.action_undo:
Timber.i("StudyOptionsFragment:: Undo button pressed");
CollectionTask.launchCollectionTask(UNDO, undoListener);
return true;
case R.id.action_deck_options:
Timber.i("StudyOptionsFragment:: Deck options button pressed");
if (getCol().getDecks().isDyn(getCol().getDecks().selected())) {
openFilteredDeckOptions();
} else {
Intent i = new Intent(getActivity(), DeckOptions.class);
getActivity().startActivityForResult(i, DECK_OPTIONS);
ActivityTransitionAnimation.slide(getActivity(), ActivityTransitionAnimation.FADE);
}
return true;
case R.id.action_setting:
Timber.i("StudyOptionsFragment:: Deck setting button pressed");
Intent i = new Intent(getActivity(), StudySettingActivity.class);
getActivity().startActivityForResult(i, DECK_OPTIONS);
ActivityTransitionAnimation.slide(getActivity(), ActivityTransitionAnimation.FADE);
return true;
case R.id.action_custom_study:
Timber.i("StudyOptionsFragment:: custom study button pressed");
showCustomStudyContextMenu();
return true;
case R.id.action_unbury:
Timber.i("StudyOptionsFragment:: unbury button pressed");
getCol().getSched().unburyCardsForDeck();
refreshInterfaceAndDecklist(true);
item.setVisible(false);
return true;
case R.id.action_rebuild:
Timber.i("StudyOptionsFragment:: rebuild cram deck button pressed");
mProgressDialog = StyledProgressDialog.show(getActivity(), "", getResources().getString(R.string.rebuild_filtered_deck), true);
CollectionTask.launchCollectionTask(REBUILD_CRAM, getCollectionTaskListener(true));
return true;
case R.id.action_empty:
Timber.i("StudyOptionsFragment:: empty cram deck button pressed");
mProgressDialog = StyledProgressDialog.show(getActivity(), "", getResources().getString(R.string.empty_filtered_deck), false);
CollectionTask.launchCollectionTask(EMPTY_CRAM, getCollectionTaskListener(true));
return true;
case R.id.action_rename:
((AnkiActivity) getActivity()).renameDeckDialog(getCol().getDecks().selected());
return true;
case R.id.action_delete:
getAnkiActivity().mContextMenuDid = getCol().getDecks().selected();
((AnkiActivity) getActivity()).confirmDeckDeletion(getCol().getDecks().selected());
return true;
case R.id.action_export:
((AnkiActivity) getActivity()).exportDeck(getCol().getDecks().selected());
return true;
case R.id.action_add_card:
addNote();
return true;
case R.id.create_deck:
getAnkiActivity().mContextMenuDid = getCol().getDecks().selected();
((AnkiActivity) getActivity()).createSubdeckDialog();
return true;
case // 停止/恢复
R.id.action_suspend:
mDeckIsStopped = deckIsStopped();
if (mDeckIsStopped) {
customDialog = new CustomStyleDialog.Builder(getAnkiActivity()).setTitle("恢复学习").setMessage("恢复学习后将每天新卡数和复习数值调整成默认值,请确认是否开始学习").setPositiveButton("确定", (dialog, which) -> {
resumeDeckStudy();
dialog.dismiss();
}).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
} else {
customDialog = new CustomStyleDialog.Builder(getAnkiActivity()).setTitle("停止学习").setMessage("暂停学习将会自动把每天新卡数和复习数调整为零,适用于有事暂停一两周不学习,若该记忆库学习的时长不超过2个月,又暂停了30天未学习,建议重设进度,重新开始学习").setPositiveButton("确定", (dialog, which) -> {
stopDeckStudy();
dialog.dismiss();
}).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
}
customDialog.show();
return true;
case // 重设学习进度
R.id.action_reset_card_progress:
customDialog = new CustomStyleDialog.Builder(getAnkiActivity()).setTitle("重设学习进度").setMessage("重设学习进度后,该记忆库的所有卡片学习记录都会被清除,请谨慎操作").setPositiveButton("确定", (dialog, which) -> {
CollectionTask.launchCollectionTask(RESET_DECK, new ResetCardHandler(StudyOptionsFragment.this), new TaskData(new Object[] { "deck:\"" + getCol().getDecks().current().getString("name") + "\" " }));
dialog.dismiss();
}).setNegativeButton("取消", (dialog, which) -> dialog.dismiss()).create();
customDialog.show();
return true;
default:
return false;
}
}
Aggregations