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:de.cachebox_test.splash.java

@SuppressWarnings("deprecation")
@Override/*from   ww  w. j a va 2s .  co  m*/
protected void onStart() {
    super.onStart();
    Log.debug(log, "onStart");

    if (android.os.Build.VERSION.SDK_INT >= 23) {
        PermissionCheck.checkNeededPermissions(this);
    }

    // initial GDX
    Gdx.files = new AndroidFiles(this.getAssets(), this.getFilesDir().getAbsolutePath());
    // first, try to find stored preferences of workPath
    androidSetting = this.getSharedPreferences(Global.PREFS_NAME, 0);

    workPath = androidSetting.getString("WorkPath", Environment.getDataDirectory() + "/cachebox");
    boolean askAgain = androidSetting.getBoolean("AskAgain", true);
    showSandbox = androidSetting.getBoolean("showSandbox", false);

    Global.initTheme(this);
    Global.InitIcons(this);

    CB_Android_FileExplorer fileExplorer = new CB_Android_FileExplorer(this);
    PlatformConnector.setGetFileListener(fileExplorer);
    PlatformConnector.setGetFolderListener(fileExplorer);

    String LangPath = androidSetting.getString("Sel_LanguagePath", "");
    if (LangPath.length() == 0) {
        // set default lang

        String locale = Locale.getDefault().getLanguage();
        if (locale.contains("de")) {
            LangPath = "data/lang/de/strings.ini";
        } else if (locale.contains("cs")) {
            LangPath = "data/lang/cs/strings.ini";
        } else if (locale.contains("cs")) {
            LangPath = "data/lang/cs/strings.ini";
        } else if (locale.contains("fr")) {
            LangPath = "data/lang/fr/strings.ini";
        } else if (locale.contains("nl")) {
            LangPath = "data/lang/nl/strings.ini";
        } else if (locale.contains("pl")) {
            LangPath = "data/lang/pl/strings.ini";
        } else if (locale.contains("pt")) {
            LangPath = "data/lang/pt/strings.ini";
        } else if (locale.contains("hu")) {
            LangPath = "data/lang/hu/strings.ini";
        } else {
            LangPath = "data/lang/en-GB/strings.ini";
        }
    }

    new Translation(workPath, FileType.Internal);
    try {
        Translation.LoadTranslation(LangPath);
    } catch (Exception e) {
        e.printStackTrace();
    }

    // check Write permission
    if (!askAgain) {
        if (!FileIO.checkWritePermission(workPath)) {
            askAgain = true;
            if (!ToastEx) {
                ToastEx = true;
                String WriteProtectionMsg = Translation.Get("NoWriteAcces");
                Toast.makeText(splash.this, WriteProtectionMsg, Toast.LENGTH_LONG).show();
            }
        }
    }

    if ((askAgain)) {
        // no saved workPath found -> search sd-cards and if more than 1 is found give the user the possibility to select one

        String externalSd = getExternalSdPath("/CacheBox");

        boolean hasExtSd;
        final String externalSd2 = externalSd;

        if (externalSd != null) {
            hasExtSd = (externalSd.length() > 0) && (!externalSd.equalsIgnoreCase(workPath));
        } else {
            hasExtSd = false;
        }

        // externe SD wurde gefunden != internal
        // oder Tablet Layout mglich
        // -> Auswahldialog anzeigen
        try {
            final Dialog dialog = new Dialog(context) {
                @Override
                public boolean onKeyDown(int keyCode, KeyEvent event) {
                    if (keyCode == KeyEvent.KEYCODE_BACK) {
                        splash.this.finish();
                    }
                    return super.onKeyDown(keyCode, event);
                }
            };

            dialog.setContentView(R.layout.sdselectdialog);
            TextView title = (TextView) dialog.findViewById(R.id.select_sd_title);
            title.setText(Translation.Get("selectWorkSpace") + "\n\n");
            /*
             * TextView tbLayout = (TextView) dialog.findViewById(R.id.select_sd_layout); tbLayout.setText("\nLayout"); final RadioGroup
             * rgLayout = (RadioGroup) dialog.findViewById(R.id.select_sd_radiogroup); final RadioButton rbHandyLayout = (RadioButton)
             * dialog.findViewById(R.id.select_sd_handylayout); final RadioButton rbTabletLayout = (RadioButton)
             * dialog.findViewById(R.id.select_sd_tabletlayout); rbHandyLayout.setText("Handy-Layout");
             * rbTabletLayout.setText("Tablet-Layout"); if (!GlobalCore.posibleTabletLayout) {
             * rgLayout.setVisibility(RadioGroup.INVISIBLE); rbHandyLayout.setChecked(true); } else { if (GlobalCore.isTab) {
             * rbTabletLayout.setChecked(true); } else { rbHandyLayout.setChecked(true); } }
             */
            final CheckBox cbAskAgain = (CheckBox) dialog.findViewById(R.id.select_sd_askagain);
            cbAskAgain.setText(Translation.Get("AskAgain"));
            cbAskAgain.setChecked(askAgain);
            Button buttonI = (Button) dialog.findViewById(R.id.button1);
            buttonI.setText("Internal SD\n\n" + workPath);
            buttonI.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    // close select dialog
                    dialog.dismiss();

                    // show please wait dialog
                    showPleaseWaitDialog();

                    // use internal SD -> nothing to change
                    Thread thread = new Thread() {
                        @Override
                        public void run() {
                            boolean askAgain = cbAskAgain.isChecked();
                            // boolean useTabletLayout = rbTabletLayout.isChecked();
                            saveWorkPath(askAgain/* , useTabletLayout */);
                            dialog.dismiss();
                            startInitial();
                        }
                    };
                    thread.start();
                }
            });
            Button buttonE = (Button) dialog.findViewById(R.id.button2);
            final boolean isSandbox = externalSd == null ? false
                    : externalSd.contains("Android/data/de.cachebox_test");
            if (!hasExtSd) {
                buttonE.setVisibility(Button.INVISIBLE);
            } else {
                String extSdText = isSandbox ? "External SD SandBox\n\n" : "External SD\n\n";
                buttonE.setText(extSdText + externalSd);
            }

            buttonE.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    // show KitKat Massage?

                    if (isSandbox && !showSandbox) {
                        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

                        // set title
                        alertDialogBuilder.setTitle("KitKat Sandbox");

                        // set dialog message
                        alertDialogBuilder.setMessage(Translation.Get("Desc_Sandbox")).setCancelable(false)
                                .setPositiveButton(Translation.Get("yes"),
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int id) {
                                                // if this button is clicked, run Sandbox Path

                                                showSandbox = true;
                                                Config.AcceptChanges();

                                                // close select dialog
                                                dialog.dismiss();

                                                // show please wait dialog
                                                showPleaseWaitDialog();

                                                // use external SD -> change workPath
                                                Thread thread = new Thread() {
                                                    @Override
                                                    public void run() {
                                                        workPath = externalSd2;
                                                        boolean askAgain = cbAskAgain.isChecked();
                                                        // boolean useTabletLayout = rbTabletLayout.isChecked();
                                                        saveWorkPath(askAgain/* , useTabletLayout */);
                                                        startInitial();
                                                    }
                                                };
                                                thread.start();
                                            }
                                        })
                                .setNegativeButton(Translation.Get("no"),
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int id) {
                                                // if this button is clicked, just close
                                                // the dialog box and do nothing
                                                dialog.cancel();
                                            }
                                        });

                        // create alert dialog
                        AlertDialog alertDialog = alertDialogBuilder.create();

                        // show it
                        alertDialog.show();
                    } else {
                        // close select dialog
                        dialog.dismiss();

                        // show please wait dialog
                        showPleaseWaitDialog();

                        // use external SD -> change workPath
                        Thread thread = new Thread() {
                            @Override
                            public void run() {
                                workPath = externalSd2;
                                boolean askAgain = cbAskAgain.isChecked();
                                // boolean useTabletLayout = rbTabletLayout.isChecked();
                                saveWorkPath(askAgain/* , useTabletLayout */);
                                startInitial();
                            }
                        };
                        thread.start();
                    }
                }
            });

            LinearLayout ll = (LinearLayout) dialog.findViewById(R.id.scrollViewLinearLayout);

            // add all Buttons for created Workspaces

            AdditionalWorkPathArray = getAdditionalWorkPathArray();

            for (final String AddWorkPath : AdditionalWorkPathArray) {

                final String Name = FileIO.GetFileNameWithoutExtension(AddWorkPath);

                if (!FileIO.checkWritePermission(AddWorkPath)) {
                    // delete this Work Path
                    deleteWorkPath(AddWorkPath);
                    continue;
                }

                Button buttonW = new Button(context);
                buttonW.setText(Name + "\n\n" + AddWorkPath);

                buttonW.setOnLongClickListener(new OnLongClickListener() {

                    @Override
                    public boolean onLongClick(View v) {

                        // setting the MassageBox then the UI_sizes are not initial in this moment
                        Resources res = splash.this.getResources();
                        float scale = res.getDisplayMetrics().density;
                        float calcBase = 533.333f * scale;

                        FrameLayout frame = (FrameLayout) findViewById(R.id.frameLayout1);
                        int width = frame.getMeasuredWidth();
                        int height = frame.getMeasuredHeight();

                        MessageBox.Builder.WindowWidth = width;
                        MessageBox.Builder.WindowHeight = height;
                        MessageBox.Builder.textSize = (calcBase
                                / res.getDimensionPixelSize(R.dimen.BtnTextSize)) * scale;
                        MessageBox.Builder.ButtonHeight = (int) (50 * scale);

                        // Ask before delete
                        msg = (MessageBox) MessageBox.Show(Translation.Get("shuredeleteWorkspace", Name),
                                Translation.Get("deleteWorkspace"), MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question, new DialogInterface.OnClickListener() {

                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        if (which == MessageBox.BUTTON_POSITIVE) {
                                            // Delete this Workpath only from Settings don't delete any File
                                            deleteWorkPath(AddWorkPath);
                                        }
                                        // Start again to exclude the old Folder
                                        msg.dismiss();
                                        onStart();
                                    }

                                });

                        dialog.dismiss();
                        return true;
                    }
                });

                buttonW.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        // close select dialog
                        dialog.dismiss();

                        // show please wait dialog
                        showPleaseWaitDialog();

                        // use external SD -> change workPath
                        Thread thread = new Thread() {
                            @Override
                            public void run() {
                                workPath = AddWorkPath;
                                boolean askAgain = cbAskAgain.isChecked();
                                // boolean useTabletLayout = rbTabletLayout.isChecked();
                                saveWorkPath(askAgain/* , useTabletLayout */);
                                startInitial();
                            }
                        };
                        thread.start();

                    }
                });

                ll.addView(buttonW);
            }

            Button buttonC = (Button) dialog.findViewById(R.id.buttonCreateWorkspace);
            buttonC.setText(Translation.Get("createWorkSpace"));
            buttonC.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    // close select dialog
                    dialog.dismiss();
                    getFolderReturnListener = new IgetFolderReturnListener() {

                        @Override
                        public void getFolderReturn(String Path) {
                            if (FileIO.checkWritePermission(Path)) {

                                AdditionalWorkPathArray.add(Path);
                                writeAdditionalWorkPathArray(AdditionalWorkPathArray);
                                // Start again to include the new Folder
                                onStart();
                            } else {
                                String WriteProtectionMsg = Translation.Get("NoWriteAcces");
                                Toast.makeText(splash.this, WriteProtectionMsg, Toast.LENGTH_LONG).show();
                            }
                        }
                    };

                    PlatformConnector.getFolder("", Translation.Get("select_folder"), Translation.Get("select"),
                            getFolderReturnListener);

                }
            });

            dialog.show();

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    } else {
        if (GlobalCore.displayType == DisplayType.Large || GlobalCore.displayType == DisplayType.xLarge)
            GlobalCore.isTab = isLandscape;

        // restore the saved workPath
        // test whether workPath is available by checking the free size on the SD
        String workPathToTest = workPath.substring(0, workPath.lastIndexOf("/"));
        long bytesAvailable = 0;
        try {
            StatFs stat = new StatFs(workPathToTest);
            bytesAvailable = (long) stat.getBlockSize() * (long) stat.getBlockCount();
        } catch (Exception ex) {
            bytesAvailable = 0;
        }
        if (bytesAvailable == 0) {
            // there is a workPath stored but this workPath is not available at the moment (maybe SD is removed)
            Toast.makeText(splashActivity,
                    "WorkPath " + workPath + " is not available!\nMaybe SD-Card is removed?", Toast.LENGTH_LONG)
                    .show();
            finish();
            return;
        }

        startInitial();
    }

}

From source file:com.ibm.hellotodo.MainActivity.java

/**
 * Launches a dialog for updating the TodoItem name. Called when the list item is tapped.
 *
 * @param view The TodoItem that is tapped.
 *///from   w ww. j  ava2s . co  m
public void editTodoName(View view) {
    // Gets position in list view of tapped item
    final Integer pos = mListView.getPositionForView(view);
    final Dialog addDialog = new Dialog(this);

    addDialog.setContentView(R.layout.add_edit_dialog);
    addDialog.setTitle("Edit Todo");
    TextView textView = (TextView) addDialog.findViewById(android.R.id.title);
    if (textView != null) {
        textView.setGravity(Gravity.CENTER);
    }
    addDialog.setCancelable(true);
    EditText et = (EditText) addDialog.findViewById(R.id.todo);

    final String name = mTodoItemList.get(pos).text;
    final boolean isDone = mTodoItemList.get(pos).isDone;
    final int id = mTodoItemList.get(pos).idNumber;
    et.setText(name);

    Button addDone = (Button) addDialog.findViewById(R.id.Add);
    addDialog.show();

    // When done is pressed, send PUT request to update TodoItem on Bluemix
    addDone.setOnClickListener(new View.OnClickListener() {
        // Save text inputted when done is tapped
        @Override
        public void onClick(View view) {
            EditText editedText = (EditText) addDialog.findViewById(R.id.todo);

            String newName = editedText.getText().toString();

            // If new text is not empty, create JSON with updated info and send PUT request
            if (!newName.isEmpty()) {
                String json = "{\"text\":\"" + newName + "\",\"isDone\":" + isDone + ",\"id\":" + id + "}";

                // Create PUT REST request using the IBM Mobile First SDK and set HTTP headers so Bluemix knows what to expect in the request
                Request request = new Request(client.getBluemixAppRoute() + "/api/Items", Request.PUT);

                HashMap headers = new HashMap();
                List<String> cType = new ArrayList<>();
                cType.add("application/json");
                List<String> accept = new ArrayList<>();
                accept.add("Application/json");

                headers.put("Content-Type", cType);
                headers.put("Accept", accept);

                request.setHeaders(headers);

                request.send(getApplicationContext(), json, new ResponseListener() {
                    // On success, update local list with updated TodoItem
                    @Override
                    public void onSuccess(Response response) {
                        Log.i(TAG, "Item updated successfully");

                        loadList();
                    }

                    // On failure, log errors
                    @Override
                    public void onFailure(Response response, Throwable t, JSONObject extendedInfo) {
                        String errorMessage = "";

                        if (response != null) {
                            errorMessage += response.toString() + "\n";
                        }

                        if (t != null) {
                            StringWriter sw = new StringWriter();
                            PrintWriter pw = new PrintWriter(sw);
                            t.printStackTrace(pw);
                            errorMessage += "THROWN" + sw.toString() + "\n";
                        }

                        if (extendedInfo != null) {
                            errorMessage += "EXTENDED_INFO" + extendedInfo.toString() + "\n";
                        }

                        if (errorMessage.isEmpty())
                            errorMessage = "Request Failed With Unknown Error.";

                        Log.e(TAG, "editTodoName failed with error: " + errorMessage);
                    }
                });

            }
            addDialog.dismiss();
        }
    });
}

From source file:de.bogutzky.psychophysiocollector.app.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_add_bluetooth_device) {
        addBluetoothDevice();// w  w  w  .  j  a v  a2 s  .  c  o  m
        return true;
    }

    if (id == R.id.action_connect) {
        disconnectMenuItem.setEnabled(true);
        connectMenuItem.setEnabled(false);
        addMenuItem.setEnabled(false);
        connectAllShimmerImus();
        connectBioHarness();
    }

    if (id == R.id.action_disconnect) {
        disconnectDevices();
    }

    if (id == R.id.action_settings) {
        showSettings();
    }

    if (id == R.id.action_start_streaming) {
        this.isFirstSelfReportRequest = true;
        startSession();
        //showQuestionnaire(true);
    }

    if (id == R.id.action_stop_streaming) {
        this.isSessionStarted = false;
        this.stopTimestamp = System.currentTimeMillis();
        stopAllStreamingOfAllShimmerImus();
        stopStreamingBioHarness();
        stopStreamingInternalSensorData();

        if (intervalConfigured) {
            stopTimerThread();
        } else {
            feedbackNotification();
            showQuestionnaire();
        }

        this.directoryName = null;
        this.startStreamMenuItem.setEnabled(true);
        this.stopStreamMenuItem.setEnabled(false);
        this.disconnectMenuItem.setEnabled(true);
    }

    if (id == R.id.action_info) {
        Dialog dialog = new Dialog(this);
        dialog.setTitle(getString(R.string.action_info));
        dialog.setContentView(R.layout.info_popup);

        TextView infoSessionStatus = (TextView) dialog.findViewById(R.id.textViewInfoSessionStatus);
        if (isSessionStarted) {
            infoSessionStatus.setText(getString(R.string.info_started));
        }

        if (shimmerImuService != null) {
            int shimmerImuCount = shimmerImuService.shimmerImuMap.values().size();

            TextView infoShimmerImoConnectionStatus = (TextView) dialog
                    .findViewById(R.id.textViewInfoShimmerImoConnectionStatus);
            infoShimmerImoConnectionStatus.setText(getString(R.string.info_number_connected, shimmerImuCount));
        }

        if (bioHarnessService != null) {
            if (bioHarnessService.isBioHarnessConnected()) {
                TextView infoBioHarnessConnectionStatus = (TextView) dialog
                        .findViewById(R.id.textViewInfoBioHarnessConnectionStatus);
                infoBioHarnessConnectionStatus.setText(getString(R.string.info_number_connected, 1));
            }
        }

        infoGpsConnectionStatus = (TextView) dialog.findViewById(R.id.textViewInfoGpsConnectionStatus);
        if (gpsStatusText == null) {
            gpsStatusText = getString(R.string.info_not_connected);
        }
        infoGpsConnectionStatus.setText(gpsStatusText);

        TextView infoVersionName = (TextView) dialog.findViewById(R.id.textViewInfoVersionName);
        try {
            PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
            infoVersionName.setText(packageInfo.versionName);
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "Could not read package info", e);
            infoVersionName.setText(R.string.info_could_not_read);
        }
        dialog.show();
    }
    return super.onOptionsItemSelected(item);
}

From source file:edu.berkeley.boinc.PrefsActivity.java

public void onItemClick(View view) {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Object item = view.getTag();//from ww  w .java2  s.  c  o  m

    if (item instanceof PrefsListItemWrapperValue) {
        final PrefsListItemWrapperValue valueWrapper = (PrefsListItemWrapperValue) item;
        if (Logging.DEBUG)
            Log.d(Logging.TAG, "PrefsActivity onItemClick Value " + valueWrapper.ID);

        if (valueWrapper.isPct) {
            // show dialog with slider
            dialog.setContentView(R.layout.prefs_layout_dialog_pct);
            // setup slider
            TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status);
            sliderProgress.setText(valueWrapper.status.intValue() + " " + getString(R.string.prefs_unit_pct));
            Double seekBarDefault = valueWrapper.status / 10;
            SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar);
            slider.setProgress(seekBarDefault.intValue());
            slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                    String progressString = (progress * 10) + " " + getString(R.string.prefs_unit_pct);
                    TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status);
                    sliderProgress.setText(progressString);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                }
            });
        } else if (valueWrapper.isNumber) {
            if (!getHostInfo()) {
                if (Logging.WARNING)
                    Log.w(Logging.TAG, "onItemClick missing hostInfo");
                return;
            }

            // show dialog with slider
            dialog.setContentView(R.layout.prefs_layout_dialog_pct);
            TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status);
            sliderProgress.setText("" + valueWrapper.status.intValue());
            SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar);

            // slider setup depending on actual preference
            if (valueWrapper.ID == R.string.prefs_cpu_number_cpus_header) {
                slider.setMax(hostinfo.p_ncpus);
                slider.setProgress(valueWrapper.status.intValue());
                slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                        if (progress == 0)
                            progress = 1; // do not allow 0 cpus
                        String progressString = String.valueOf(progress);
                        TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status);
                        sliderProgress.setText(progressString);
                    }

                    @Override
                    public void onStartTrackingTouch(SeekBar seekBar) {
                    }

                    @Override
                    public void onStopTrackingTouch(SeekBar seekBar) {
                    }
                });
            } else if (valueWrapper.ID == R.string.prefs_gui_log_level_header) {
                slider.setMax(5);
                slider.setProgress(valueWrapper.status.intValue());
                slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                        String progressString = String.valueOf(progress);
                        TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status);
                        sliderProgress.setText(progressString);
                    }

                    @Override
                    public void onStartTrackingTouch(SeekBar seekBar) {
                    }

                    @Override
                    public void onStopTrackingTouch(SeekBar seekBar) {
                    }
                });
            }
        } else {
            // show dialog with edit text
            dialog.setContentView(R.layout.prefs_layout_dialog);
        }
        // show preference name
        ((TextView) dialog.findViewById(R.id.pref)).setText(valueWrapper.ID);

        // setup buttons
        Button confirm = (Button) dialog.findViewById(R.id.confirm);
        confirm.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                double value = 0.0;
                Boolean clientPref = true;
                if (valueWrapper.isPct) {
                    SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar);
                    value = slider.getProgress() * 10;
                } else if (valueWrapper.isNumber) {
                    SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar);
                    int sbProgress = slider.getProgress();
                    if (valueWrapper.ID == R.string.prefs_cpu_number_cpus_header) {
                        if (sbProgress == 0)
                            sbProgress = 1;
                        value = numberCpuCoresToPct(sbProgress);
                    } else if (valueWrapper.ID == R.string.prefs_gui_log_level_header) {
                        appPrefs.setLogLevel(sbProgress);
                        updateValuePref(valueWrapper.ID, (double) sbProgress);
                        clientPref = false; // avoid writing client prefs via rpc
                        updateLayout();
                    }
                } else {
                    EditText edit = (EditText) dialog.findViewById(R.id.Input);
                    String input = edit.getText().toString();
                    Double valueTmp = parseInputValueToDouble(input);
                    if (valueTmp == null)
                        return;
                    value = valueTmp;
                }
                if (clientPref)
                    writeClientValuePreference(valueWrapper.ID, value);
                dialog.dismiss();
            }
        });
        Button cancel = (Button) dialog.findViewById(R.id.cancel);
        cancel.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        dialog.show();

    } else {
        // instance of PrefsListItemWrapper, i.e. client log flags
        PrefsListItemWrapper wrapper = (PrefsListItemWrapper) item;
        if (Logging.DEBUG)
            Log.d(Logging.TAG, "PrefsActivity onItemClick super " + wrapper.ID);

        dialog.setContentView(R.layout.prefs_layout_dialog_selection);
        final ArrayList<ClientLogOption> options = new ArrayList<ClientLogOption>();
        String[] array = getResources().getStringArray(R.array.prefs_client_log_flags);
        for (String option : array)
            options.add(new ClientLogOption(option));
        ListView lv = (ListView) dialog.findViewById(R.id.selection);
        new PrefsLogOptionsListAdapter(this, lv, R.id.selection, options);

        // setup buttons
        Button confirm = (Button) dialog.findViewById(R.id.confirm);
        confirm.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ArrayList<String> selectedOptions = new ArrayList<String>();
                for (ClientLogOption option : options)
                    if (option.selected)
                        selectedOptions.add(option.name);
                if (Logging.DEBUG)
                    Log.d(Logging.TAG, selectedOptions.size() + " log flags selected");
                new SetCcConfigAsync().execute(formatOptionsToCcConfig(selectedOptions));
                dialog.dismiss();
            }
        });
        Button cancel = (Button) dialog.findViewById(R.id.cancel);
        cancel.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        dialog.show();
    }
}

From source file:com.corporatetaxi.TaxiArrived_Acitivity.java

private void initiatePopupWindowsendmesage() {
    try {//  w  w w  . ja va  2 s  . c o  m
        dialog = new Dialog(TaxiArrived_Acitivity.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // before
        dialog.setContentView(R.layout.sendmesssage_popup);

        Button mbtn_sendmesssage = (Button) dialog.findViewById(R.id.btn_acceptor);
        Button mbtn_cancel = (Button) dialog.findViewById(R.id.btn_cancel);
        rd1 = (RadioButton) dialog.findViewById(R.id.radioButton1);
        rd2 = (RadioButton) dialog.findViewById(R.id.radioButton2);
        rd3 = (RadioButton) dialog.findViewById(R.id.radioButton3);
        mcross = (ImageButton) dialog.findViewById(R.id.cross);
        txt_header = (TextView) dialog.findViewById(R.id.popup_text);
        mcross.setOnClickListener(cancle_btn_click_listener);
        mbtn_cancel.setOnClickListener(cancle_btn_click_listener);
        Typeface tf = Typeface.createFromAsset(this.getAssets(), "Montserrat-Regular.ttf");
        rd1.setTypeface(tf);
        rd2.setTypeface(tf);
        rd3.setTypeface(tf);
        mbtn_sendmesssage.setTypeface(tf);
        txt_header.setTypeface(tf);
        mbtn_cancel.setTypeface(tf);
        mbtn_sendmesssage.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                if (rd1.isChecked()) {
                    sendmessage = getResources().getString(R.string.prompt_message_one);

                } else if (rd2.isChecked()) {
                    sendmessage = getResources().getString(R.string.prompt_message_two);

                } else if (rd3.isChecked()) {
                    sendmessage = getResources().getString(R.string.prompt_message_three);

                }

                Allbeans allbeans = new Allbeans();

                allbeans.setSendmessage(sendmessage);

                new SendmessageAsynch(allbeans).execute();

            }
        });
        dialog.show();

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

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (DEBUG_ENABLE)
        Log.v(APPLICATION_TAG, "onCreateDialog");

    //       mContext=getActivity().getApplicationContext();
    mDialog = new Dialog(getActivity());
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    if (!mTerminateRequired) {
        initViewWidget();/*from w w w . java2  s.c  o m*/
    }
    return mDialog;
}

From source file:com.smsc.usuario.ui.MapaActivity.java

public void getDetalle(int posicion) {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(false);/*  w  ww .  j a v  a  2s.  co  m*/
    dialog.setContentView(R.layout.dialog_incidente);

    TextView lblAsunto = (TextView) dialog.findViewById(R.id.lblAsunto);
    lblAsunto.setText(lista.get(posicion).getStr_detalle());

    TextView lblNombreInciente = (TextView) dialog.findViewById(R.id.lblNombreInciente);
    lblNombreInciente.setText(lista.get(posicion).getStr_tipo_incidente_nombre());

    TextView lblEstado = (TextView) dialog.findViewById(R.id.lblEstado);
    lblEstado.setText("Enviado");
    if (lista.get(posicion).getInt_estado() == 1)
        lblEstado.setText("En Progreso");
    else if (lista.get(posicion).getInt_estado() == 2)
        lblEstado.setText("Valido");
    else if (lista.get(posicion).getInt_estado() == 3)
        lblEstado.setText("Invalido");
    SimpleDateFormat fecha = new SimpleDateFormat("dd/MM/yyyy");
    SimpleDateFormat hora = new SimpleDateFormat("h:mm a");

    TextView lblFecha = (TextView) dialog.findViewById(R.id.lblFecha);
    lblFecha.setText(fecha.format(lista.get(posicion).getDat_fecha_registro()));

    TextView lblHora = (TextView) dialog.findViewById(R.id.lblHora);
    lblHora.setText(hora.format(lista.get(posicion).getDat_fecha_registro()));

    View ViewFoto = (View) dialog.findViewById(R.id.ViewFoto);
    if (lista.get(posicion).getByte_foto() == null) {
        ViewFoto.setVisibility(View.GONE);
    } else {
        ImageView image = (ImageView) dialog.findViewById(R.id.image);
        image.setImageBitmap(Funciones.getBitmap(lista.get(posicion).getByte_foto()));
    }

    View ViewCalificacion = (View) dialog.findViewById(R.id.ViewCalificacion);
    if (lista.get(posicion).getInt_rapides() == 0 && lista.get(posicion).getInt_conformidad() == 0) {
        ViewCalificacion.setVisibility(View.GONE);
    } else {
        RatingBar ratingRapides = (RatingBar) dialog.findViewById(R.id.ratingRapides);
        ratingRapides.setRating(lista.get(posicion).getInt_rapides());

        RatingBar ratingConformidad = (RatingBar) dialog.findViewById(R.id.ratingConformidad);
        ratingConformidad.setRating(lista.get(posicion).getInt_conformidad());
    }

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

}

From source file:com.vuze.android.remote.AppPreferences.java

public void showRateDialog(final Activity mContext) {

    if (!shouldShowRatingReminder()) {
        return;/*from w ww  .j  a  v a  2  s .c o  m*/
    }

    // skip showing if they are adding a torrent (or anything else)
    Intent intent = mContext.getIntent();
    if (intent != null) {
        Uri data = intent.getData();
        if (data != null) {
            return;
        }
    }

    // even if something goes wrong, we want to set that we asked, so
    // it doesn't continue to pop up
    setAskedRating();

    Dialog dialog = new Dialog(mContext);

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setMessage(R.string.ask_rating_message).setCancelable(false)
            .setPositiveButton(R.string.rate_now, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    final String appPackageName = mContext.getPackageName();
                    try {
                        mContext.startActivity(new Intent(Intent.ACTION_VIEW,
                                Uri.parse("market://details?id=" + appPackageName)));
                    } catch (android.content.ActivityNotFoundException anfe) {
                        mContext.startActivity(new Intent(Intent.ACTION_VIEW,
                                Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
                    }
                    VuzeEasyTracker.getInstance(mContext).sendEvent("uiAction", "Rating", "AskStoreClick",
                            null);
                }
            }).setNeutralButton(R.string.later, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).setNegativeButton(R.string.no_thanks, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    setNeverAskRatingAgain();
                }
            });
    dialog = builder.create();

    VuzeEasyTracker.getInstance(mContext).sendEvent("uiAction", "Rating", "AskShown", null);
    dialog.show();
}

From source file:com.corporatetaxi.TaxiOntheWay_Activity.java

private void initiatePopupWindowcanceltaxi() {
    try {//from   w w  w .ja  va  2s .co  m
        dialog = new Dialog(TaxiOntheWay_Activity.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // before
        dialog.setContentView(R.layout.canceltaxi_popup);

        cross = (ImageButton) dialog.findViewById(R.id.cross);
        cross.setOnClickListener(cancle_btn_click_listener);
        rd1 = (RadioButton) dialog.findViewById(R.id.radioButton);
        rd2 = (RadioButton) dialog.findViewById(R.id.radioButton2);
        rd3 = (RadioButton) dialog.findViewById(R.id.radioButton3);
        btn_confirm = (Button) dialog.findViewById(R.id.btn_acceptor);
        TextView txt = (TextView) dialog.findViewById(R.id.textView);
        textheader = (TextView) dialog.findViewById(R.id.popup_text);
        Typeface tf = Typeface.createFromAsset(this.getAssets(), "Montserrat-Regular.ttf");
        rd1.setTypeface(tf);
        rd2.setTypeface(tf);
        rd3.setTypeface(tf);
        btn_confirm.setTypeface(tf);
        txt.setTypeface(tf);
        textheader.setTypeface(tf);
        btn_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (rd1.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_one);

                } else if (rd2.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_two);

                } else if (rd3.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_three);

                }

                Allbeans allbeans = new Allbeans();

                allbeans.setCanceltaxirequest(canceltaxirequest);

                new CancelTaxiAsynch(allbeans).execute();

            }
        });

        dialog.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.usertaxi.TaxiArrived_Acitivity.java

private void initiatePopupWindowcanceltaxi() {
    try {/*from  w w w .j  a  va 2 s .c  om*/
        dialog = new Dialog(TaxiArrived_Acitivity.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // before
        dialog.setContentView(R.layout.canceltaxi_popup);

        cross = (ImageButton) dialog.findViewById(R.id.cross);
        cross.setOnClickListener(cancle_btn_click_listener);
        rd1 = (RadioButton) dialog.findViewById(R.id.radioButton);
        rd2 = (RadioButton) dialog.findViewById(R.id.radioButton2);
        rd3 = (RadioButton) dialog.findViewById(R.id.radioButton3);
        btn_confirm = (Button) dialog.findViewById(R.id.btn_acceptor);
        TextView txt = (TextView) dialog.findViewById(R.id.textView);
        textheader = (TextView) dialog.findViewById(R.id.popup_text);

        Typeface tf = Typeface.createFromAsset(this.getAssets(), "Montserrat-Regular.ttf");
        rd1.setTypeface(tf);
        rd2.setTypeface(tf);
        rd3.setTypeface(tf);
        btn_confirm.setTypeface(tf);
        txt.setTypeface(tf);
        textheader.setTypeface(tf);
        btn_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (rd1.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_canceltaxione);

                } else if (rd2.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_two);

                } else if (rd3.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_three);

                }

                Allbeans allbeans = new Allbeans();

                allbeans.setCanceltaxirequest(canceltaxirequest);

                new CancelTaxiAsynch(allbeans).execute();

            }
        });
        dialog.show();

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