Example usage for android.app AlertDialog.Builder setView

List of usage examples for android.app AlertDialog.Builder setView

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setView.

Prototype

public void setView(View view) 

Source Link

Document

Set the view to display in that dialog.

Usage

From source file:com.andrewshu.android.reddit.profile.ProfileActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog;//from   w ww . j  a v  a  2s.  c  om
    ProgressDialog pdialog;
    AlertDialog.Builder builder;
    LayoutInflater inflater;
    View layout; // used for inflated views for AlertDialog.Builder.setView()

    switch (id) {
    case Constants.DIALOG_LOGIN:
        dialog = new LoginDialog(this, mSettings, false) {
            @Override
            public void onLoginChosen(String user, String password) {
                dismissDialog(Constants.DIALOG_LOGIN);
                new MyLoginTask(user, password).execute();
            }
        };
        break;

    case Constants.DIALOG_COMPOSE:
        inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        builder = new AlertDialog.Builder(this);
        layout = inflater.inflate(R.layout.compose_dialog, null);
        final EditText composeDestination = (EditText) layout.findViewById(R.id.compose_destination_input);
        final EditText composeSubject = (EditText) layout.findViewById(R.id.compose_subject_input);
        final EditText composeText = (EditText) layout.findViewById(R.id.compose_text_input);
        final Button composeSendButton = (Button) layout.findViewById(R.id.compose_send_button);
        final Button composeCancelButton = (Button) layout.findViewById(R.id.compose_cancel_button);
        final EditText composeCaptcha = (EditText) layout.findViewById(R.id.compose_captcha_input);
        composeDestination.setText(mUsername);

        dialog = builder.setView(layout).create();
        final Dialog composeDialog = dialog;
        composeSendButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                ThingInfo hi = new ThingInfo();
                // reddit.com performs these sanity checks too.
                if ("".equals(composeDestination.getText().toString().trim())) {
                    Toast.makeText(ProfileActivity.this, "please enter a username", Toast.LENGTH_LONG).show();
                    return;
                }
                if ("".equals(composeSubject.getText().toString().trim())) {
                    Toast.makeText(ProfileActivity.this, "please enter a subject", Toast.LENGTH_LONG).show();
                    return;
                }
                if ("".equals(composeText.getText().toString().trim())) {
                    Toast.makeText(ProfileActivity.this, "you need to enter a message", Toast.LENGTH_LONG)
                            .show();
                    return;
                }
                if (composeCaptcha.getVisibility() == View.VISIBLE
                        && "".equals(composeCaptcha.getText().toString().trim())) {
                    Toast.makeText(ProfileActivity.this, "", Toast.LENGTH_LONG).show();
                    return;
                }
                hi.setDest(composeDestination.getText().toString().trim());
                hi.setSubject(composeSubject.getText().toString().trim());
                new MyMessageComposeTask(composeDialog, hi, composeCaptcha.getText().toString().trim())
                        .execute(composeText.getText().toString().trim());
                dismissDialog(Constants.DIALOG_COMPOSE);
            }
        });
        composeCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dismissDialog(Constants.DIALOG_COMPOSE);
            }
        });
        break;

    case Constants.DIALOG_THREAD_CLICK:
        inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        builder = new AlertDialog.Builder(this);
        dialog = builder.setView(inflater.inflate(R.layout.thread_click_dialog, null)).create();
        break;

    // "Please wait"
    case Constants.DIALOG_LOGGING_IN:
        pdialog = new ProgressDialog(this);
        pdialog.setMessage("Logging in...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(false);
        dialog = pdialog;
        break;
    case Constants.DIALOG_REPLYING:
        pdialog = new ProgressDialog(this);
        pdialog.setMessage("Sending reply...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(false);
        dialog = pdialog;
        break;
    case Constants.DIALOG_COMPOSING:
        pdialog = new ProgressDialog(this);
        pdialog.setMessage("Composing message...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(false);
        dialog = pdialog;
        break;

    default:
        throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}

From source file:biz.bokhorst.xprivacy.ActivityMain.java

@SuppressLint("InflateParams")
private void optionTemplate() {
    final int userId = Util.getUserId(Process.myUid());

    // Build view
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.template, null);
    final Spinner spTemplate = (Spinner) view.findViewById(R.id.spTemplate);
    Button btnRename = (Button) view.findViewById(R.id.btnRename);
    ExpandableListView elvTemplate = (ExpandableListView) view.findViewById(R.id.elvTemplate);

    // Template selector
    final SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item);
    spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    String defaultName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, "0",
            getString(R.string.title_default));
    spAdapter.add(defaultName);/*from   w w w  . j  a  v a 2s  .  co m*/
    for (int i = 1; i <= 4; i++) {
        String alternateName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, Integer.toString(i),
                getString(R.string.title_alternate) + " " + i);
        spAdapter.add(alternateName);
    }
    spTemplate.setAdapter(spAdapter);

    // Template definition
    final TemplateListAdapter templateAdapter = new TemplateListAdapter(this, view, R.layout.templateentry);
    elvTemplate.setAdapter(templateAdapter);
    elvTemplate.setGroupIndicator(null);

    spTemplate.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            templateAdapter.notifyDataSetChanged();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            templateAdapter.notifyDataSetChanged();
        }
    });

    btnRename.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (Util.hasProLicense(ActivityMain.this) == null) {
                // Redirect to pro page
                Util.viewUri(ActivityMain.this, cProUri);
                return;
            }

            final int templateId = spTemplate.getSelectedItemPosition();
            if (templateId == AdapterView.INVALID_POSITION)
                return;

            AlertDialog.Builder dlgRename = new AlertDialog.Builder(spTemplate.getContext());
            dlgRename.setTitle(R.string.title_rename);

            final String original = (templateId == 0 ? getString(R.string.title_default)
                    : getString(R.string.title_alternate) + " " + templateId);
            dlgRename.setMessage(original);

            final EditText input = new EditText(spTemplate.getContext());
            dlgRename.setView(input);

            dlgRename.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String name = input.getText().toString();
                    if (TextUtils.isEmpty(name)) {
                        PrivacyManager.setSetting(userId, Meta.cTypeTemplateName, Integer.toString(templateId),
                                null);
                        name = original;
                    } else {
                        PrivacyManager.setSetting(userId, Meta.cTypeTemplateName, Integer.toString(templateId),
                                name);
                    }
                    spAdapter.remove(spAdapter.getItem(templateId));
                    spAdapter.insert(name, templateId);
                    spAdapter.notifyDataSetChanged();
                }
            });

            dlgRename.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    // Do nothing
                }
            });

            dlgRename.create().show();
        }
    });

    // Build dialog
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setTitle(R.string.menu_template);
    alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
    alertDialogBuilder.setView(view);
    alertDialogBuilder.setPositiveButton(getString(R.string.msg_done), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Do nothing
        }
    });

    // Show dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}

From source file:com.gelakinetic.mtgfam.activities.MainActivity.java

public void showDialogFragment(final int id) {
    // DialogFragment.show() will take care of adding the fragment
    // in a transaction. We also want to remove any currently showing
    // dialog, so make our own transaction and take care of that here.
    this.showContent();
    FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction();
    Fragment prev = getSupportFragmentManager().findFragmentByTag(FamiliarFragment.DIALOG_TAG);
    if (prev != null) {
        ft.remove(prev);/*www  .  j  a  v  a2 s  . c  o m*/
    }

    // Create and show the dialog.
    FamiliarDialogFragment newFragment = new FamiliarDialogFragment() {

        @Override
        public void onDismiss(DialogInterface mDialog) {
            super.onDismiss(mDialog);
            if (bounceMenu) {
                getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
                bounceMenu = false;
                Runnable r = new Runnable() {

                    @Override
                    public void run() {
                        long timeStarted = System.currentTimeMillis();
                        Message msg = Message.obtain();
                        msg.arg1 = OPEN;
                        bounceHandler.sendMessage(msg);
                        while (System.currentTimeMillis() < (timeStarted + 1500)) {
                            ;
                        }
                        msg = Message.obtain();
                        msg.arg1 = CLOSE;
                        bounceHandler.sendMessage(msg);
                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
                            }
                        });
                    }
                };

                Thread t = new Thread(r);
                t.start();
            }
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            switch (id) {
            case DONATEDIALOG: {
                AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());
                builder.setTitle(R.string.main_donate_dialog_title);
                builder.setNeutralButton(R.string.dialog_thanks_anyway, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });

                LayoutInflater inflater = this.getActivity().getLayoutInflater();
                View dialoglayout = inflater.inflate(R.layout.about_dialog,
                        (ViewGroup) findViewById(R.id.dialog_layout_root));

                TextView text = (TextView) dialoglayout.findViewById(R.id.aboutfield);
                text.setText(ImageGetterHelper.jellyBeanHack(getString(R.string.main_donate_text)));
                text.setMovementMethod(LinkMovementMethod.getInstance());

                text.setTextSize(15);

                ImageView paypal = (ImageView) dialoglayout.findViewById(R.id.imageview1);
                paypal.setImageResource(R.drawable.paypal);
                paypal.setOnClickListener(new View.OnClickListener() {

                    public void onClick(View v) {
                        Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
                                "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=SZK4TAH2XBZNC&lc=US&item_name=MTG%20Familiar&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted"));

                        startActivity(myIntent);
                    }
                });
                ((ImageView) dialoglayout.findViewById(R.id.imageview2)).setVisibility(View.GONE);

                builder.setView(dialoglayout);
                return builder.create();
            }
            case ABOUTDIALOG: {
                AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());

                // You have to catch the exception because the package stuff is all
                // run-time
                if (pInfo != null) {
                    builder.setTitle(getString(R.string.main_about) + " " + getString(R.string.app_name) + " "
                            + pInfo.versionName);
                } else {
                    builder.setTitle(getString(R.string.main_about) + " " + getString(R.string.app_name));
                }

                builder.setNeutralButton(R.string.dialog_thanks, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });

                LayoutInflater inflater = this.getActivity().getLayoutInflater();
                View dialoglayout = inflater.inflate(R.layout.about_dialog,
                        (ViewGroup) findViewById(R.id.dialog_layout_root));

                TextView text = (TextView) dialoglayout.findViewById(R.id.aboutfield);
                text.setText(ImageGetterHelper.jellyBeanHack(getString(R.string.main_about_text)));
                text.setMovementMethod(LinkMovementMethod.getInstance());

                builder.setView(dialoglayout);
                return builder.create();
            }
            case CHANGELOGDIALOG: {
                AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());

                if (pInfo != null) {
                    builder.setTitle(getString(R.string.main_whats_new_in_title) + " " + pInfo.versionName);
                } else {
                    builder.setTitle(R.string.main_whats_new_title);
                }

                builder.setNeutralButton(R.string.dialog_enjoy, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });

                builder.setMessage(ImageGetterHelper.jellyBeanHack(getString(R.string.main_whats_new_text)));
                return builder.create();
            }
            default: {
                savedInstanceState.putInt("id", id);
                return super.onCreateDialog(savedInstanceState);
            }
            }
        }
    };
    newFragment.show(ft, FamiliarFragment.DIALOG_TAG);
}

From source file:com.sixwonders.courtkiosk.CheckInActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    activity = this;
    view = LayoutInflater.from(this).inflate(R.layout.activity_check_in, null);
    btnInfoSubmit = (Button) view.findViewById(R.id.btnInfoSubmit);

    btnIdScan = (Button) view.findViewById(R.id.btnLicenseScan);

    btnIdScan.setOnClickListener(new View.OnClickListener() {
        @Override//  w  w  w .  j ava2 s  .c  om
        public void onClick(View view) {
            callToScan();
        }
    });

    btnInfoSubmit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
            builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                }
            });
            final View custom = LayoutInflater.from(activity)
                    .inflate(R.layout.check_in_personal_info_alertdialog, null);
            builder.setTitle(R.string.userInformationInput).setPositiveButton(R.string.continueText,
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int id) {

                            //TODO call webservice to check for user
                            EditText firstName = (EditText) custom.findViewById(R.id.etFirstName);
                            EditText lastName = (EditText) custom.findViewById(R.id.etLastName);
                            DatePicker dob = (DatePicker) custom.findViewById(R.id.dpDob);

                            if (dob == null) {
                                int i = 0;
                                i++;
                                i++;
                            }
                            int monthInt = dob.getMonth() + 1;
                            String month = "";
                            if (monthInt < 10) {
                                month += "0";
                            }
                            month += monthInt;

                            int dayInt = dob.getDayOfMonth();
                            String day = "";
                            if (dayInt < 10) {
                                day += "0";
                            }
                            day += dayInt;

                            int yearInt = dob.getYear();
                            String year = "";
                            if (yearInt < 10) {
                                year += "0";
                            }
                            year += yearInt;
                            String dobStr = month + "/" + day + "/" + year;

                            ConnectionUtil connectionUtil = new ConnectionUtil();
                            connectionUtil.authCall(firstName.getText().toString(),
                                    lastName.getText().toString(), dobStr, (AsyncResponse) activity);
                        }
                    });

            builder.setView(custom);

            datePicker = (DatePicker) custom.findViewById(R.id.dpDob);
            setUpDatePicker();
            AlertDialog alert = builder.create();
            alert.show();
        }
    });

    setContentView(view);
}

From source file:dentex.youtube.downloader.DashboardActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);

    String previousJson = Json.readJsonDashboardFile(sDashboard);
    boolean smtInProgressOrPaused = (previousJson.contains(YTD.JSON_DATA_STATUS_IN_PROGRESS)
            || previousJson.contains(YTD.JSON_DATA_STATUS_PAUSED));

    switch (item.getItemId()) {
    case R.id.menu_search:
        BugSenseHandler.leaveBreadcrumb("ShareActivity_menu_search");
        if (!isSearchBarVisible) {
            spawnSearchBar();// www  .j a  v  a  2s.co  m
        } else {
            hideSearchBar();
        }
        return true;
    case R.id.menu_backup:
        BugSenseHandler.leaveBreadcrumb("ShareActivity_menu_backup");
        if (YTD.JSON_FILE.exists() && !previousJson.equals("{}\n") && !smtInProgressOrPaused) {
            boolean backupCheckboxEnabled = YTD.settings.getBoolean("dashboard_backup_info", true);
            if (backupCheckboxEnabled == true) {

                AlertDialog.Builder adb = new AlertDialog.Builder(boxThemeContextWrapper);

                LayoutInflater adbInflater = LayoutInflater.from(DashboardActivity.this);
                View showAgainView = adbInflater.inflate(R.layout.dialog_show_again_checkbox, null);
                final CheckBox showAgain = (CheckBox) showAgainView.findViewById(R.id.showAgain2);
                showAgain.setChecked(true);
                adb.setView(showAgainView);

                adb.setTitle(getString(R.string.information));
                adb.setMessage(getString(R.string.menu_backup_info));
                adb.setIcon(android.R.drawable.ic_dialog_info);

                adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        if (!showAgain.isChecked()) {
                            YTD.settings.edit().putBoolean("dashboard_backup_info", false).apply();
                            Utils.logger("d", "dashboard backup info checkbox disabled", DEBUG_TAG);
                        }
                        launchFcForBackup();
                    }
                });

                adb.setNegativeButton(R.string.dialogs_negative, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        // cancel
                    }
                });

                secureShowDialog(adb);
            } else {
                launchFcForBackup();
            }
        } else {
            toastOpsNotExecuted();
        }
        return true;
    case R.id.menu_restore:
        BugSenseHandler.leaveBreadcrumb("ShareActivity_menu_restore");
        if (!smtInProgressOrPaused) {
            boolean restoreCheckboxEnabled = YTD.settings.getBoolean("dashboard_restore_info", true);
            if (restoreCheckboxEnabled == true) {

                AlertDialog.Builder adb = new AlertDialog.Builder(boxThemeContextWrapper);

                LayoutInflater adbInflater = LayoutInflater.from(DashboardActivity.this);
                View showAgainView = adbInflater.inflate(R.layout.dialog_show_again_checkbox, null);
                final CheckBox showAgain = (CheckBox) showAgainView.findViewById(R.id.showAgain2);
                showAgain.setChecked(true);
                adb.setView(showAgainView);

                adb.setTitle(getString(R.string.information));
                adb.setMessage(getString(R.string.menu_restore_info) + ".\n"
                        + getString(R.string.menu_restore_info_msg));
                adb.setIcon(android.R.drawable.ic_dialog_info);

                adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        if (!showAgain.isChecked()) {
                            YTD.settings.edit().putBoolean("dashboard_restore_info", false).apply();
                            Utils.logger("d", "dashboard restore info checkbox disabled", DEBUG_TAG);
                        }
                        launchFcForRestore();
                    }
                });

                adb.setNegativeButton(R.string.dialogs_negative, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        // cancel
                    }
                });

                secureShowDialog(adb);
            } else {
                launchFcForRestore();
            }
        } else {
            toastOpsNotExecuted();
        }
        return true;
    case R.id.menu_import:
        BugSenseHandler.leaveBreadcrumb("ShareActivity_menu_import");
        boolean importCheckboxEnabled1 = YTD.settings.getBoolean("dashboard_import_info", true);
        if (importCheckboxEnabled1 == true) {

            AlertDialog.Builder adb = new AlertDialog.Builder(boxThemeContextWrapper);

            LayoutInflater adbInflater = LayoutInflater.from(DashboardActivity.this);
            View showAgainView = adbInflater.inflate(R.layout.dialog_show_again_checkbox, null);
            final CheckBox showAgain = (CheckBox) showAgainView.findViewById(R.id.showAgain2);
            showAgain.setChecked(true);
            adb.setView(showAgainView);

            adb.setTitle(getString(R.string.information));
            adb.setMessage(getString(R.string.menu_import_info));
            adb.setIcon(android.R.drawable.ic_dialog_info);

            adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    if (!showAgain.isChecked()) {
                        YTD.settings.edit().putBoolean("dashboard_import_info", false).apply();
                        Utils.logger("d", "dashboard import info checkbox disabled", DEBUG_TAG);
                    }
                    launchFcForImport();
                }
            });

            adb.setNegativeButton(R.string.dialogs_negative, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // cancel
                }
            });

            secureShowDialog(adb);
        } else {
            launchFcForImport();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.eveningoutpost.dexdrip.Home.java

public void showNoteTextInputDialog(View myitem, final long timestamp, final double position) {
    Log.d(TAG, "showNoteTextInputDialog: ts:" + timestamp + " pos:" + position);
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    LayoutInflater inflater = this.getLayoutInflater();
    final View dialogView = inflater.inflate(R.layout.note_dialog_phone, null);
    dialogBuilder.setView(dialogView);

    final EditText edt = (EditText) dialogView.findViewById(R.id.treatment_note_edit_text);
    final CheckBox cbx = (CheckBox) dialogView.findViewById(R.id.default_to_voice_input);
    cbx.setChecked(getPreferencesBooleanDefaultFalse("default_to_voice_notes"));

    dialogBuilder.setTitle(R.string.treatment_note);
    //dialogBuilder.setMessage("Enter text below");
    dialogBuilder.setPositiveButton("Done", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String treatment_text = edt.getText().toString().trim();
            Log.d(TAG, "Got treatment note: " + treatment_text);
            Treatments.create_note(treatment_text, timestamp, position); // timestamp?
            Home.staticRefreshBGCharts();

            if (treatment_text.length() > 0) {
                // display snackbar of the snackbar
                final View.OnClickListener mOnClickListener = new View.OnClickListener() {
                    @Override/* w  ww .j  a va  2  s  .c o m*/
                    public void onClick(View v) {
                        Home.startHomeWithExtra(xdrip.getAppContext(), Home.CREATE_TREATMENT_NOTE,
                                Long.toString(timestamp), Double.toString(position));
                    }
                };
                Home.snackBar(getString(R.string.added) + ":    " + treatment_text, mOnClickListener,
                        mActivity);
            }

            if (getPreferencesBooleanDefaultFalse("default_to_voice_notes"))
                showcasemenu(SHOWCASE_NOTE_LONG);
            dialog = null;
        }
    });
    dialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            if (getPreferencesBooleanDefaultFalse("default_to_voice_notes"))
                showcasemenu(SHOWCASE_NOTE_LONG);
            dialog = null;

        }
    });
    dialog = dialogBuilder.create();
    edt.setInputType(InputType.TYPE_CLASS_TEXT);
    edt.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                if (dialog != null)
                    dialog.getWindow()
                            .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }
        }
    });

    dialog.show();

}

From source file:com.aniruddhc.acemusic.player.Dialogs.ABRepeatDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    mContext = getActivity().getApplicationContext();
    mApp = (Common) mContext;//w  ww .  j a  v  a2s . c o  m

    receiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            initRepeatSongRangeDialog();

        }

    };

    sharedPreferences = getActivity().getSharedPreferences("com.aniruddhc.acemusic.player",
            Context.MODE_PRIVATE);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_repeat_song_range_dialog, null);
    currentSongIndex = mApp.getService().getCurrentSongIndex();

    repeatSongATime = (TextView) view.findViewById(R.id.repeat_song_range_A_time);
    repeatSongBTime = (TextView) view.findViewById(R.id.repeat_song_range_B_time);

    currentSongDurationMillis = (int) mApp.getService().getCurrentMediaPlayer().getDuration();
    currentSongDurationSecs = (int) currentSongDurationMillis / 1000;

    //Remove the placeholder seekBar and replace it with the RangeSeekBar.
    seekBar = (SeekBar) view.findViewById(R.id.repeat_song_range_placeholder_seekbar);
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) seekBar.getLayoutParams();
    viewGroup = (ViewGroup) seekBar.getParent();
    viewGroup.removeView(seekBar);

    rangeSeekBar = new RangeSeekBar<Integer>(0, currentSongDurationSecs, getActivity());
    rangeSeekBar.setLayoutParams(params);
    viewGroup.addView(rangeSeekBar);

    if (sharedPreferences.getInt(Common.REPEAT_MODE, Common.REPEAT_OFF) == Common.A_B_REPEAT) {
        repeatSongATime.setText(convertMillisToMinsSecs(mApp.getService().getRepeatSongRangePointA()));
        repeatSongBTime.setText(convertMillisToMinsSecs(mApp.getService().getRepeatSongRangePointB()));

        rangeSeekBar.setSelectedMinValue(mApp.getService().getRepeatSongRangePointA());
        rangeSeekBar.setSelectedMaxValue(mApp.getService().getRepeatSongRangePointB());

        repeatPointA = mApp.getService().getRepeatSongRangePointA();
        repeatPointB = mApp.getService().getRepeatSongRangePointB();
    } else {
        repeatSongATime.setText("0:00");
        repeatSongBTime.setText(convertMillisToMinsSecs(currentSongDurationMillis));
        repeatPointA = 0;
        repeatPointB = currentSongDurationMillis;
    }

    rangeSeekBar.setOnRangeSeekBarChangeListener(new OnRangeSeekBarChangeListener<Integer>() {
        @Override
        public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer minValue, Integer maxValue) {
            repeatPointA = minValue * 1000;
            repeatPointB = maxValue * 1000;
            repeatSongATime.setText(convertMillisToMinsSecs(minValue * 1000));
            repeatSongBTime.setText(convertMillisToMinsSecs(maxValue * 1000));
        }

    });

    //Set the dialog title.
    builder.setTitle(R.string.a_b_repeat);
    builder.setView(view);
    builder.setNegativeButton(R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            // TODO Auto-generated method stub

        }

    });

    builder.setPositiveButton(R.string.repeat, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if ((currentSongDurationSecs - repeatPointB) < mApp.getCrossfadeDuration()) {
                //Remove the crossfade handler.
                mApp.getService().getHandler().removeCallbacks(mApp.getService().startCrossFadeRunnable);
                mApp.getService().getHandler().removeCallbacks(mApp.getService().crossFadeRunnable);
            }

            mApp.broadcastUpdateUICommand(new String[] { Common.UPDATE_PLAYBACK_CONTROLS },
                    new String[] { "" });
            mApp.getService().setRepeatSongRange(repeatPointA, repeatPointB);
            mApp.getService().setRepeatMode(Common.A_B_REPEAT);

        }

    });

    return builder.create();
}

From source file:com.eveningoutpost.dexdrip.Home.java

private void promptTextInput_old() {

    if (recognitionRunning)
        return;/*  w  w  w  .  j  a  va 2 s .  c  o  m*/
    recognitionRunning = true;

    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Type treatment\neg: units x.x");
    // Set up the input
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    builder.setView(input);
    // Set up the buttons
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            voiceRecognitionText.setText(input.getText().toString());
            voiceRecognitionText.setVisibility(View.VISIBLE);
            last_speech_time = JoH.ts();
            naturalLanguageRecognition(input.getText().toString());

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

    final AlertDialog dialog = builder.create();
    input.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                if (dialog != null)
                    dialog.getWindow()
                            .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }
        }
    });
    dialog.show();
    recognitionRunning = false;
}

From source file:com.irccloud.android.activity.UploadsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (ColorFormatter.file_uri_template != null)
        template = UriTemplate.fromTemplate(ColorFormatter.file_uri_template);
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 21) {
        Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
        setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name),
                cloud, 0xFFF2F7FC));/*from ww w . java 2  s.  c  o  m*/
        cloud.recycle();
    }

    if (Build.VERSION.SDK_INT >= 14) {
        try {
            java.io.File httpCacheDir = new java.io.File(getCacheDir(), "http");
            long httpCacheSize = 10 * 1024 * 1024; // 10 MiB
            HttpResponseCache.install(httpCacheDir, httpCacheSize);
        } catch (IOException e) {
            Log.i("IRCCloud", "HTTP response cache installation failed:" + e);
        }
    }
    setContentView(R.layout.ignorelist);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
        getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar));
        getSupportActionBar().setElevation(0);
    }

    if (savedInstanceState != null && savedInstanceState.containsKey("cid")) {
        cid = savedInstanceState.getInt("cid");
        to = savedInstanceState.getString("to");
        msg = savedInstanceState.getString("msg");
        page = savedInstanceState.getInt("page");
        File[] files = (File[]) savedInstanceState.getSerializable("adapter");
        for (File f : files) {
            adapter.addFile(f);
        }
        adapter.notifyDataSetChanged();
    }

    footer = getLayoutInflater().inflate(R.layout.messageview_header, null);
    ListView listView = (ListView) findViewById(android.R.id.list);
    listView.setAdapter(adapter);
    listView.addFooterView(footer);
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {

        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (canLoadMore && firstVisibleItem + visibleItemCount > totalItemCount - 4) {
                canLoadMore = false;
                new FetchFilesTask().execute((Void) null);
            }
        }
    });
    listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            final File f = (File) adapter.getItem(i);

            AlertDialog.Builder builder = new AlertDialog.Builder(UploadsActivity.this);
            builder.setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB);
            final View v = getLayoutInflater().inflate(R.layout.dialog_upload, null);
            final EditText messageinput = (EditText) v.findViewById(R.id.message);
            messageinput.setText(msg);
            final ImageView thumbnail = (ImageView) v.findViewById(R.id.thumbnail);

            v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    if (messageinput.hasFocus()) {
                        v.post(new Runnable() {
                            @Override
                            public void run() {
                                v.scrollTo(0, v.getBottom());
                            }
                        });
                    }
                }
            });

            if (f.mime_type.startsWith("image/")) {
                try {
                    thumbnail.setImageBitmap(f.image);
                    thumbnail.setVisibility(View.VISIBLE);
                    thumbnail.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            Intent i = new Intent(UploadsActivity.this, ImageViewerActivity.class);
                            i.setData(Uri.parse(f.url));
                            startActivity(i);
                        }
                    });
                    thumbnail.setClickable(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                thumbnail.setVisibility(View.GONE);
            }

            ((TextView) v.findViewById(R.id.filesize)).setText(f.metadata);
            v.findViewById(R.id.filename).setVisibility(View.GONE);
            v.findViewById(R.id.filename_heading).setVisibility(View.GONE);

            builder.setTitle("Send A File To " + to);
            builder.setView(v);
            builder.setPositiveButton("Send", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String message = messageinput.getText().toString();
                    if (message.length() > 0)
                        message += " ";
                    message += f.url;

                    dialog.dismiss();
                    if (getParent() == null) {
                        setResult(Activity.RESULT_OK);
                    } else {
                        getParent().setResult(Activity.RESULT_OK);
                    }
                    finish();

                    NetworkConnection.getInstance().say(cid, to, message);
                }
            });
            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            AlertDialog d = builder.create();
            d.setOwnerActivity(UploadsActivity.this);
            d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
            d.show();
        }
    });
}

From source file:com.google.cast.samples.games.gamedebugger.PlayerTransitionDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();

    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.player_transition_dialog, null);
    mTransitionPlayerStateSection = (LinearLayout) view.findViewById(R.id.transition_player_state_section);
    mPlayerStateGroup = (RadioGroup) view.findViewById(R.id.radio_player_states);
    mExtraMessageDataLabel = (TextView) view.findViewById(R.id.extra_message_data_label);
    mExtraMessageDataEditText = (EditText) view.findViewById(R.id.extra_message_data);
    mCancelButton = (Button) view.findViewById(R.id.button_cancel);
    mOkButton = (Button) view.findViewById(R.id.button_ok);

    // Find the valid player states.
    GameManagerClient client = GameDebuggerApplication.getInstance().getCastConnectionManager()
            .getGameManagerClient();/*w ww .  j a v  a  2s .co m*/
    GameManagerState state = client.getCurrentState();
    PlayerInfo player = state.getPlayer(getArguments().getString(KEY_PLAYER_ID));
    if (player == null) {
        return null;
    }
    if (player.isConnected()) {
        boolean defaultSelectionSet = false;
        for (int i = 0; i < PLAYER_STATES.length; i++) {
            if (PLAYER_STATES[i] != player.getPlayerState()) {
                RadioButton radioButton = new RadioButton(getActivity());
                radioButton.setText(getText(PLAYER_STATE_RESOURCE_IDS[i]));
                radioButton.setId(PLAYER_STATES[i]);
                radioButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.WRAP_CONTENT));
                mPlayerStateGroup.addView(radioButton);

                // Select the first element.
                if (!defaultSelectionSet) {
                    mPlayerStateGroup.check(PLAYER_STATES[i]);
                    defaultSelectionSet = true;
                }
            }
        }
    } else {
        RadioButton radioButton = new RadioButton(getActivity());
        radioButton.setText(getText(R.string.player_state_available));
        radioButton.setId(GameManagerClient.PLAYER_STATE_AVAILABLE);
        radioButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        mPlayerStateGroup.addView(radioButton);
        mPlayerStateGroup.check(GameManagerClient.PLAYER_STATE_AVAILABLE);
    }

    if (!getArguments().getBoolean(KEY_IS_TRANSITION)) {
        mTransitionPlayerStateSection.setVisibility(View.GONE);
        mExtraMessageDataLabel.setText(R.string.game_message_label);
        mExtraMessageDataEditText.setMinLines(4);
        mOkButton.setText(getText(R.string.button_send_game_message));

    }
    builder.setView(view);

    mCancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    mOkButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onOkPressed();
        }
    });

    return builder.create();
}