use of android.content.DialogInterface.OnClickListener in project android_frameworks_base by ParanoidAndroid.
the class TrackerActivity method showConfirm.
private void showConfirm(int textId, final Runnable onConfirmAction) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setTitle(R.string.confirm_title);
dialogBuilder.setMessage(textId);
dialogBuilder.setPositiveButton(android.R.string.ok, new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
onConfirmAction.run();
}
});
dialogBuilder.setNegativeButton(android.R.string.cancel, new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
});
dialogBuilder.show();
}
use of android.content.DialogInterface.OnClickListener in project MPAndroidChart by PhilJay.
the class SimpleChartDemo method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_awesomedesign);
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setOffscreenPageLimit(3);
PageAdapter a = new PageAdapter(getSupportFragmentManager());
pager.setAdapter(a);
AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setTitle("This is a ViewPager.");
b.setMessage("Swipe left and right for more awesome design examples!");
b.setPositiveButton("OK", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
b.show();
}
use of android.content.DialogInterface.OnClickListener in project Anki-Android by Ramblurr.
the class CardBrowser method onCreateDialog.
@Override
protected Dialog onCreateDialog(int id) {
StyledDialog dialog = null;
Resources res = getResources();
StyledDialog.Builder builder = new StyledDialog.Builder(this);
switch(id) {
case DIALOG_ORDER:
builder.setTitle(res.getString(R.string.card_browser_change_display_order_title));
builder.setMessage(res.getString(R.string.card_browser_change_display_order_reverse));
builder.setIcon(android.R.drawable.ic_menu_sort_by_size);
builder.setSingleChoiceItems(res.getStringArray(R.array.card_browser_order_labels), mOrder, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int which) {
if (which != mOrder) {
mOrder = which;
mOrderAsc = false;
try {
if (mOrder == 0) {
mCol.getConf().put("sortType", fSortTypes[1]);
AnkiDroidApp.getSharedPrefs(getBaseContext()).edit().putBoolean("cardBrowserNoSorting", true).commit();
} else {
mCol.getConf().put("sortType", fSortTypes[mOrder]);
AnkiDroidApp.getSharedPrefs(getBaseContext()).edit().putBoolean("cardBrowserNoSorting", false).commit();
}
// default to descending for non-text fields
if (fSortTypes[mOrder].equals("noteFld")) {
mOrderAsc = true;
}
mCol.getConf().put("sortBackwards", mOrderAsc);
} catch (JSONException e) {
throw new RuntimeException(e);
}
searchCards();
} else if (which != CARD_ORDER_NONE) {
mOrderAsc = !mOrderAsc;
try {
mCol.getConf().put("sortBackwards", mOrderAsc);
} catch (JSONException e) {
throw new RuntimeException(e);
}
Collections.reverse(mCards);
updateList();
}
}
});
dialog = builder.create();
break;
case DIALOG_CONTEXT_MENU:
// FIXME:
String[] entries = new String[4];
@SuppressWarnings("unused") MenuItem item;
entries[CONTEXT_MENU_MARK] = res.getString(R.string.card_browser_mark_card);
entries[CONTEXT_MENU_SUSPEND] = res.getString(R.string.card_browser_suspend_card);
entries[CONTEXT_MENU_DELETE] = res.getString(R.string.card_browser_delete_card);
entries[CONTEXT_MENU_DETAILS] = res.getString(R.string.card_browser_card_details);
builder.setTitle("contextmenu");
builder.setIcon(R.drawable.ic_menu_manage);
builder.setItems(entries, mContextMenuListener);
dialog = builder.create();
break;
case DIALOG_TAGS:
allTags = mCol.getTags().all();
builder.setTitle(R.string.studyoptions_limit_select_tags);
builder.setMultiChoiceItems(allTags, new boolean[allTags.length], new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String tag = allTags[which];
if (mSelectedTags.contains(tag)) {
Log.i(AnkiDroidApp.TAG, "unchecked tag: " + tag);
mSelectedTags.remove(tag);
} else {
Log.i(AnkiDroidApp.TAG, "checked tag: " + tag);
mSelectedTags.add(tag);
}
}
});
builder.setPositiveButton(res.getString(R.string.select), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mSearchEditText.setText("");
String tags = mSelectedTags.toString();
mSearchEditText.setHint(getResources().getString(R.string.card_browser_tags_shown, tags.substring(1, tags.length() - 1)));
StringBuilder sb = new StringBuilder();
for (String tag : mSelectedTags) {
sb.append("tag:").append(tag).append(" ");
}
mSearchTerms = sb.toString();
searchCards();
}
});
builder.setNegativeButton(res.getString(R.string.cancel), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mSelectedTags.clear();
}
});
builder.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mSelectedTags.clear();
}
});
dialog = builder.create();
break;
}
return dialog;
}
use of android.content.DialogInterface.OnClickListener in project Anki-Android by Ramblurr.
the class Preferences method onCreateDialog.
@Override
protected Dialog onCreateDialog(int id) {
Resources res = getResources();
StyledDialog.Builder builder = new StyledDialog.Builder(this);
switch(id) {
case DIALOG_BACKUP:
builder.setTitle(res.getString(R.string.backup_manager_title));
builder.setCancelable(false);
builder.setMessage(res.getString(R.string.pref_backup_warning));
builder.setPositiveButton(res.getString(R.string.yes), new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
lockCheckAction = true;
useBackupPreference.setChecked(false);
dialogMessage = getResources().getString(R.string.backup_delete);
DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DELETE_BACKUPS, mDeckOperationHandler, (DeckTask.TaskData[]) null);
}
});
builder.setNegativeButton(res.getString(R.string.no), null);
break;
case DIALOG_ASYNC:
builder.setTitle(res.getString(R.string.async_mode));
builder.setCancelable(false);
builder.setMessage(res.getString(R.string.async_mode_message));
builder.setPositiveButton(res.getString(R.string.yes), new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
lockCheckAction = true;
asyncModePreference.setChecked(true);
}
});
builder.setNegativeButton(res.getString(R.string.no), null);
break;
case DIALOG_WRITE_ANSWERS:
builder.setTitle(res.getString(R.string.write_answers));
builder.setCancelable(false);
builder.setMessage(res.getString(R.string.write_answers_message));
builder.setNegativeButton(res.getString(R.string.ok), null);
break;
case DIALOG_HEBREW_FONT:
builder.setTitle(res.getString(R.string.fix_hebrew_text));
builder.setCancelable(false);
builder.setMessage(res.getString(R.string.fix_hebrew_instructions, AnkiDroidApp.getCurrentAnkiDroidDirectory()));
builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(res.getString(R.string.fix_hebrew_download_font), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(getResources().getString(R.string.link_hebrew_font)));
startActivity(intent);
}
});
break;
}
return builder.create();
}
use of android.content.DialogInterface.OnClickListener in project Anki-Android by Ramblurr.
the class StudyOptionsFragment method createFilteredDeck.
private void createFilteredDeck(JSONArray delays, Object[] terms, Boolean resched) {
JSONObject dyn;
if (AnkiDroidApp.colIsOpen()) {
Collection col = AnkiDroidApp.getCol();
try {
String deckName = col.getDecks().current().getString("name");
String customStudyDeck = getResources().getString(R.string.custom_study_deck_name);
JSONObject cur = col.getDecks().byName(customStudyDeck);
if (cur != null) {
if (cur.getInt("dyn") != 1) {
StyledDialog.Builder builder = new StyledDialog.Builder(getActivity());
builder.setMessage(R.string.custom_study_deck_exists);
builder.setNegativeButton(getResources().getString(R.string.cancel), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//
}
});
builder.create().show();
return;
} else {
// safe to empty
col.getSched().emptyDyn(cur.getLong("id"));
// reuse; don't delete as it may have children
dyn = cur;
col.getDecks().select(cur.getLong("id"));
}
} else {
long did = col.getDecks().newDyn(customStudyDeck);
dyn = col.getDecks().get(did);
}
// and then set various options
dyn.put("delays", delays);
JSONArray ar = dyn.getJSONArray("terms");
ar.getJSONArray(0).put(0, new StringBuilder("deck:\"").append(deckName).append("\" ").append(terms[0]).toString());
ar.getJSONArray(0).put(1, terms[1]);
ar.getJSONArray(0).put(2, terms[2]);
dyn.put("resched", resched);
if (mFragmented) {
Bundle config = new Bundle();
config.putString("searchSuffix", "'deck:" + dyn.getString("name") + "'");
initAllContentViews(getLayoutInflater(config));
finishCongrats();
} else {
// Load a new fragment with the filtered deck view. The config passed is null, so it uses the
// current deck. The deck we just created is internally set as the current deck.
((StudyOptionsActivity) getActivity()).loadContent(false, null);
}
// Initial rebuild
mProgressDialog = StyledProgressDialog.show(getActivity(), "", getResources().getString(R.string.rebuild_custom_study_deck), true);
DeckTask.launchDeckTask(DeckTask.TASK_TYPE_REBUILD_CRAM, mRebuildCustomStudyListener, new DeckTask.TaskData(AnkiDroidApp.getCol(), AnkiDroidApp.getCol().getDecks().selected(), mFragmented));
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
}
Aggregations