Example usage for android.app Dialog setCanceledOnTouchOutside

List of usage examples for android.app Dialog setCanceledOnTouchOutside

Introduction

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

Prototype

public void setCanceledOnTouchOutside(boolean cancel) 

Source Link

Document

Sets whether this dialog is canceled when touched outside the window's bounds.

Usage

From source file:com.givon.baseproject.xinlu.act.ActRegist.java

public void showDialog(final String phone, final String code) {
    int resId = getStyleRes(this, "CommonDialog");
    if (resId > 0) {
        final String phoneNum = "+" + code + " " + splitPhoneNum(phone);
        final Dialog dialog = new Dialog(this, resId);
        resId = getLayoutRes(this, "smssdk_send_msg_dialog");
        if (resId > 0) {
            dialog.setContentView(resId);
            resId = getIdRes(this, "tv_phone");
            ((TextView) dialog.findViewById(resId)).setText(phoneNum);
            resId = getIdRes(this, "tv_dialog_hint");
            TextView tv = (TextView) dialog.findViewById(resId);
            resId = getStringRes(this, "smssdk_make_sure_mobile_detail");
            if (resId > 0) {
                String text = this.getString(resId);
                tv.setText(Html.fromHtml(text));
            }//from   w  w  w.ja  v  a  2  s .co m
            resId = getIdRes(this, "btn_dialog_ok");
            if (resId > 0) {
                ((Button) dialog.findViewById(resId)).setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        // ???
                        dialog.dismiss();
                        Log.e("verification phone ==>>", phone);
                        showWaitingDialog();
                        SMSSDK.getVerificationCode(code, phone.trim());
                    }
                });
            }
            resId = getIdRes(this, "btn_dialog_cancel");
            if (resId > 0) {
                ((Button) dialog.findViewById(resId)).setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });
            }
            dialog.setCanceledOnTouchOutside(true);
            dialog.show();
        }
    }
}

From source file:com.haibison.android.anhuu.utils.ui.history.HistoryFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG)
        Log.d(CLASSNAME, "onCreateDialog()");
    Dialog dialog = new Dialog(getActivity(),
            UI.resolveAttribute(getActivity(), R.attr.anhuu_f5be488d_theme_dialog)) {

        @Override//from  w  w  w . ja  v a2  s.  c  o m
        public boolean onCreateOptionsMenu(Menu menu) {
            getActivity().getMenuInflater().inflate(R.menu.anhuu_f5be488d_viewgroup_history, menu);
            return super.onCreateOptionsMenu(menu);
        }// onCreateOptionsMenu()

        @Override
        public boolean onPrepareOptionsMenu(Menu menu) {
            menu.findItem(R.id.anhuu_f5be488d_menuitem_clear)
                    .setEnabled(mHistoryCursorAdapter != null && mHistoryCursorAdapter.getGroupCount() > 0);
            return true;
        }// onPrepareOptionsMenu()

        @Override
        public boolean onMenuItemSelected(int featureId, MenuItem item) {
            if (BuildConfig.DEBUG)
                Log.d(CLASSNAME, "onMenuItemSelected() in Dialog");

            UI.showSoftKeyboard(mSearchView, false);

            if (item.getItemId() == R.id.anhuu_f5be488d_menuitem_clear)
                doConfirmClearHistory();

            return true;
        }// onMenuItemSelected()
    };

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(true);
    dialog.setContentView(initContentView(dialog.getLayoutInflater(), null));
    dialog.setOnKeyListener(mDialogOnKeyListener);

    UI.adjustDialogSizeForLargeScreens(dialog);

    return dialog;
}

From source file:com.neighbor.ex.tong.ui.activity.MainActivity2Activity.java

private void showDialogAree() {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    dialog.setContentView(R.layout.dialog_agree); // custom_dialog.xml  ? layout  ?? view .
    WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
    params.width = LinearLayout.LayoutParams.MATCH_PARENT;
    final CheckBox accountLicense = (CheckBox) dialog.findViewById(R.id.checkBoxAgree);
    final Button agreeBtn = (Button) dialog.findViewById(R.id.buttonAgree);
    final Button agreeCancelBtn = (Button) dialog.findViewById(R.id.buttonAgreeCancel);
    agreeBtn.setOnClickListener(new View.OnClickListener() {
        @Override//  w  ww. j  a v  a 2 s.c o  m
        public void onClick(View view) {
            if (accountLicense.isChecked()) {
                SharedPreferenceManager.setValue(MainActivity2Activity.this,
                        SharedPreferenceManager.positionAgree, "true");
                dialog.dismiss();
            }
        }
    });
    agreeCancelBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
}

From source file:no.barentswatch.fiskinfo.MapActivity.java

/**
 * //  w  w  w .  j a  va  2 s  .  c  om
 */
public void showMapLayersDialog() {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setContentView(R.layout.dialog_select_map_layers);

    final LinearLayout mapLayerLayout = (LinearLayout) dialog.findViewById(R.id.map_layers_checkbox_layout);
    Button okButton = (Button) dialog.findViewById(R.id.dismiss_dialog_button);
    Button cancelButton = (Button) dialog.findViewById(R.id.go_to_map_button);

    for (int i = 0; i < 5; i++) {
        View mapLayerRow = getMapLayerCheckBoxRow(getContext(), Integer.toString(i));
        mapLayerLayout.addView(mapLayerRow);
    }

    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            for (int i = 0; i < mapLayerLayout.getChildCount(); i++) {
                if (((CheckBox) ((TableRow) mapLayerLayout.getChildAt(i)).getChildAt(0)).isChecked()) {
                    // TODO: Add layer to list

                }
            }
            // TODO: Implement logic for adding map layers here.            

            dialog.dismiss();
        }
    });

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

    dialog.setTitle(R.string.choose_map_layers);
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
}

From source file:com.starwood.anglerslong.MainActivity.java

/*****************************************************************************************
 * Dialog to show fishing regulations/*w w  w  .  j av  a2 s  .  c om*/
 *****************************************************************************************/
private void displayDialog() {

    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.fishing_reg_dialog);
    dialog.setTitle("Select a State:");

    dialog.findViewById(R.id.sc_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(scUrl));
            startActivity(browserIntent);
        }
    });

    dialog.findViewById(R.id.ga_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(gaUrl));
            startActivity(browserIntent);
        }
    });

    dialog.findViewById(R.id.fl_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(flUrl));
            startActivity(browserIntent);
        }
    });

    dialog.findViewById(R.id.al_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(alUrl));
            startActivity(browserIntent);
        }
    });

    dialog.findViewById(R.id.ms_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(msUrl));
            startActivity(browserIntent);
        }
    });

    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
}

From source file:com.inter.trade.ui.fragment.smsreceivepayment.SmsReceivePaymentMainFragment.java

/**
 * ??/*  w ww  . j av  a 2  s  .  com*/
 * @param message
 * @param positive
 * @param negative
 * @param positiveEnable
 * @param negativeEnable
 */
private void showDefaultCardDialog(String message, String positive, String negative, boolean positiveEnable,
        boolean negativeEnable) {
    message = "??????????";

    //newDialog?
    Dialog dialog = new Dialog(getActivity(), R.style.MyDialogStyleBottom);
    //ContentView
    dialog.setContentView(R.layout.sms_default_card_dialog);
    dialog.findViewById(R.id.select_card).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            selectReceiveBankCard();
        }
    });
    dialog.findViewById(R.id.add_card).setOnClickListener(new OnClickListener() {

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

    dialog.findViewById(R.id.select_card).setEnabled(positiveEnable);
    dialog.findViewById(R.id.add_card).setEnabled(negativeEnable);
    dialog.setCancelable(true);
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
}

From source file:com.inde.shiningdays.MainActivity.java

private void openRateDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    // Get the layout inflater
    LayoutInflater inflater = this.getLayoutInflater();

    final View layout = inflater.inflate(R.layout.rate_dialog, null);
    builder.setView(layout);//from w  ww  . ja  va2 s . c  om
    final Dialog dialog = builder.create();

    //rate right now 
    layout.findViewById(R.id.rate_right_now).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            //open the market list
            Intent goToMarket = new Intent(Intent.ACTION_VIEW);
            goToMarket.setData(Uri.parse("market://details?id=" + getPackageName()));
            startActivity(goToMarket);
            //modify the isOpenRateDialog = false
            SharedPreferences prefs = SharedPrefsUtil.getSharedPrefs(v.getContext(),
                    Constant.COUNT_DOWN_SETTING_PREF);
            Editor editor = prefs.edit();
            editor.putBoolean(Constant.IS_OPEN_RATE_DIALOG, false);
            editor.commit();
            //dismiss dialog
            dialog.dismiss();
        }
    });
    //rate later
    layout.findViewById(R.id.rate_later).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    //rate never
    layout.findViewById(R.id.rate_never).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            //modify the isOpenRateDialog = false
            SharedPreferences prefs = SharedPrefsUtil.getSharedPrefs(v.getContext(),
                    Constant.COUNT_DOWN_SETTING_PREF);
            Editor editor = prefs.edit();
            editor.putBoolean(Constant.IS_OPEN_RATE_DIALOG, false);
            editor.commit();
            //dismiss dialog
            dialog.dismiss();
        }
    });

    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
}

From source file:group.pals.android.lib.ui.filechooser.FragmentFiles.java

/**
 * Show a dialog for sorting options and resort file list after user
 * selected an option./* w ww  .j av  a  2s.  com*/
 */
private void resortViewFiles() {
    final Dialog dialog = new Dialog(getActivity(),
            Ui.resolveAttribute(getActivity(), R.attr.afc_theme_dialog));
    dialog.setCanceledOnTouchOutside(true);

    // get the index of button of current sort type
    int btnCurrentSortTypeIdx = 0;
    switch (DisplayPrefs.getSortType(getActivity())) {
    case BaseFile.SORT_BY_NAME:
        btnCurrentSortTypeIdx = 0;
        break;
    case BaseFile.SORT_BY_SIZE:
        btnCurrentSortTypeIdx = 2;
        break;
    case BaseFile.SORT_BY_MODIFICATION_TIME:
        btnCurrentSortTypeIdx = 4;
        break;
    }
    if (!DisplayPrefs.isSortAscending(getActivity()))
        btnCurrentSortTypeIdx++;

    View.OnClickListener listener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();

            if (v.getId() == R.id.afc_button_sort_by_name_asc) {
                DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_NAME);
                DisplayPrefs.setSortAscending(getActivity(), true);
            } else if (v.getId() == R.id.afc_button_sort_by_name_desc) {
                DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_NAME);
                DisplayPrefs.setSortAscending(getActivity(), false);
            } else if (v.getId() == R.id.afc_button_sort_by_size_asc) {
                DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_SIZE);
                DisplayPrefs.setSortAscending(getActivity(), true);
            } else if (v.getId() == R.id.afc_button_sort_by_size_desc) {
                DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_SIZE);
                DisplayPrefs.setSortAscending(getActivity(), false);
            } else if (v.getId() == R.id.afc_button_sort_by_date_asc) {
                DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_MODIFICATION_TIME);
                DisplayPrefs.setSortAscending(getActivity(), true);
            } else if (v.getId() == R.id.afc_button_sort_by_date_desc) {
                DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_MODIFICATION_TIME);
                DisplayPrefs.setSortAscending(getActivity(), false);
            }

            /*
             * Reload current location.
             */
            goTo(getCurrentLocation());
            getActivity().supportInvalidateOptionsMenu();
        }// onClick()
    };// listener

    View view = getLayoutInflater(null).inflate(R.layout.afc_settings_sort_view, null);
    for (int i = 0; i < BUTTON_SORT_IDS.length; i++) {
        View v = view.findViewById(BUTTON_SORT_IDS[i]);
        v.setOnClickListener(listener);
        if (i == btnCurrentSortTypeIdx) {
            v.setEnabled(false);
            if (v instanceof Button)
                ((Button) v).setText(R.string.afc_bullet);
        }
    }

    dialog.setTitle(R.string.afc_title_sort_by);
    dialog.setContentView(view);
    dialog.show();
}

From source file:es.javocsoft.android.lib.toolbox.ToolBox.java

/**
 * "Coach mark" (help overlay image)//from w w  w  .j av a2s. com
 * 
 * @param context
 * @param coachMarkLayoutId   Is "Help overlay" layout id in UX talk :-) 
 *             [coach_mark.xml is your coach mark layout]
 * @param coachMarkMasterViewId   is the id of the top most view in coach_mark.xml
 */
public static void dialog_onCoachMark(Context context, int coachMarkLayoutId, int coachMarkMasterViewId,
        int bgColor) {

    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(bgColor));
    dialog.setContentView(coachMarkLayoutId);
    dialog.setCanceledOnTouchOutside(true);

    //for dismissing anywhere you touch
    View masterView = dialog.findViewById(coachMarkMasterViewId);
    masterView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });

    dialog.show();
}

From source file:com.haibison.android.anhuu.FragmentFiles.java

/**
 * Show a dialog for sorting options and resort file list after user
 * selected an option.//from   w ww .ja v a2s .c om
 */
private void resortViewFiles() {
    final Dialog dialog = new Dialog(getActivity(),
            UI.resolveAttribute(getActivity(), R.attr.anhuu_f5be488d_theme_dialog));
    dialog.setCanceledOnTouchOutside(true);

    // get the index of button of current sort type
    int btnCurrentSortTypeIdx = 0;
    switch (Display.getSortType(getActivity())) {
    case BaseFile.SORT_BY_NAME:
        btnCurrentSortTypeIdx = 0;
        break;
    case BaseFile.SORT_BY_SIZE:
        btnCurrentSortTypeIdx = 2;
        break;
    case BaseFile.SORT_BY_MODIFICATION_TIME:
        btnCurrentSortTypeIdx = 4;
        break;
    }
    if (!Display.isSortAscending(getActivity()))
        btnCurrentSortTypeIdx++;

    View.OnClickListener listener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();

            if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_name_asc) {
                Display.setSortType(getActivity(), BaseFile.SORT_BY_NAME);
                Display.setSortAscending(getActivity(), true);
            } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_name_desc) {
                Display.setSortType(getActivity(), BaseFile.SORT_BY_NAME);
                Display.setSortAscending(getActivity(), false);
            } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_size_asc) {
                Display.setSortType(getActivity(), BaseFile.SORT_BY_SIZE);
                Display.setSortAscending(getActivity(), true);
            } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_size_desc) {
                Display.setSortType(getActivity(), BaseFile.SORT_BY_SIZE);
                Display.setSortAscending(getActivity(), false);
            } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_date_asc) {
                Display.setSortType(getActivity(), BaseFile.SORT_BY_MODIFICATION_TIME);
                Display.setSortAscending(getActivity(), true);
            } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_date_desc) {
                Display.setSortType(getActivity(), BaseFile.SORT_BY_MODIFICATION_TIME);
                Display.setSortAscending(getActivity(), false);
            }

            /*
             * Reload current location.
             */
            goTo(getCurrentLocation());
            getActivity().supportInvalidateOptionsMenu();
        }// onClick()
    };// listener

    View view = getLayoutInflater(null).inflate(R.layout.anhuu_f5be488d_settings_sort_view, null);
    for (int i = 0; i < BUTTON_SORT_IDS.length; i++) {
        View v = view.findViewById(BUTTON_SORT_IDS[i]);
        v.setOnClickListener(listener);
        if (i == btnCurrentSortTypeIdx) {
            v.setEnabled(false);
            if (v instanceof Button)
                ((Button) v).setText(R.string.anhuu_f5be488d_bullet);
        }
    }

    dialog.setTitle(R.string.anhuu_f5be488d_title_sort_by);
    dialog.setContentView(view);
    dialog.show();
}