Search in sources :

Example 1 with AlertDialog

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());
}
Also used : ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) AlertDialog(android.app.AlertDialog) Context(android.content.Context) ActionMode(android.support.v7.view.ActionMode) RecyclerView(android.support.v7.widget.RecyclerView) ShadowRecyclerView(io.github.hidroh.materialistic.test.shadow.ShadowRecyclerView) RoboMenuItem(org.robolectric.fakes.RoboMenuItem) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test)

Example 2 with AlertDialog

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());
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DailyNews(io.github.izzyleung.zhihudailypurify.bean.DailyNews)

Example 3 with AlertDialog

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());
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DailyNews(io.github.izzyleung.zhihudailypurify.bean.DailyNews)

Example 4 with AlertDialog

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;
            }
        }
    });
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) SeekBar(android.widget.SeekBar) MenuItem(android.view.MenuItem) RadioButton(android.widget.RadioButton) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) File(java.io.File) Toolbar(android.support.v7.widget.Toolbar)

Example 5 with AlertDialog

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();
            }
        });
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) View(android.view.View)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)413 DialogInterface (android.content.DialogInterface)275 View (android.view.View)219 TextView (android.widget.TextView)165 Intent (android.content.Intent)117 EditText (android.widget.EditText)87 ImageView (android.widget.ImageView)68 Button (android.widget.Button)67 LayoutInflater (android.view.LayoutInflater)59 RecyclerView (android.support.v7.widget.RecyclerView)54 NonNull (android.support.annotation.NonNull)53 AdapterView (android.widget.AdapterView)51 SuppressLint (android.annotation.SuppressLint)50 ArrayList (java.util.ArrayList)48 Bundle (android.os.Bundle)46 ListView (android.widget.ListView)42 Context (android.content.Context)35 SharedPreferences (android.content.SharedPreferences)35 Uri (android.net.Uri)32 LinearLayout (android.widget.LinearLayout)29