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.privacity.MenuActivity.java

public void gotoVisualizar(View view) {

    Intent intent = new Intent(this, PermisosActivity.class);
    String permisos = new String();
    JSONObject jsonObject = comm.obternerPemisosPorPalabras();

    if (!jsonObject.has("Error") & !jsonObject.has("detail")) { //Si no existen errores
        try {//from  w  ww  .j a va2s.co  m
            permisos = new String(jsonObject.get("permisos").toString());
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        intent.putExtra("permisos", permisos);
        startActivity(intent);
    } //IF
    else {
        Dialog dialogoError = new Dialog(this);
        dialogoError.setTitle(getResources().getString(R.string.errorDeConexion));
        dialogoError.show();
    }

}

From source file:fi.loezi.unifud.MainActivity.java

public void showAboutDialog() {

    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.dialog_fragment);
    dialog.setTitle("UniFud");

    final TextView text = (TextView) dialog.findViewById(R.id.dialogText);
    text.setText(//from w ww .j a v a 2  s  .  com
            "Created by Leo Leppnen (leo.leppanen@helsinki.fi)\n" + "\n" + "Data provided by HYY Ravintolat\n"
                    + "\n" + "Icons by Freepik and Icon Works from www.flaticon.com, licensed under CC BY 3.0");

    String version = null;
    try {
        version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
    } catch (PackageManager.NameNotFoundException exception) {
        version = "unknown";
    }

    text.append("\n\nVersion " + version);

    final Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);

    dialogButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();
}

From source file:fib.lcfib.raco.Controladors.ControladorLoginRaco.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.vista_login);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        queEs = extras.getString("queEs");
    }/* w ww  .j  a va 2  s .c  om*/

    loginDialog = new Dialog(this);
    showAddDialog();
}

From source file:com.commonsware.android.arXiv.arXiv.java

private boolean applyMenuChoice(MenuItem item) {
    switch (item.getItemId()) {
    case ABOUT_ID:
        String str = getString(R.string.about_text);
        TextView wv = new TextView(this);
        wv.setPadding(16, 0, 16, 16);/*w w w .j a v  a  2  s .  co m*/
        wv.setText(str);

        ScrollView scwv = new ScrollView(this);
        scwv.addView(wv);

        Dialog dialog = new Dialog(this) {
            public boolean onKeyDown(int keyCode, KeyEvent event) {
                if (keyCode != KeyEvent.KEYCODE_DPAD_LEFT)
                    this.dismiss();
                return true;
            }
        };
        dialog.setTitle(R.string.about_arxiv_droid);
        dialog.addContentView(scwv, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT));
        dialog.show();
        return (true);
    case HISTORY_ID:
        Intent myIntent = new Intent(this, DownloadsActivity.class);
        startActivity(myIntent);
        return (true);
    case PREF_ID:
        if (Build.VERSION.SDK_INT >= 11) {
            startActivity(new Intent(this, EditPreferences.class));
        } else {
            startActivity(new Intent(this, EditPreferencesCompat.class));
        }
        return (true);
    case DONATE_ID:
        Intent goToMarket = new Intent(Intent.ACTION_VIEW,
                Uri.parse("market://details?id=com.jd.android.arXiv"));
        try {
            startActivity(goToMarket);
        } catch (Exception ef) {
            Toast.makeText(this, "Market Not Installed", Toast.LENGTH_SHORT).show();
        }
        return (true);
    case SEARCH_ID:
        Intent search = new Intent(this, SearchWindow.class);
        startActivity(search);
        return (true);
    }
    return (false);
}

From source file:bos.whu.familytree.ui.activitys.base.BaseActivity.java

@Override
public void onNavigationDrawerItemSelected(int position) {
    switch (position) {
    case DrawerMenu.HOME:
        fragmentTransaction(new HomeFragment());
        break;//from  ww  w .ja va  2  s .  c om
    case DrawerMenu.ABOUT:
        Dialog dialog = new Dialog(this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.about_dialog);
        dialog.show();
        break;
    }
}

From source file:com.pileproject.drive.setting.app.ProgramListFragment.java

@Override
@NonNull/*from  w  ww  . ja  v a 2  s.co m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = new Dialog(getActivity());
    dialog.setTitle(R.string.setting_programList);

    return dialog;
}

From source file:com.applivery.applvsdklib.ui.views.update.MustUpdateViewImpl.java

/**
 * Overrided in order to get fullScreen dialog
 * @param savedInstanceState//from   w w w  .ja  v  a2 s  . c  om
 * @return
 */
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {

    final RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final Dialog dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(root);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.YELLOW));
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    return dialog;
}

From source file:de.androvdr.activities.ChannelsActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_WHATS_ON:
        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.extendedchannels_whats_on);
        dialog.setTitle(R.string.channels_whats_on);

        final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
        final DatePicker dp = (DatePicker) dialog.findViewById(R.id.channels_datePicker);
        final TimePicker tp = (TimePicker) dialog.findViewById(R.id.channels_timePicker);
        tp.setIs24HourView(DateFormat.is24HourFormat(getApplicationContext()));
        if (sp.contains("whats_on_hour")) {
            tp.setCurrentHour(sp.getInt("whats_on_hour", 0));
            tp.setCurrentMinute(sp.getInt("whats_on_minute", 0));
        }//from w ww .j av  a 2 s  . c  om

        Button button = (Button) dialog.findViewById(R.id.channels_cancel);
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        button = (Button) dialog.findViewById(R.id.channels_search);
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Editor editor = sp.edit();
                editor.putInt("whats_on_hour", tp.getCurrentHour());
                editor.putInt("whats_on_minute", tp.getCurrentMinute());
                editor.commit();

                SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy hh:mm");
                try {
                    long time = df.parse(dp.getDayOfMonth() + "." + (dp.getMonth() + 1) + "." + dp.getYear()
                            + " " + tp.getCurrentHour() + ":" + tp.getCurrentMinute()).getTime() / 1000;
                    getController().whatsOn(time);
                } catch (ParseException e) {
                    logger.error("Couldn't get date from pickers", e);
                }
                dialog.dismiss();
            }
        });
        return dialog;
    default:
        return super.onCreateDialog(id);
    }
}

From source file:com.normsstuff.maps4norm.Dialogs.java

/**
 * @param c     the Context/*w w w  .  j a v  a  2  s.c o m*/
 * @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.saveMarks).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View vX) {
            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.loadMarks).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 sometimes 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]), (MyMapActivity) 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, (MyMapActivity) c);
                b.setAdapter(da, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            Util.loadFromFile(Uri.fromFile(da.getFile(which)), (MyMapActivity) 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:net.networksaremadeofstring.rhybudd.ViewZenossEvent.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home: {
        finish();//w  w  w.  j av a2s .c  o  m
        return true;
    }

    case R.id.AddLog: {
        addMessageDialog = new Dialog(ViewZenossEvent.this);
        addMessageDialog.setContentView(R.layout.add_message);
        addMessageDialog.setTitle("Add Message to Event Log");
        ((Button) addMessageDialog.findViewById(R.id.SaveButton)).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                AddLogMessage(((EditText) addMessageDialog.findViewById(R.id.LogMessage)).getText().toString());
                addMessageDialog.dismiss();
            }
        });

        addMessageDialog.show();
        return true;
    }

    case R.id.escalate: {
        Intent intent = new Intent(android.content.Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);

        // Add data to the intent, the receiving app will decide what to do with it.
        intent.putExtra(Intent.EXTRA_SUBJECT,
                "Escalation of Zenoss Event on " + getIntent().getStringExtra("Device"));
        String EventDetails = getIntent().getStringExtra("Summary") + "\r\r\n"
                + getIntent().getStringExtra("LastTime") + "\r\r\n" + "Count: "
                + getIntent().getIntExtra("Count", 0);

        intent.putExtra(Intent.EXTRA_TEXT, EventDetails);

        startActivity(Intent.createChooser(intent, "How would you like to escalate this event?"));
    }

    default: {
        return false;
    }
    }
}