Example usage for android.app Dialog Dialog

List of usage examples for android.app Dialog Dialog

Introduction

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

Prototype

public Dialog(@NonNull Context context) 

Source Link

Document

Creates a dialog window that uses the default dialog theme.

Usage

From source file:com.siabra.discover.MainActivity.java

public void actualizarValidador(String verificador) {
    if (com.obtenerAccessToken(verificador)) {
        Intent intent = new Intent(this, CloudReco.class);
        startActivity(intent);// w  w w  .  j a v a  2  s .c om
        this.finish();
    } else {
        Dialog dialogoError = new Dialog(this);
        dialogoError.setTitle("Verficador incorrecto.");
        dialogoError.show();

    }
}

From source file:com.osama.cryptofm.tasks.MyProgressDialog.java

MyProgressDialog(Context context, String title, final AsyncTask task) {
    dialog = new Dialog(context);
    Log.d("dialog", "MyProgressDialog: not cancelable");
    dialog.setCanceledOnTouchOutside(false);
    this.mContext = context;
    this.mContentTitle = title;
    this.isInNotificationMode = false;
    dialog.setContentView(R.layout.task_progress_layout);
    ((TextView) dialog.findViewById(R.id.progress_dialog_title)).setText(title);
    mProgressTextView = ((TextView) dialog.findViewById(R.id.filename_progress_textview));
    mProgressBar = (ProgressBar) dialog.findViewById(R.id.dialog_progressbar);
    mProgressBar.setMax(100);/*from   ww  w  .  j a  v a2  s . c  om*/
    dialog.findViewById(R.id.runin_background_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
            buildNotification();
        }
    });
    dialog.findViewById(R.id.cancel_background_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.d("cancel", "Canceling the task");
            SharedData.IS_TASK_CANCELED = true;
            task.cancel(true);
            dialog.dismiss();

        }
    });
}

From source file:de.domjos.schooltools.activities.LearningCardOverviewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.learning_card_overview_activity);
    this.initControls();

    this.cmdLearningCardQueryStart.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w  ww .j  ava  2 s .c o m*/
        public void onClick(View v) {
            final LearningCardQueryTraining learningCardQueryTraining = new LearningCardQueryTraining();
            if (cmdLearningCardQueryStart.getText().equals(getString(R.string.learningCard_query))) {
                final Dialog dialog = new Dialog(LearningCardOverviewActivity.this);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.learning_card_dialog);
                dialog.setCancelable(true);

                final Spinner spLearningCardQuery = dialog.findViewById(R.id.spLearningCardQueries);
                final ArrayAdapter<LearningCardQuery> learningCardQueries = new ArrayAdapter<>(
                        getApplicationContext(), android.R.layout.simple_spinner_item,
                        MainActivity.globals.getSqLite().getLearningCardQueries(""));
                spLearningCardQuery.setAdapter(learningCardQueries);
                learningCardQueries.notifyDataSetChanged();

                final Button btnStartSop = dialog.findViewById(R.id.cmdStart);
                btnStartSop.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        learningCardQueryTraining.setLearningCardQuery(
                                learningCardQueries.getItem(spLearningCardQuery.getSelectedItemPosition()));
                        learningCardQueryTraining.setID(MainActivity.globals.getSqLite()
                                .insertOrUpdateLearningCardQueryTraining(learningCardQueryTraining));
                        cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query_end));
                        fragmentAdapter.setQuery(learningCardQueryTraining);
                        viewPager.setAdapter(fragmentAdapter);
                        dialog.dismiss();
                    }
                });
                dialog.show();
            } else {
                int wrongCards = 0, rightCards = 0, firstTry = 0, secondTry = 0, thirdTry = 0;
                LearningCardQueryTraining reloadedTraining = MainActivity.globals.getSqLite()
                        .getLearningCardQueryTraining("ID=" + learningCardQueryTraining.getID()).get(0);
                for (LearningCardQueryResult result : reloadedTraining.getResults()) {
                    if (result.isResult1() || result.isResult2() || result.isResult3()) {
                        rightCards++;
                        if (result.isResult1()) {
                            firstTry++;
                        } else if (result.isResult2()) {
                            secondTry++;
                        } else {
                            thirdTry++;
                        }
                    } else {
                        wrongCards++;
                    }
                }
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                        LearningCardOverviewActivity.this);
                alertDialogBuilder.setTitle(R.string.learningCard_result);
                String content = String.format("%s %s%n%s %s%n%s %s%n%s %s%n%s %s%n",
                        getString(R.string.learningCard_result_right), rightCards,
                        getString(R.string.learningCard_result_wrong), wrongCards,
                        getString(R.string.learningCard_result_firstTry), firstTry,
                        getString(R.string.learningCard_result_secondTry), secondTry,
                        getString(R.string.learningCard_result_thirdTry), thirdTry);
                alertDialogBuilder.setMessage(content);
                alertDialogBuilder.create().show();

                cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query));
                fragmentAdapter.setQuery(null);
                viewPager.setAdapter(fragmentAdapter);
            }
        }
    });
}

From source file:com.feathercoin.wallet.feathercoin.util.BitmapFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bitmap bitmap = (Bitmap) getArguments().getParcelable(KEY_BITMAP);

    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.bitmap_dialog);
    dialog.setCanceledOnTouchOutside(true);

    final ImageView imageView = (ImageView) dialog.findViewById(R.id.bitmap_dialog_image);
    imageView.setImageBitmap(bitmap);/*from  ww w. j ava  2  s .co m*/
    imageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View v) {
            dismiss();
        }
    });

    return dialog;
}

From source file:cc.mintcoin.wallet.util.BitmapFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bitmap bitmap = (Bitmap) getArguments().getParcelable(KEY_BITMAP);

    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.bitmap_dialog);
    dialog.setCanceledOnTouchOutside(true);

    final ImageView imageView = (ImageView) dialog.findViewById(R.id.bitmap_dialog_image);
    imageView.setImageBitmap(bitmap);/* w  w  w.  ja v a2  s  .  c o  m*/
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            dismiss();
        }
    });

    return dialog;
}

From source file:com.bushstar.kobocoin_android_wallet.util.BitmapFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bitmap bitmap = getArguments().getParcelable(KEY_BITMAP);

    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.bitmap_dialog);
    dialog.setCanceledOnTouchOutside(true);

    final ImageView imageView = (ImageView) dialog.findViewById(R.id.bitmap_dialog_image);
    imageView.setImageBitmap(bitmap);//from  w  w w  .  j  a  va2s  .co  m
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            dismiss();
        }
    });

    return dialog;
}

From source file:de.schildbach.wallet.ui.BitmapFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final BitmapDrawable bitmap = new BitmapDrawable(getResources(), (Bitmap) args.getParcelable(KEY_BITMAP));
    bitmap.setFilterBitmap(false);/*from   w  w w .jav  a 2  s. c  o  m*/

    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.bitmap_dialog);
    dialog.setCanceledOnTouchOutside(true);

    final ImageView imageView = (ImageView) dialog.findViewById(R.id.bitmap_dialog_image);
    imageView.setImageDrawable(bitmap);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            dismissAllowingStateLoss();
        }
    });

    return dialog;
}

From source file:de.schildbach.litecoinwallet.ui.HelpDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final String page = args.getString(KEY_PAGE);

    final WebView webView = new WebView(activity);
    webView.loadUrl("file:///android_asset/" + page + languagePrefix() + ".html");

    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(webView);//from w  ww  .j av a2  s . co  m
    dialog.setCanceledOnTouchOutside(true);

    return dialog;
}

From source file:de.j4velin.mapsmeasure.Dialogs.java

/**
 * @param c     the Context/*from   w w w  . j  av a2s .com*/
 * @param trace the current trace of points
 * @return the "save & share" dialog
 */
public static Dialog getSaveNShare(final Activity c, final Stack<LatLng> trace) {
    final Dialog d = new Dialog(c);
    d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    d.setContentView(R.layout.dialog_save);
    d.findViewById(R.id.save).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            final File destination;
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO
                    && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
                destination = API8Wrapper.getExternalFilesDir(c);
            } else {
                destination = c.getDir("traces", Context.MODE_PRIVATE);
            }

            d.dismiss();
            AlertDialog.Builder b = new AlertDialog.Builder(c);
            b.setTitle(R.string.save);
            final View layout = c.getLayoutInflater().inflate(R.layout.dialog_enter_filename, null);
            ((TextView) layout.findViewById(R.id.location))
                    .setText(c.getString(R.string.file_path, destination.getAbsolutePath() + "/"));
            b.setView(layout);
            b.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        String fname = ((EditText) layout.findViewById(R.id.filename)).getText().toString();
                        if (fname == null || fname.length() < 1) {
                            fname = "MapsMeasure_" + System.currentTimeMillis();
                        }
                        final File f = new File(destination, fname + ".csv");
                        Util.saveToFile(f, trace);
                        d.dismiss();
                        Toast.makeText(c, c.getString(R.string.file_saved, f.getAbsolutePath()),
                                Toast.LENGTH_SHORT).show();
                    } catch (Exception e) {
                        Toast.makeText(c,
                                c.getString(R.string.error,
                                        e.getClass().getSimpleName() + "\n" + e.getMessage()),
                                Toast.LENGTH_LONG).show();
                    }
                }
            });
            b.create().show();
        }
    });
    d.findViewById(R.id.load).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {

            File[] files = c.getDir("traces", Context.MODE_PRIVATE).listFiles();

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO
                    && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
                File ext = API8Wrapper.getExternalFilesDir(c);
                // even though we checked the external storage state, ext is still sometims null, accoring to Play Store crash reports
                if (ext != null) {
                    File[] filesExtern = ext.listFiles();
                    File[] allFiles = new File[files.length + filesExtern.length];
                    System.arraycopy(files, 0, allFiles, 0, files.length);
                    System.arraycopy(filesExtern, 0, allFiles, files.length, filesExtern.length);
                    files = allFiles;
                }
            }

            if (files.length == 0) {
                Toast.makeText(c,
                        c.getString(R.string.no_files_found,
                                c.getDir("traces", Context.MODE_PRIVATE).getAbsolutePath()),
                        Toast.LENGTH_SHORT).show();
            } else if (files.length == 1) {
                try {
                    Util.loadFromFile(Uri.fromFile(files[0]), (Map) c);
                    d.dismiss();
                } catch (IOException e) {
                    e.printStackTrace();
                    Toast.makeText(c,
                            c.getString(R.string.error, e.getClass().getSimpleName() + "\n" + e.getMessage()),
                            Toast.LENGTH_LONG).show();
                }
            } else {
                d.dismiss();
                AlertDialog.Builder b = new AlertDialog.Builder(c);
                b.setTitle(R.string.select_file);
                final DeleteAdapter da = new DeleteAdapter(files, (Map) c);
                b.setAdapter(da, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            Util.loadFromFile(Uri.fromFile(da.getFile(which)), (Map) c);
                            dialog.dismiss();
                        } catch (IOException e) {
                            e.printStackTrace();
                            Toast.makeText(c,
                                    c.getString(R.string.error,
                                            e.getClass().getSimpleName() + "\n" + e.getMessage()),
                                    Toast.LENGTH_LONG).show();
                        }
                    }
                });
                b.create().show();
            }
        }
    });
    d.findViewById(R.id.share).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            try {
                final File f = new File(c.getCacheDir(), "MapsMeasure.csv");
                Util.saveToFile(f, trace);
                Intent shareIntent = new Intent();
                shareIntent.setAction(Intent.ACTION_SEND);
                shareIntent.putExtra(Intent.EXTRA_STREAM,
                        FileProvider.getUriForFile(c, "de.j4velin.mapsmeasure.fileprovider", f));
                shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                shareIntent.setType("text/comma-separated-values");
                d.dismiss();
                c.startActivity(Intent.createChooser(shareIntent, null));
            } catch (IOException e) {
                e.printStackTrace();
                Toast.makeText(c,
                        c.getString(R.string.error, e.getClass().getSimpleName() + "\n" + e.getMessage()),
                        Toast.LENGTH_LONG).show();
            }
        }
    });
    return d;
}

From source file:com.example.android.common.play.GoogleServicesConnectionFailedHelper.java

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {

    /*/*from  w  w w.ja  v  a2 s  .c  o m*/
     * Google Play services can resolve some errors it detects.
     * If the error has a resolution, try sending an Intent to
     * start a Google Play services activity that can resolve
     * error.
     */
    if (connectionResult.hasResolution()) {
        try {
            // Start an Activity that tries to resolve the error
            connectionResult.startResolutionForResult(mActivity, mRequestCode);
            /*
             * Thrown if Google Play services canceled the original
             * PendingIntent
             */
        } catch (IntentSender.SendIntentException e) {
            // Log the error
            e.printStackTrace();
        }
    } else {
        /*
         * If no resolution is available, display a dialog to the
         * user with the error.
         */
        PlayHelper.ErrorDialogFragment fragment = new PlayHelper.ErrorDialogFragment();
        fragment.setDialog(new Dialog(mActivity));
        fragment.show(mActivity.getSupportFragmentManager(), null);

    }
}