Example usage for android.app AlertDialog setIcon

List of usage examples for android.app AlertDialog setIcon

Introduction

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

Prototype

public void setIcon(Drawable icon) 

Source Link

Usage

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

/**
 * Add new entry based on input//from   w w  w.  j  a  v a2 s.c o m
 *
 * @param input
 */
private void addEntry(String hostname, String ip) {
    if (hostname != null) {
        if (org.adawaycn.util.RegexUtils.isValidHostname(hostname)) {
            if (org.adawaycn.util.RegexUtils.isValidIP(ip)) {
                org.adawaycn.provider.ProviderHelper.insertRedirectionListItem(mActivity, hostname, ip);
            } else {
                AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                alertDialog.setTitle(R.string.no_ip_title);
                alertDialog.setMessage(getString(R.string.no_ip));
                alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dlg, int sum) {
                        dlg.dismiss();
                    }
                });
                alertDialog.show();
            }
        } 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.deemsys.lmsmooc.BillingFragment.java

@SuppressWarnings("deprecation")
@Override// ww  w .j  a  va 2 s  . c om
public void onResume() {
    super.onResume();

    if (isInternetPresent) {

        // onResume();
        new Details().execute();

    }

    else {

        AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();

        alertDialog.setTitle("Sorry User");

        alertDialog.setMessage("No network connection.");

        alertDialog.setIcon(R.drawable.delete);

        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {

            public void onClick(final DialogInterface dialog, final int which) {

            }
        });

        alertDialog.show();

    }

}

From source file:com.aikidonord.fragments.FragmentDate.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_date, null /*container, false*/);

    View rlLoading = view.findViewById(R.id.loadingPanel);
    //View listView = view.getListView();

    if (VerifConnexion.isOnline(this.getActivity())) {
        rlLoading.setVisibility(View.VISIBLE);

        // on va fair l'impasse l dessus vu que je ne suis pas bien sr
        // de la manire dont il faut oprer tant que la vue n'a pas t renvoye.
        //listView.setVisibility(View.GONE);
        this.lancementAsync();
    } else {// w  w w. ja  v  a 2s. c  o m

        AlertDialog alertDialog = new AlertDialog.Builder(this.getActivity()).create();
        alertDialog.setTitle(getResources().getString(R.string.app_name));
        alertDialog.setMessage(getResources().getString(R.string.no_network));
        alertDialog.setIcon(R.drawable.ic_launcher);
        alertDialog.setCancelable(false);
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getResources().getString(R.string.close),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        // if this button is clicked, close
                        // current activity
                        FragmentDate.this.getActivity().finish();
                    }
                });
        alertDialog.show();
    }

    return view;
}

From source file:com.aikidonord.fragments.FragmentLieu.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_lieu, null /*container, false*/);

    View rlLoading = view.findViewById(R.id.loadingPanel);
    //View listView = view.getListView();

    if (VerifConnexion.isOnline(this.getActivity())) {
        rlLoading.setVisibility(View.VISIBLE);

        // on va fair l'impasse l dessus vu que je ne suis pas bien sr
        // de la manire dont il faut oprer tant que la vue n'a pas t renvoye.
        //listView.setVisibility(View.GONE);
        this.lancementAsync();
    } else {//ww w .  java 2 s .  c  om

        AlertDialog alertDialog = new AlertDialog.Builder(this.getActivity()).create();
        alertDialog.setTitle(getResources().getString(R.string.app_name));
        alertDialog.setMessage(getResources().getString(R.string.no_network));
        alertDialog.setIcon(R.drawable.ic_launcher);
        alertDialog.setCancelable(false);
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getResources().getString(R.string.close),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        // if this button is clicked, close
                        // current activity
                        FragmentLieu.this.getActivity().finish();
                    }
                });
        alertDialog.show();
    }

    return view;
}

From source file:com.aikidonord.fragments.FragmentType.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_type, null /*container, false*/);

    View rlLoading = view.findViewById(R.id.loadingPanel);
    //View listView = view.getListView();

    if (VerifConnexion.isOnline(this.getActivity())) {
        rlLoading.setVisibility(View.VISIBLE);

        // on va fair l'impasse l dessus vu que je ne suis pas bien sr
        // de la manire dont il faut oprer tant que la vue n'a pas t renvoye.
        //listView.setVisibility(View.GONE);
        this.lancementAsync();
    } else {/*from w  w  w  . j  a  va 2  s  .c o  m*/

        AlertDialog alertDialog = new AlertDialog.Builder(this.getActivity()).create();
        alertDialog.setTitle(getResources().getString(R.string.app_name));
        alertDialog.setMessage(getResources().getString(R.string.no_network));
        alertDialog.setIcon(R.drawable.ic_launcher);
        alertDialog.setCancelable(false);
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getResources().getString(R.string.close),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        // if this button is clicked, close
                        // current activity
                        FragmentType.this.getActivity().finish();
                    }
                });
        alertDialog.show();
    }

    return view;
}

From source file:org.uclab.mm.sl.uiux.uiuxanalyticsdemo.MainActivity.java

public void userFeedback() {
    AlertDialog userfeedback = new AlertDialog.Builder(this).create();

    // Setting Dialog Title
    userfeedback.setTitle("Feedback");

    // Setting Icon to Dialog
    userfeedback.setIcon(R.drawable.ic_feedback_black_18dp);

    LayoutInflater inflater = this.getLayoutInflater();

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    userfeedback.setView(inflater.inflate(R.layout.feedback, null));

    // Setting OK Button
    userfeedback.setButton("Send", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog
            // closed
            Toast.makeText(getApplicationContext(), "Your Feedback sent Successfully", Toast.LENGTH_SHORT)
                    .show();/*w w w  . ja  v a  2s  . c  o m*/
        }
    });

    // Showing Alert Message
    userfeedback.show();
}

From source file:com.veniosg.dir.android.dialog.MultiDeleteDialog.java

@NonNull
@Override/*from  w w w .  jav a  2  s  . co  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ArrayList<FileHolder> holders = getArguments().getParcelableArrayList(EXTRA_DIALOG_FILE_HOLDER);

    if (holders != null) {
        AlertDialog dialog = new AlertDialog.Builder(getActivity())
                .setTitle(getString(R.string.really_delete_multiselect, holders.size()))
                .setPositiveButton(R.string.yes, (dialog1, which) -> {
                    FileHolder[] params = holders.toArray(new FileHolder[holders.size()]);
                    new DeleteAsyncTask(getContext()).execute(params);
                }).setNegativeButton(R.string.no, null).create();
        dialog.setIcon(R.drawable.ic_dialog_delete);
        return dialog;
    } else {
        dismiss();
        return new Dialog(getContext());
    }
}

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);//w w  w.  ja  va  2s  .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:org.odk.collect.android.activities.FormHierarchyActivity.java

/**
 * Creates and displays dialog with the given errorMsg.
 *//*from w  w  w .ja  v a2 s  .  c om*/
private void createErrorDialog(String errorMsg) {
    Collect.getInstance().getActivityLogger().logInstanceAction(this, "createErrorDialog", "show.");

    AlertDialog alertDialog = new AlertDialog.Builder(this).create();

    alertDialog.setIcon(android.R.drawable.ic_dialog_info);
    alertDialog.setTitle(getString(R.string.error_occured));
    alertDialog.setMessage(errorMsg);
    DialogInterface.OnClickListener errorListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i) {
            switch (i) {
            case DialogInterface.BUTTON_POSITIVE:
                Collect.getInstance().getActivityLogger().logInstanceAction(this, "createErrorDialog", "OK");
                FormController formController = Collect.getInstance().getFormController();
                formController.jumpToIndex(currentIndex);
                break;
            }
        }
    };
    alertDialog.setCancelable(false);
    alertDialog.setButton(getString(R.string.ok), errorListener);
    alertDialog.show();
}

From source file:com.njlabs.amrita.aid.landing.Landing.java

public void checkForUpdates() {

    OkHttpClient client = new OkHttpClient.Builder().followRedirects(true).followSslRedirects(true).build();

    Request.Builder request = new Request.Builder().url("https://api.codezero.xyz/aid/latest");

    client.newCall(request.build()).enqueue(new Callback() {
        @Override// w  ww  .  jav a 2 s  .  c om
        public void onFailure(Call call, IOException e) {
            Ln.e(e);
        }

        @Override
        public void onResponse(Call call, final Response rawResponse) throws IOException {
            final String responseString = rawResponse.body().string();
            ((Activity) baseContext).runOnUiThread(new Runnable() {
                @Override
                public void run() {

                    JSONObject response;

                    try {
                        response = new JSONObject(responseString);

                        String status = "";
                        status = response.getString("status");

                        if (status.equals("ok")) {
                            Double Latest = 0.0;
                            String Description = null;
                            try {
                                Latest = response.getDouble("version");
                                Description = response.getString("description");
                            } catch (JSONException e) {
                                FirebaseCrash.report(e);
                            }
                            if (Latest > BuildConfig.VERSION_CODE) {

                                AlertDialog.Builder updateDialogBuilder = new AlertDialog.Builder(Landing.this);

                                LayoutInflater factory = LayoutInflater.from(Landing.this);
                                final View changelogView = factory.inflate(R.layout.webview_dialog, null);
                                LinearLayout WebViewDialogLayout = (LinearLayout) changelogView
                                        .findViewById(R.id.WebViewDialogLayout);
                                WebViewDialogLayout.setPadding(5, 5, 5, 5);
                                WebView changelogWebView = (WebView) changelogView
                                        .findViewById(R.id.LicensesView);
                                changelogWebView.loadData(String.format("%s", Description), "text/html",
                                        "utf-8");
                                changelogWebView.setPadding(5, 5, 5, 5);
                                changelogWebView.setBackgroundColor(0);
                                changelogWebView.setOnLongClickListener(new View.OnLongClickListener() {
                                    @Override
                                    public boolean onLongClick(View v) {
                                        return true;
                                    }
                                });
                                changelogWebView.setLongClickable(false);
                                updateDialogBuilder.setView(changelogView).setCancelable(true)
                                        .setCancelable(false)
                                        .setNegativeButton("Dismiss", new DialogInterface.OnClickListener() {
                                            public void onClick(DialogInterface dialog, int id) {
                                                dialog.cancel();
                                            }
                                        })
                                        .setPositiveButton("Update Now", new DialogInterface.OnClickListener() {
                                            public void onClick(DialogInterface dialog, int id) {
                                                Uri uri = Uri
                                                        .parse("market://details?id=com.njlabs.amrita.aid");
                                                Intent it = new Intent(Intent.ACTION_VIEW, uri);
                                                startActivity(it);
                                            }
                                        });
                                AlertDialog alert = updateDialogBuilder.create();
                                alert.setTitle("Update Available");
                                alert.setIcon(R.mipmap.ic_launcher);
                                alert.show();
                            }
                        }

                    } catch (Exception e) {
                        Ln.e(e);
                    }
                }
            });
        }
    });
}