Example usage for android.app AlertDialog setButton

List of usage examples for android.app AlertDialog setButton

Introduction

In this page you can find the example usage for android.app AlertDialog setButton.

Prototype

@Deprecated
public void setButton(CharSequence text, final OnClickListener listener) 

Source Link

Document

Set a listener to be invoked when button 1 of the dialog is pressed.

Usage

From source file:cm.aptoide.pt.RemoteInSearch.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch (item.getItemId()) {
    case MANAGE_REPO:
        Intent i = new Intent(this, ManageRepo.class);
        startActivity(i);//from   w w  w . j av a 2 s.  c  om
        return true;
    case SEARCH_MENU:
        onSearchRequested();
        return true;
    case ABOUT:
        LayoutInflater li = LayoutInflater.from(this);
        View view = li.inflate(R.layout.about, null);
        Builder p = new AlertDialog.Builder(this).setView(view);
        final AlertDialog alrt = p.create();
        alrt.setIcon(R.drawable.icon);
        alrt.setTitle("APTOIDE");
        alrt.setButton("ChangeLog", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                Uri uri = Uri.parse("http://aptoide.com/changelog.html");
                startActivity(new Intent(Intent.ACTION_VIEW, uri));
            }
        });
        alrt.show();
        return true;
    case SETTINGS:
        Intent s = new Intent(RemoteInSearch.this, Settings.class);
        s.putExtra("order", order_lst);
        startActivityForResult(s, SETTINGS_FLAG);
    }
    return super.onOptionsItemSelected(item);
}

From source file:dev.ronlemire.contactclientcloud.MainActivity.java

@SuppressWarnings("deprecation")
@Override/*ww  w .  ja v a2  s.  c  om*/
public void onBackPressed() {
    //super.onBackPressed();
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Exiting Application");
    alertDialog.setMessage("Are you sure?");
    alertDialog.setIcon(android.R.attr.alertDialogIcon);
    alertDialog.setButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            finish();
        }
    });
    alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            return;
        }
    });
    alertDialog.show();

    //      new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_DARK)
    //            .setIconAttribute(android.R.attr.alertDialogIcon)
    //            .setTitle(R.string.exitingApplication)
    //            .setMessage(R.string.shortMessage)
    //            .setPositiveButton(R.string.alert_dialog_ok,
    //                  new DialogInterface.OnClickListener() {
    //                     public void onClick(DialogInterface dialog,
    //                           int whichButton) {
    //                        finish();
    //                     }
    //                  })
    //            .setNegativeButton(R.string.alert_dialog_cancel,
    //                  new DialogInterface.OnClickListener() {
    //                     public void onClick(DialogInterface dialog,
    //                           int whichButton) {
    //                        return;
    //                     }
    //                  }).create().show();
}

From source file:com.ubundude.timesheet.MainActivity.java

/**
 * Checks for an updated version of the app
 *
 * If there is an updated version, an Alert dialog is displayed
 * to advise the user to download the latest version
 *
 * @throws NameNotFoundException/* w  ww  .j  a v a2s  . c  o  m*/
 * @throws IOException
 * @throws InterruptedException
 * @throws ExecutionException
 */
@SuppressWarnings("deprecation")
private void updateCheck() throws NameNotFoundException, IOException, InterruptedException, ExecutionException {
    /** String to store the version from the url */
    String urlVersion;

    /** Get instance of UpdateCheck.java and get the version returned from it */
    UpdateCheck check = new UpdateCheck();
    urlVersion = check.execute().get();

    /** Get the currently running version of the app for comparision */
    PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    String packageVersion = pInfo.versionName;

    Log.d("Package Version", packageVersion);

    /** Builds an alert dialog to let the user know that they need to upgrade */
    if (!urlVersion.equals(packageVersion)) {
        AlertDialog alert = new AlertDialog.Builder(this).create();
        alert.setTitle("Version Check");
        alert.setMessage("You're version is out of date. Please visit "
                + "www.ubundude.com/p/beta.html to update to the latest version.");

        alert.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        alert.show();
    }
}

From source file:org.adawaycn.ui.HostsSourcesFragment.java

/**
 * Add new entry based on input// ww w.  j  a v a 2s . com
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidUrl(input)) {

            // insert hosts source into database
            ProviderHelper.insertHostsSource(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_url_title);
            alertDialog.setMessage(getString(R.string.no_url));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:org.adawaycn.ui.WhitelistFragment.java

/**
 * Add new entry based on input/*from w w  w .  java  2  s. co  m*/
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidWhitelistHostname(input)) {
            ProviderHelper.insertWhitelistItem(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:org.adawaycn.ui.BlacklistFragment.java

/**
 * Add new entry based on input/*from w  ww . j a v  a2 s  . c  om*/
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (org.adawaycn.util.RegexUtils.isValidHostname(input)) {
            org.adawaycn.provider.ProviderHelper.insertBlacklistItem(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:com.workingagenda.democracydroid.Adapters.ViewHolders.EpisodeViewHolder.java

@RequiresApi(api = Build.VERSION_CODES.M)
@Override// w ww.  java  2  s.c o m
public boolean onMenuItemClick(MenuItem menuItem) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(itemView.getContext());
    int DEFAULT_STREAM = Integer.parseInt(preferences.getString("stream_preference", "0")); // 0=video
    int DEFAULT_OPEN = Integer.parseInt(preferences.getString("open_preference", "0")); // 0 = within this ap
    String actionTitle = "Democracy Now!";
    if (mEpisode.getTitle().length() > 16) {
        if ("Today's Broadcast".equals(mEpisode.getTitle())) {
            actionTitle = mEpisode.getTitle();
        } else if (mEpisode.getTitle().startsWith("Democracy Now!")) {
            actionTitle = mEpisode.getTitle().substring(14);
        } else {
            actionTitle = mEpisode.getTitle();
        }
    }

    switch (menuItem.getItemId()) {
    case R.id.action_share:
        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, mEpisode.getTitle());
        sendIntent.putExtra(Intent.EXTRA_TEXT, mEpisode.getUrl());
        sendIntent.setType("text/plain");
        itemView.getContext().startActivity(sendIntent);
        return true;
    case R.id.reverse_default_media:
        if (mEpisode.getVideoUrl().contains("m3u8"))
            startMediaIntent(mEpisode.getAudioUrl(), 1, mEpisode.getTitle());
        else if (DEFAULT_STREAM == 0)
            startMediaIntent(mEpisode.getAudioUrl(), DEFAULT_OPEN, actionTitle);
        else
            startMediaIntent(mEpisode.getVideoUrl(), DEFAULT_OPEN, actionTitle);
        return true;
    case R.id.reverse_default_open:
        int reverseOpen = 0;
        if (reverseOpen == DEFAULT_OPEN)
            reverseOpen = 1;
        if (DEFAULT_STREAM == 0)
            startMediaIntent(mEpisode.getVideoUrl(), reverseOpen, actionTitle);
        else
            startMediaIntent(mEpisode.getAudioUrl(), reverseOpen, actionTitle);
        return true;
    case R.id.action_description:
        AlertDialog description = new AlertDialog.Builder(itemView.getContext()).create();
        // Get Description and Title
        description.setTitle("The War and Peace Report");
        description.setMessage(mEpisode.getDescription() + "\n\n" + mEpisode.getTitle());
        description.setButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                // do nothing
            }
        });
        description.show();
        return true;
    case R.id.video_download:
        if (mEpisode.getTitle().equals("Stream Live"))
            return true;
        Download(mEpisode.getVideoUrl(), mEpisode.getTitle(), mEpisode.getDescription());
        return true;
    case R.id.audio_download:
        if (mEpisode.getTitle().equals("Stream Live"))
            return true;
        Download(mEpisode.getAudioUrl(), mEpisode.getTitle(), mEpisode.getDescription());
        return true;
    case R.id.open_browser:
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.parse(mEpisode.getUrl()), "*/*");
        itemView.getContext().startActivity(intent);
        return true;
    }
    return false;
}

From source file:org.adaway.ui.BlacklistFragment.java

/**
 * Add new entry based on input//  w  w w  .  j  av a  2s  .c  om
 * 
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidHostname(input)) {
            ProviderHelper.insertBlacklistItem(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(org.adaway.R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:org.adaway.ui.HostsSourcesFragment.java

/**
 * Add new entry based on input//from  w w w .  j  a v a2s.c o m
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidUrl(input)) {

            // insert hosts source into database
            ProviderHelper.insertHostsSource(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_url_title);
            alertDialog.setMessage(getString(org.adaway.R.string.no_url));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:org.adaway.ui.WhitelistFragment.java

/**
 * Add new entry based on input//from ww  w.  ja v  a 2s . c  om
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidWhitelistHostname(input)) {
            ProviderHelper.insertWhitelistItem(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(org.adaway.R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}