Example usage for android.content DialogInterface cancel

List of usage examples for android.content DialogInterface cancel

Introduction

In this page you can find the example usage for android.content DialogInterface cancel.

Prototype

void cancel();

Source Link

Document

Cancels the dialog, invoking the OnCancelListener .

Usage

From source file:com.coincollection.MainActivity.java

private void showExportConfirmation() {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(mRes.getString(R.string.export_warning)).setCancelable(false)
            .setPositiveButton(mRes.getString(R.string.yes), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // TODO Maybe use AsyncTask, if necessary
                    handleExportCollectionsPart2();
                }//from w  w w .j a  va  2s.  c  o m
            }).setNegativeButton(mRes.getString(R.string.no), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    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  ww w. j av  a 2 s. c  om*/
        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:com.example.android.contactslist.ui.eventEntry.EventEntryFragment.java

private void editWordCountTextDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.event_word_count_title);

    // Set up the input
    final EditText input = new EditText(getActivity());

    input.setText(mWordCountViewButton.getText());
    input.setSelected(true);/*from  w  w  w.  jav  a2  s.  c om*/

    // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
    input.setInputType(InputType.TYPE_CLASS_NUMBER);
    builder.setView(input);

    // Set up the buttons
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            mWordCountViewButton.setText(input.getText().toString());
            mWordCount = Integer.parseInt(input.getText().toString());
            mWordCountSeekBar.setProgress(mWordCount);

        }
    });

    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.show();
}

From source file:com.piusvelte.sonet.core.SonetNotifications.java

@Override
public boolean onContextItemSelected(final MenuItem item) {
    if (item.getItemId() == CLEAR) {
        final ProgressDialog loadingDialog = new ProgressDialog(this);
        final AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() {

            @Override//from w  w  w  .j  a va 2  s. c  om
            protected Void doInBackground(Void... arg0) {
                // clear all notifications
                ContentValues values = new ContentValues();
                values.put(Notifications.CLEARED, 1);
                SonetNotifications.this.getContentResolver().update(
                        Notifications.getContentUri(SonetNotifications.this), values, Notifications._ID + "=?",
                        new String[] { Long.toString(((AdapterContextMenuInfo) item.getMenuInfo()).id) });
                return null;
            }

            @Override
            protected void onPostExecute(Void result) {
                if (loadingDialog.isShowing()) {
                    loadingDialog.dismiss();
                }
                SonetNotifications.this.finish();
            }
        };
        loadingDialog.setMessage(getString(R.string.loading));
        loadingDialog.setCancelable(true);
        loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                if (!asyncTask.isCancelled())
                    asyncTask.cancel(true);
            }
        });
        loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
        loadingDialog.show();
        asyncTask.execute();
    }
    return super.onContextItemSelected(item);
    // clear
}

From source file:com.fvd.nimbus.PaintActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case 0:/* ww w .jav a  2s  .  co  m*/
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(getString(R.string.do_save_image)).setCancelable(false)
                .setPositiveButton(getString(R.string.save_yes), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                        exitOnComplete = true;
                        screenCapture();
                        //finish();
                    }
                }).setNeutralButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setNegativeButton(getString(R.string.save_no), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                        drawView.recycle();
                        finish();
                    }
                });

        return builder.create();
    default:
        return null;
    }
}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showPrompt(final Utils.PaymentType paymentType) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = null;/* www .  j a v a 2  s. c om*/
    String positiveButtonText = null;

    switch (paymentType) {
    case LOAD_MONEY:
    case AUTO_LOAD_MONEY:
        message = "Please enter the amount to load.";
        positiveButtonText = "Load Money";
        break;
    case CITRUS_CASH:
    case NEW_CITRUS_CASH:
        message = "Please enter the transaction amount.";
        positiveButtonText = "Pay";
        break;
    case PG_PAYMENT:
    case NEW_PG_PAYMENT:
    case WALLET_PG_PAYMENT:
        message = "Please enter the transaction amount.";
        positiveButtonText = "Make Payment";
        break;
    }

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    alert.setTitle("Transaction Amount?");
    alert.setMessage(message);
    // Set an EditText view to get user input
    final EditText input = new EditText(getActivity());
    input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    alert.setView(input);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString();

            mListener.onPaymentTypeSelected(paymentType, new Amount(value));

            input.clearFocus();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    input.requestFocus();
    alert.show();
}

From source file:com.instiwork.RegistrationActivity.java

public void displayMessage(String toastString) {
    android.app.AlertDialog.Builder alertDialogBuilder = new android.app.AlertDialog.Builder(
            RegistrationActivity.this);
    alertDialogBuilder.setTitle("Error");
    alertDialogBuilder.setMessage(Html.fromHtml(toastString)).setCancelable(false)
            .setPositiveButton("Retry", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }/*  w  w w. ja  v  a2  s. com*/
            }).setNegativeButton("Discard", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    onBackPressed();
                }
            });
    android.app.AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}

From source file:com.app.blockydemo.ui.adapter.BrickAdapter.java

private void showConfirmDeleteDialog(int itemPosition) {
    this.clickItemPosition = itemPosition;
    int titleId;/*from  w  ww  .ja v a2s.  c  o m*/

    if (getItem(clickItemPosition) instanceof ScriptBrick) {
        titleId = R.string.dialog_confirm_delete_script_title;
    } else {
        titleId = R.string.dialog_confirm_delete_brick_title;
    }

    AlertDialog.Builder builder = new CustomAlertDialogBuilder(context);
    builder.setTitle(titleId);
    builder.setMessage(R.string.dialog_confirm_delete_brick_message);
    builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            if (getItem(clickItemPosition) instanceof ScriptBrick) {
                scriptToDelete = ((ScriptBrick) getItem(clickItemPosition))
                        .initScript(ProjectManager.getInstance().getCurrentSprite());
                handleScriptDelete(sprite, scriptToDelete);
                scriptToDelete = null;
            } else {
                removeFromBrickListAndProject(clickItemPosition, false);
            }
        }
    });
    builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            scriptToDelete = null;
        }
    });

    AlertDialog alertDialog = builder.create();
    alertDialog.show();
}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showCvvPrompt(final PaymentOption paymentOption) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = "Please enter CVV.";
    String positiveButtonText = "OK";
    alert.setTitle("CVV");
    alert.setMessage(message);/*  w w  w .j  a v a2s .co m*/
    // Set an EditText view to get user input
    final EditText input = new EditText(getActivity());
    input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    input.setTransformationMethod(PasswordTransformationMethod.getInstance());
    InputFilter[] FilterArray = new InputFilter[1];
    FilterArray[0] = new InputFilter.LengthFilter(4);
    input.setFilters(FilterArray);
    alert.setView(input);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String cvv = input.getText().toString();
            input.clearFocus();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
            otherPaymentOption = paymentOption;
            ((CardOption) otherPaymentOption).setCardCVV(cvv);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
        }
    });

    input.requestFocus();
    alert.show();
}

From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java

public void refreshLabels(JSONObject jObject) {

    /* Button btn = new Button(this);
      btn.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
    getResources().getDimensionPixelSize(R.dimen.prediction_text_view_height) ));
    btn.setTextSize(pixels);//from   ww w . j av  a  2  s.c o  m
    btn.setText("Cat");
    predictions.addView(btn); */
    final List<RadioButton> buttons = new ArrayList<>();

    String result = "I think it's: ";
    try {
        JSONArray jArray = jObject.getJSONArray("data");
        for (int i = 0; i < jArray.length(); i++) {
            JSONObject prediction = jArray.getJSONObject(i);
            // Pulling items from the array
            int score = prediction.getInt("score");
            if (score < Constants.minScoreThershold) {
                continue;
            }
            String label = prediction.getString("label");

            result += "\"" + label + "\" : " + score + "% ";

            RadioButton radioButton = new RadioButton(EasyPaint.this);
            radioButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    getResources().getDimensionPixelSize(R.dimen.prediction_text_view_height)));
            radioButton.setTextSize(pixels5);
            radioButton.setText(label + " (" + score + "%)");
            radioButton.setTag(label);
            //radioButton.set
            //predictions.addView(radioButton);
            radioButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    saveButton.setTag(view.getTag());
                    feedbackType = ApiCallType.POSITIVE_FEEDBACK;
                }
            });

            buttons.add(radioButton);

        }

    } catch (JSONException e) {
        e.printStackTrace();
    }

    final RadioButton radioButton = new RadioButton(EasyPaint.this);
    radioButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            getResources().getDimensionPixelSize(R.dimen.prediction_text_view_height)));
    radioButton.setTextSize(pixels5);
    radioButton.setText(R.string.other_label);
    buttons.add(radioButton);

    radioButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            AlertDialog.Builder builder = new AlertDialog.Builder(EasyPaint.this);
            builder.setTitle(R.string.other_label);

            // Set up the input
            final EditText input = new EditText(EasyPaint.this);
            // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
            input.setInputType(InputType.TYPE_CLASS_TEXT);
            builder.setView(input);

            // Set up the buttons
            builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (input.getText().toString().length() > 0) {
                        radioButton.setText(input.getText().toString());
                        saveButton.setTag(input.getText().toString());
                        feedbackType = ApiCallType.NEGATIVE_FEEDBACK;
                    } else {
                        EasyPaint.this.runOnUiThread(new Runnable() {
                            public void run() {
                                Toast.makeText(getApplicationContext(),
                                        "You didn't specify a name, try again please", Toast.LENGTH_LONG)
                                        .show();
                            }
                        });
                        saveButton.setTag("");
                        feedbackType = ApiCallType.POSITIVE_FEEDBACK;
                        dialog.cancel();
                    }
                }
            });
            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    saveButton.setTag("");
                    feedbackType = ApiCallType.POSITIVE_FEEDBACK;
                    dialog.cancel();
                }
            });

            builder.show();
        }
    });

    saveButton.setOnClickListener(otherLabelOnClickListener);

    toastMessage = result;

    EasyPaint.this.runOnUiThread(new Runnable() {
        public void run() {
            resetPredictionsView(predictions, false);
            Toast.makeText(getApplicationContext(), toastMessage, Toast.LENGTH_LONG).show();
            for (RadioButton r : buttons) {
                predictions.addView(r);
            }
        }
    });

}