use of android.support.v7.app.AlertDialog in project materialistic by hidroh.
the class FavoriteActivityTest method testDelete.
@Test
public void testDelete() {
RecyclerView.ViewHolder holder = shadowAdapter.getViewHolder(0);
holder.itemView.performLongClick();
ActionMode actionMode = mock(ActionMode.class);
activity.actionModeCallback.onActionItemClicked(actionMode, new RoboMenuItem(R.id.menu_clear));
AlertDialog dialog = ShadowAlertDialog.getLatestAlertDialog();
dialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
assertEquals(2, adapter.getItemCount());
activity.actionModeCallback.onActionItemClicked(actionMode, new RoboMenuItem(R.id.menu_clear));
dialog = ShadowAlertDialog.getLatestAlertDialog();
dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
verify(favoriteManager).remove(any(Context.class), selection.capture());
assertThat(selection.getValue()).contains("1");
verify(actionMode).finish();
when(favoriteManager.getSize()).thenReturn(1);
observerCaptor.getValue().onChanged();
assertEquals(1, adapter.getItemCount());
}
use of android.support.v7.app.AlertDialog in project ZhihuDailyPurify by izzyleung.
the class NewsAdapter method share.
private void share(Context context, int position) {
DailyNews dailyNews = newsList.get(position);
if (dailyNews.hasMultipleQuestions()) {
AlertDialog dialog = createDialog(context, dailyNews, makeShareQuestionDialogClickListener(context, dailyNews));
dialog.show();
} else {
shareQuestion(context, dailyNews.getQuestions().get(0).getTitle(), dailyNews.getQuestions().get(0).getUrl());
}
}
use of android.support.v7.app.AlertDialog in project ZhihuDailyPurify by izzyleung.
the class NewsAdapter method browse.
private void browse(Context context, int position) {
DailyNews dailyNews = newsList.get(position);
if (dailyNews.hasMultipleQuestions()) {
AlertDialog dialog = createDialog(context, dailyNews, makeGoToZhihuDialogClickListener(context, dailyNews));
dialog.show();
} else {
goToZhihu(context, dailyNews.getQuestions().get(0).getUrl());
}
}
use of android.support.v7.app.AlertDialog in project NewPipe by TeamNewPipe.
the class DownloadActivity method showUrlDialog.
private void showUrlDialog() {
// Create the view
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.dialog_url, null);
final EditText name = Utility.findViewById(v, R.id.file_name);
final TextView tCount = Utility.findViewById(v, R.id.threads_count);
final SeekBar threads = Utility.findViewById(v, R.id.threads);
final Toolbar toolbar = Utility.findViewById(v, R.id.toolbar);
final RadioButton audioButton = (RadioButton) Utility.findViewById(v, R.id.audio_button);
threads.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) {
tCount.setText(String.valueOf(progress + 1));
}
@Override
public void onStartTrackingTouch(SeekBar p1) {
}
@Override
public void onStopTrackingTouch(SeekBar p1) {
}
});
int def = mPrefs.getInt(THREADS, 4);
threads.setProgress(def - 1);
tCount.setText(String.valueOf(def));
name.setText(getIntent().getStringExtra("fileName"));
toolbar.setTitle(R.string.add);
toolbar.setNavigationIcon(R.drawable.ic_arrow_back_black_24dp);
toolbar.inflateMenu(R.menu.dialog_url);
// Show the dialog
final AlertDialog dialog = new AlertDialog.Builder(this).setCancelable(true).setView(v).create();
dialog.show();
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == R.id.okay) {
String location;
if (audioButton.isChecked()) {
location = NewPipeSettings.getAudioDownloadPath(DownloadActivity.this);
} else {
location = NewPipeSettings.getVideoDownloadPath(DownloadActivity.this);
}
String fName = name.getText().toString().trim();
File f = new File(location, fName);
if (f.exists()) {
Toast.makeText(DownloadActivity.this, R.string.msg_exists, Toast.LENGTH_SHORT).show();
} else {
DownloadManagerService.startMission(DownloadActivity.this, getIntent().getData().toString(), location, fName, audioButton.isChecked(), threads.getProgress() + 1);
mFragment.notifyChange();
mPrefs.edit().putInt(THREADS, threads.getProgress() + 1).commit();
mPendingUrl = null;
dialog.dismiss();
}
return true;
} else {
return false;
}
}
});
}
use of android.support.v7.app.AlertDialog in project AndroidChromium by JackyAndroid.
the class PassphraseCreationDialogFragment method onStart.
@Override
public void onStart() {
super.onStart();
AlertDialog d = (AlertDialog) getDialog();
if (d != null) {
// Override the button's onClick listener. The default gets set in the dialog's
// onCreate, when it is shown (in super.onStart()), so we have to do this here.
// Otherwise the dialog will close when the button is clicked regardless of what else we
// do.
d.getButton(Dialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tryToSubmitPassphrase();
}
});
}
}
Aggregations