Example usage for android.app AlertDialog.Builder setIcon

List of usage examples for android.app AlertDialog.Builder setIcon

Introduction

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

Prototype

public void setIcon(Drawable icon) 

Source Link

Usage

From source file:de.k3b.android.locationMapViewer.geobmp.BookmarkListOverlay.java

/** before deleting: "Are you shure?" */
private void deleteConfirm() {
    final GeoBmpDto currentItem = this.bookMarkController.getCurrentItem();
    if (currentItem != null) {
        final String message = String.format(this.context.getString(R.string.format_question_delete).toString(),
                currentItem.getName() + "\n" + currentItem.getSummary());

        final AlertDialog.Builder builder = new AlertDialog.Builder(this.context);

        builder.setTitle(R.string.title_confirm_delete);
        Bitmap bitmap = currentItem.getBitmap();

        if (bitmap != null) {
            BitmapDrawable drawable = (bitmap == null) ? null
                    : new BitmapDrawable(context.getResources(), bitmap);
            builder.setIcon(drawable);
        }//  w  w w  .  j  a  v a  2s. c  o  m

        builder.setMessage(message).setCancelable(false)
                .setPositiveButton(R.string.cmd_yes, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int id) {
                        bookMarkController.deleteCurrent();
                    }
                }).setNegativeButton(R.string.cmd_no, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int id) {
                        dialog.cancel();
                    }
                });

        final AlertDialog alert = builder.create();
        alert.show();
    }
}

From source file:br.com.GUI.perfil.MeusAlunos.java

public void atualizarInterface() {
    listDataHeader = new ArrayList<RowItemAluno>();

    if (alunos.isEmpty()) {
        Log.i("alunos", "esta vazio");
    } else {//from  w  ww  .ja va 2 s .c  o m
        Log.i("aluno", "nao esta vazio");
    }

    List<RowItemExpandedAluno> opcoes = prepararOpcoes();

    for (Aluno a : alunos) {

        byte[] foto = new Aluno().buscarFotoAluno(b, a.getUsuario());
        Bitmap bmp = BitmapFactory.decodeByteArray(foto, 0, foto.length);

        RowItemAluno item = new RowItemAluno();
        item.setImagemPerfil(bmp);
        item.setNomePerfil(a.getNome());
        item.setUsuarioAluno(a.getUsuario());

        listDataHeader.add(item);

    }

    for (RowItemAluno row : listDataHeader) {
        listDataChild.put(row, opcoes);
    }
    /*CustomAdapterAluno adapter = 
    new CustomAdapterAluno(getActivity(),alunosPerfil);
    meusAlunos.setAdapter(adapter);
            
    meusAlunos.setOnItemClickListener(new OnItemClickListener() {
               
    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
    long arg3) {
               
       String usuario = alunos.get(arg2).getUsuario();         
       Intent intent = new Intent(getActivity(),AdicionarAluno.class);
       intent.putExtra("usuario", usuario);
        startActivity(intent);
            
       }
    });*/

    listAdapter = new CustomAdapterExpandedAluno(getActivity(), listDataHeader, listDataChild);

    expListView.setAdapter(listAdapter);

    expListView.setOnChildClickListener(new OnChildClickListener() {

        @Override
        public boolean onChildClick(ExpandableListView parent, View v, final int groupPosition,
                int childPosition, long id) {
            Intent i;
            switch (childPosition) {
            case 0:
                i = new Intent(getActivity(), GerenciarAcompanhamento.class);
                i.putExtra("alunoAcompanhamento", listDataHeader.get(groupPosition).getUsuarioAluno());
                startActivity(i);
                break;
            case 1:
                i = new Intent(getActivity(), NovaAvaliacao.class);
                i.putExtra("alunoAvaliacao", listDataHeader.get(groupPosition).getUsuarioAluno());
                startActivity(i);
                break;
            case 2:
                i = new Intent(getActivity(), PreescreverTreinamento.class);
                i.putExtra("usuario", listDataHeader.get(groupPosition).getUsuarioAluno());
                startActivity(i);
                break;
            case 3:
                i = new Intent(getActivity(), MarcarAula.class);
                i.putExtra("usuario", listDataHeader.get(groupPosition).getUsuarioAluno());
                startActivity(i);
                break;
            case 4:

                AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
                alertDialog.setTitle("Ateno");
                alertDialog.setMessage("Voc tem certeza que deseja remover este aluno?");
                alertDialog.setIcon(R.drawable.critical);
                alertDialog.setPositiveButton("Sim", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        Aluno a = new Aluno().buscarAlunoEspecifico(b,
                                listDataHeader.get(groupPosition).getUsuarioAluno());
                        if (a.removerAlunoWeb(a.getUsuario()) && a.removerAluno(b)) {
                            Toast.makeText(getActivity(), "Removido com Sucesso", Toast.LENGTH_SHORT).show();
                            // Exclui todas as aulas marcadas com o personal
                            ArrayList<Aula> aulasParaExcluir = new ArrayList<Aula>();

                            aulasParaExcluir = new Aula().buscarAulasPorPersonalWeb(a.getUsuarioPersonal(), "");
                            for (Aula c : aulasParaExcluir) {
                                if (c.excluirAulaWeb() && c.excluirAula(b)) {
                                    Log.i("INFORMAO", "Aulas excluidas com sucesso!");
                                }
                            }
                        } else {
                            Toast.makeText(getActivity(), "Falha ao Remover o aluno", Toast.LENGTH_SHORT)
                                    .show();
                        }
                    }
                });
                alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });

                alertDialog.show();

                break;
            }

            atualizarInterface();

            return false;
        }

    });
}

From source file:jackpal.androidterm.TermPreferences.java

void licensePrefs() {
    AlertDialog.Builder bld = new AlertDialog.Builder(this);
    bld.setIcon(android.R.drawable.ic_dialog_info);
    bld.setMessage(this.getString(R.string.license_text));
    bld.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();/* w  ww .  ja v  a2s  . c o m*/
        }
    });
    bld.setNeutralButton(this.getString(R.string.github), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
            Intent openUrl = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.github_url)));
            startActivity(openUrl);
        }
    });
    bld.create().show();
}

From source file:jackpal.androidterm.TermPreferences.java

private boolean writePrefs(String filename) {
    AlertDialog.Builder bld = new AlertDialog.Builder(this);
    bld.setIcon(android.R.drawable.ic_dialog_info);
    bld.setPositiveButton(this.getString(android.R.string.ok), null);
    FileOutputStream fos;/*w  w  w.  ja va  2s  .  c  o  m*/
    try {
        fos = new FileOutputStream(filename);
        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
        XmlUtils.writeMapXml(pref.getAll(), fos);
    } catch (Exception e) {
        bld.setMessage(this.getString(R.string.prefs_write_info_failure));
        bld.create().show();
        return false;
    }
    bld.setMessage(this.getString(R.string.prefs_write_info_success) + "\n\n" + filename);
    bld.create().show();
    return true;
}

From source file:jackpal.androidterm.TermPreferences.java

@SuppressLint("NewApi")
private void doPrefsPicker() {
    AlertDialog.Builder bld = new AlertDialog.Builder(this);
    bld.setIcon(android.R.drawable.ic_dialog_info);
    bld.setMessage(this.getString(R.string.prefs_dialog_rw));
    bld.setNeutralButton(this.getString(R.string.prefs_write), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();//from   w w  w  .  j a va2s.  c  o  m
            confirmWritePrefs();
        }
    });
    bld.setPositiveButton(this.getString(R.string.prefs_read), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
            Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("text/xml");
            startActivityForResult(intent, REQUEST_PREFS_READ_PICKER);
        }
    });
    bld.setNegativeButton(this.getString(android.R.string.no), null);
    bld.create().show();
}

From source file:jackpal.androidterm.TermPreferences.java

private void confirmWritePrefs() {
    File pathExternalPublicDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
    String downloadDir = pathExternalPublicDir.getPath();
    final String filename = downloadDir + "/" + BuildConfig.APPLICATION_ID + ".xml";
    if (new File(filename).exists()) {
        AlertDialog.Builder bld = new AlertDialog.Builder(this);
        bld.setIcon(android.R.drawable.ic_dialog_info);
        bld.setMessage(this.getString(R.string.prefs_write_confirm));
        bld.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();// ww w. j a  v a  2  s .  c  om
                writePrefs(filename);
            }
        });
        bld.setNegativeButton(this.getString(android.R.string.no), null);
        bld.create().show();
    } else {
        writePrefs(filename);
        return;
    }
}

From source file:jackpal.androidterm.TermPreferences.java

private void doFilePicker() {
    AlertDialog.Builder bld = new AlertDialog.Builder(this);
    bld.setIcon(android.R.drawable.ic_dialog_info);
    bld.setMessage(this.getString(R.string.font_file_error));
    bld.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();//from   w  ww.j  av a  2s  . co m
            Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("application/octet-stream");
            startActivityForResult(intent, REQUEST_FONT_PICKER);
        }
    });
    bld.setNegativeButton(this.getString(android.R.string.no), null);
    final Activity activity = this;
    bld.setNeutralButton(this.getString(R.string.entry_fontfile_default),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(activity);
                    sp.edit().putString(FONT_FILENAME, activity.getString(R.string.entry_fontfile_default))
                            .apply();
                }
            });
    bld.create().show();
}

From source file:br.com.GUI.perfil.PerfilAluno.java

public void atualizarDadosAluno() {

    if (nome.getText().toString() == null) {
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
        alertDialog.setTitle("Ateno");
        alertDialog.setMessage("Por favor, digite o seu nome");
        alertDialog.setIcon(R.drawable.critical);
        alertDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();//from   w  w  w.  j  a v  a 2s .com
            }
        });

        alertDialog.show();
    } else {
        byte[] byteFoto = ImageUtils.bitmapToByteArray(bmp);
        String fotoAluno = new String(byteFoto);

        String dataDeNascimento = dataNascimentoDia.getValue() + "/" + dataNascimentoMes.getValue() + "/"
                + dataNascimentoAno.getValue();

        final Aluno a = new Aluno(telefone.getText().toString(), nome.getText().toString(), dataDeNascimento,
                email.getText().toString(), null, pref.getString("usuario", null),
                pref.getString("senha", null), null, 0, 0, fotoAluno, 0);

        boolean r = a.atualizarAlunoWeb();

        if (r && a.atualizar(b, byteFoto)) {
            Toast.makeText(getActivity(), "Atualizado com Sucesso", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(getActivity(), "Erro ao salvar no servidor", Toast.LENGTH_SHORT).show();
        }
    }

}

From source file:at.jclehner.rxdroid.BackupFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (!getActivity().getIntent().getBooleanExtra(BackupActivity.EXTRA_NO_BACKUP_CREATION, false)) {
        final MenuItem item = menu.add(getString(R.string._title_create_backup))
                .setIcon(R.drawable.ic_action_add_box_white)
                .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                    @Override/*from  w  w w.  java 2s .co  m*/
                    public boolean onMenuItemClick(MenuItem menuItem) {
                        final String storageState = Backup.getStorageState();
                        if (Backup.StorageStateListener.isWritable(storageState)) {
                            try {
                                Backup.createBackup(null, null);
                                getLoaderManager().restartLoader(0, null, BackupFragment.this);
                            } catch (ZipException e) {
                                showExceptionDialog(e);
                            }
                        } else {
                            if (mShowDialogIfNotWriteable) {
                                final AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());
                                ab.setPositiveButton(android.R.string.ok, null);
                                ab.setMessage(R.string._msg_external_storage_not_writeable);
                                ab.setTitle(R.string._title_error);
                                ab.setIcon(android.R.drawable.ic_dialog_alert);

                                ab.show();
                                mShowDialogIfNotWriteable = false;
                            } else {
                                Toast.makeText(getActivity(), R.string._msg_external_storage_not_writeable,
                                        Toast.LENGTH_LONG);
                            }
                        }

                        return true;
                    }
                });

        MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    }
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:jackpal.androidterm.TermPreferences.java

private boolean readPrefs(Uri uri, boolean clearPrefs) {
    try {//from ww w .j  a  va 2 s. co  m
        InputStream is = this.getApplicationContext().getContentResolver().openInputStream(uri);
        SharedPreferences.Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(this).edit();

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        Map<String, ?> entries = XmlUtils.readMapXml(is);

        int error = 0;
        for (Map.Entry<String, ?> entry : entries.entrySet()) {
            if (!prefs.contains(entry.getKey()))
                error += 1;
            if (error > 3)
                throw new Exception();
        }
        if (clearPrefs && error == 0)
            prefEdit.clear();

        for (Map.Entry<String, ?> entry : entries.entrySet()) {
            putObject(prefEdit, entry.getKey(), entry.getValue());
        }
        prefEdit.apply();
    } catch (Exception e) {
        AlertDialog.Builder bld = new AlertDialog.Builder(this);
        bld.setIcon(android.R.drawable.ic_dialog_alert);
        bld.setTitle(this.getString(R.string.prefs_read_error_title));
        bld.setMessage(this.getString(R.string.prefs_read_error));
        bld.setPositiveButton(this.getString(android.R.string.ok), null);
        bld.create().show();
        return false;
    }
    return true;
}