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.zpwebsites.linuxonandroid.Install_Debian_Testing_2.java

private void downloads(Context context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.download_debian_menu);
    dialog.setCancelable(true);//  w  w  w . j  a  v a  2 s. com

    Button btn_DownloadLarge = (Button) dialog.findViewById(R.id.btn_DownloadLarge);
    btn_DownloadLarge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Large_ext4,
                        CFG.imageURL_Debian_Testing_Large_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Large_ext2,
                        CFG.imageURL_Debian_Testing_Large_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadSmall = (Button) dialog.findViewById(R.id.btn_DownloadSmall);
    btn_DownloadSmall.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Small_ext4,
                        CFG.imageURL_Debian_Testing_Small_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Small_ext2,
                        CFG.imageURL_Debian_Testing_Small_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadCore = (Button) dialog.findViewById(R.id.btn_DownloadCore);
    btn_DownloadCore.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Core_ext4,
                        CFG.imageURL_Debian_Testing_Core_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Core_ext2,
                        CFG.imageURL_Debian_Testing_Core_ext2);
            }
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:com.zpwebsites.linuxonandroid.Install_Ubuntu13_2.java

private void downloads(Context context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.download_ubuntu13_menu);
    dialog.setCancelable(true);// w  ww . j av a2  s .c o  m

    Button btn_DownloadCore = (Button) dialog.findViewById(R.id.btn_DownloadCore);
    btn_DownloadCore.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Core_ext4,
                        CFG.imageURL_Ubuntu13_Core_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Core_ext2,
                        CFG.imageURL_Ubuntu13_Core_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadLarge = (Button) dialog.findViewById(R.id.btn_DownloadLarge);
    btn_DownloadLarge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Large_ext4,
                        CFG.imageURL_Ubuntu13_Large_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Large_ext2,
                        CFG.imageURL_Ubuntu13_Large_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadSmall = (Button) dialog.findViewById(R.id.btn_DownloadSmall);
    btn_DownloadSmall.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Small_ext4,
                        CFG.imageURL_Ubuntu13_Small_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Small_ext2,
                        CFG.imageURL_Ubuntu13_Small_ext2);
            }
            dialog.dismiss();
        }
    });
    dialog.show();

}

From source file:com.pileproject.drive.setting.machine.BluetoothMachineSelectFragment.java

@Override
@NonNull//ww  w .  j a  v  a  2  s  .  c om
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = new Dialog(getActivity());
    dialog.setTitle(R.string.setting_bluetoothMachineSelect);

    return dialog;
}

From source file:com.luke.lukef.lukeapp.popups.AdminMarkerPopup.java

public void createPopupAdmin() {

    this.dialog = new Dialog(mainActivity);
    // Include dialog.xml file
    this.dialog.setContentView(R.layout.popup_admin_marker);

    // find views
    this.submissionImage = (ImageView) this.dialog.findViewById(R.id.submissionImageMain);
    this.submissionDescription = (TextView) this.dialog.findViewById(R.id.reportDescription);
    this.submissionSubmitterName = (TextView) this.dialog.findViewById(R.id.submissionSubmitterName);
    this.submissionDate = (TextView) this.dialog.findViewById(R.id.submissionDate);
    this.popupButtonPositive = (ImageButton) this.dialog.findViewById(R.id.popup_button_positive);
    this.loadingSpinny = (ProgressBar) this.dialog.findViewById(R.id.progressBarSubmissionPopup);
    this.mainView = this.dialog.findViewById(R.id.popupMainContent);
    this.submissionTitle = (TextView) this.dialog.findViewById(R.id.submissionTitle);

    // set click listeners
    this.popupButtonPositive.setOnClickListener(this);
    this.submissionImage.setOnClickListener(this);
    this.submissionImage.setOnClickListener(this);

    getLocalSubmissionData();//from  w w w .j  ava 2  s.  c  o m
    this.dialog.show();
}

From source file:com.privacity.BuscarPerfilActivity.java

public void enviarCodigo(View view) {
    EditText txtv = (EditText) findViewById(R.id.editEnviarCodigo);
    String codigo = txtv.getText().toString();
    JSONObject jsonObject = com.getPerfil(codigo);

    if (!jsonObject.has("Error") && !jsonObject.has("detail")) {
        try {/*from w ww. ja  v a 2  s .c  om*/
            Intent intent = new Intent(this, PerfilActivity.class);
            intent.putExtra("descripcion", jsonObject.getString("descripcion"));
            intent.putExtra("permisos", jsonObject.getString("permisos"));
            Log.wtf("PERMISOS", jsonObject.getString("permisos"));
            intent.putExtra("usuario", jsonObject.getString("usuario"));
            intent.putExtra("codigo", codigo);
            intent.putExtra("agregado", jsonObject.getString("agregado"));
            startActivity(intent);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Log.wtf("Error", e);
        }
    } //IF
    else {
        Dialog dialogoError = new Dialog(this);
        try {
            String error = jsonObject.getString("Error");
            dialogoError.setTitle(error);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            dialogoError.setTitle(R.string.Upps);
            e.printStackTrace();
        }
        dialogoError.show();
    }

}

From source file:com.luke.lukef.lukeapp.popups.CategoriesPopup.java

/**
 * Constructor for creating a categories pop up
 *
 * @param mainActivity        Used as context
 * @param onItemClickListener To listen to clicks on the list of submissions
 * @param buOnClickListener   To listen to clicks on the accept button
 * @param confirmedCategories List of currently confirmed categories to add to the submission
 * @param onCancelListener    Listener to listen for cancel events, like clicking outside of the popup or the back button
 *///ww  w .j a v  a2  s. com
public CategoriesPopup(MainActivity mainActivity, AdapterView.OnItemClickListener onItemClickListener,
        View.OnClickListener buOnClickListener, ArrayList<Category> confirmedCategories,
        DialogInterface.OnCancelListener onCancelListener) {
    this.mainActivity = mainActivity;
    this.dialog = new Dialog(mainActivity);
    this.onClickListener = onItemClickListener;
    this.buttonListener = buOnClickListener;
    this.confirmedCategories = confirmedCategories;
    this.onCancelListener = onCancelListener;
}

From source file:net.networksaremadeofstring.pulsant.portal.ColoLanding.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cololanding);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Colocation");

    detailsdialog = new Dialog(this);

    EditHandler = new Handler() {
        public void handleMessage(Message msg) {
            if (msg.what == 0) {
                Toast.makeText(ColoLanding.this, "Description updated successfully!", Toast.LENGTH_SHORT)
                        .show();/*from w w w . j a  v  a2s. c  om*/
            } else {
                Toast.makeText(ColoLanding.this, "There was an error updating that description",
                        Toast.LENGTH_SHORT).show();
            }
        }
    };

    //Temp
    list = (ListView) findViewById(R.id.ColoCabList);
    final ProgressDialog dialog = ProgressDialog.show(this, "Pulsant Portal", "Please wait: loading data....",
            true);
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();
            if (Success.equals("true")) {
                UpdateErrorMessage(ErrorMessage);
                adapter = new ColoRacksAdaptor(ColoLanding.this, listOfColoRacks);
                list.setAdapter(adapter);
                list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
            } else {
                UpdateErrorMessage(ErrorMessage);
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            try {
                Colo = API.PortalQuery("colocation", "none");
                Success = Colo.getString("success");
            } catch (JSONException e) {
                ErrorMessage = "An unrecoverable JSON Exception occurred.";
                //UpdateErrorMessage("An unrecoverable JSON Exception occurred.");
            }

            if (Success.equals("false")) {
                try {
                    //UpdateErrorMessage(Colo.getString("msg"));
                    ErrorMessage = Colo.getString("msg");
                } catch (JSONException e) {
                    ErrorMessage = "An unrecoverable JSON Exception occured.";
                    //UpdateErrorMessage("An unrecoverable JSON Exception occured.");
                }
            } else {
                Log.i("APIFuncs", Colo.toString());
                try {
                    ColoCabs = Colo.getJSONArray("colocation");
                    ErrorMessage = "";
                    //UpdateErrorMessage("");
                } catch (JSONException e) {
                    ErrorMessage = "There are no Co-Location Cabinets in your account.";
                    //UpdateErrorMessage("There are no Co-Location Cabinets in your account.");
                }

                int ColoCount = ColoCabs.length();

                if (ColoCount == 0) {
                    //UpdateErrorMessage("There are no colocation cabinets for your account.");
                    ErrorMessage = "There are no colocation cabinets for your account.";
                    handler.sendEmptyMessage(0);
                    return;
                }

                for (int i = 0; i < ColoCount; i++) {
                    JSONObject CurrentColo = null;
                    try {
                        CurrentColo = ColoCabs.getJSONObject(i);
                    } catch (JSONException e1) {
                        Log.e("APIFuncs", e1.getMessage());
                    }

                    try {
                        listOfColoRacks.add(new ColoRacks(CurrentColo.getString("ip"),
                                CurrentColo.getString("servercode"), CurrentColo.getString("facility"),
                                CurrentColo.getInt("bandwidth"), CurrentColo.getString("bandwidthTotal"),
                                CurrentColo.getInt("transferlimit"), CurrentColo.getString("state"),
                                CurrentColo.getString("description")));
                    } catch (JSONException e) {
                        Log.e("APIFuncs", e.getMessage());
                    }
                }
            }
            handler.sendEmptyMessage(0);
        }
    };

    dataPreload.start();
}

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

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final Address address = (Address) args.getSerializable(KEY_ADDRESS);
    final String addressStr = address.toBase58();
    final String addressLabel = args.getString(KEY_ADDRESS_LABEL);

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

    final String uri = BitcoinURI.convertToBitcoinURI(address, null, addressLabel, null);
    final BitmapDrawable bitmap = new BitmapDrawable(getResources(), Qr.bitmap(uri));
    bitmap.setFilterBitmap(false);/*from  w  w w  .  j a  v  a  2 s. c  om*/
    final ImageView imageView = (ImageView) dialog.findViewById(R.id.wallet_address_dialog_image);
    imageView.setImageDrawable(bitmap);

    final View labelButtonView = dialog.findViewById(R.id.wallet_address_dialog_label_button);
    final TextView labelView = (TextView) dialog.findViewById(R.id.wallet_address_dialog_label);
    final CharSequence label = WalletUtils.formatHash(addressStr, Constants.ADDRESS_FORMAT_GROUP_SIZE,
            Constants.ADDRESS_FORMAT_LINE_SIZE);
    labelView.setText(label);
    labelButtonView.setVisibility(View.VISIBLE);
    labelButtonView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            final Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TEXT, addressStr);
            startActivity(Intent.createChooser(intent, getString(R.string.bitmap_fragment_share)));
            log.info("wallet address shared via intent: {}", addressStr);
        }
    });

    final View hintView = dialog.findViewById(R.id.wallet_address_dialog_hint);
    hintView.setVisibility(
            getResources().getBoolean(R.bool.show_wallet_address_dialog_hint) ? View.VISIBLE : View.GONE);

    final View dialogView = dialog.findViewById(R.id.wallet_address_dialog_group);
    dialogView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            dismiss();
        }
    });

    return dialog;
}

From source file:com.tgaubert.blefinder.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_reset) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.activity_main_reset_title);
        builder.setMessage(R.string.activity_main_reset_text);
        builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
            @Override/*from  w ww . ja  va 2s.c  o m*/
            public void onClick(DialogInterface dialog, int which) {
                BeaconIO.getSeenBeacons().clear();
                Snackbar.make(findViewById(R.id.floating_btn), R.string.activity_main_reset_done,
                        Snackbar.LENGTH_LONG).show();
            }
        });
        builder.setNegativeButton(R.string.no, null);
        builder.show();
    }

    if (id == R.id.action_about) {
        final Dialog dialog = new Dialog(this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.dialog_about);
        WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        dialog.getWindow().setAttributes(params);
        dialog.show();

        PackageInfo pInfo = null;
        try {
            pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        if (pInfo != null)
            ((TextView) dialog.findViewById(R.id.appVersion)).setText(pInfo.versionName);

        dialog.findViewById(R.id.dialogLicenses).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();

                final Dialog licenseDialog = new Dialog(v.getContext());
                licenseDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                licenseDialog.setContentView(R.layout.dialog_licenses);
                WindowManager.LayoutParams licenseParams = licenseDialog.getWindow().getAttributes();
                licenseParams.width = WindowManager.LayoutParams.MATCH_PARENT;
                licenseDialog.getWindow().setAttributes(licenseParams);
                licenseDialog.show();

                String licenses = "<h3>android-beacon-library</h3>" + "<p>Copyright 2014 Radius Networks</p>\n"
                        + "\n" + "   <p>Licensed under the Apache License, Version 2.0 (the \"License\");\n"
                        + "   you may not use this file except in compliance with the License.\n"
                        + "   You may obtain a copy of the License at</p>\n" + "\n"
                        + "       <p>http://www.apache.org/licenses/LICENSE-2.0</p>\n" + "\n"
                        + "   <p>Unless required by applicable law or agreed to in writing, software\n"
                        + "   distributed under the License is distributed on an \"AS IS\" BASIS,\n"
                        + "   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
                        + "   See the License for the specific language governing permissions and\n"
                        + "   limitations under the License.</p>" + "<h3>BottomSheet</h3>"
                        + "<p>Copyright 2011, 2015 Kai Liao</p>\n" + "\n"
                        + "<p>Licensed under the Apache License, Version 2.0 (the \"License\");\n"
                        + "you may not use this file except in compliance with the License.\n"
                        + "You may obtain a copy of the License at</p>\n" + "\n"
                        + "   <p>http://www.apache.org/licenses/LICENSE-2.0</p>\n" + "\n"
                        + "<p>Unless required by applicable law or agreed to in writing, software\n"
                        + "distributed under the License is distributed on an \"AS IS\" BASIS,\n"
                        + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
                        + "See the License for the specific language governing permissions and\n"
                        + "limitations under the License.</p>";

                ((TextView) licenseDialog.findViewById(R.id.dialogText)).setText(Html.fromHtml(licenses));

                licenseDialog.findViewById(R.id.licenseOk).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        licenseDialog.dismiss();
                    }
                });
            }
        });

        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.lrhehe.android.common.share.ShareDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = new Dialog(getActivity());
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    // may have proble to inject in a dialog fragment
    ViewUtils.inject(getActivity());/* ww  w . ja va2 s  .c  om*/
    afterViewsInflate(dialog);
    return dialog;
}