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, @StyleRes int themeResId) 

Source Link

Document

Creates a dialog window that uses a custom dialog style.

Usage

From source file:com.insthub.O2OMobile.Activity.D1_OrderActivity.java

private void showOrderPriceDialog() {
    LayoutInflater inflater = LayoutInflater.from(D1_OrderActivity.this);
    View view = inflater.inflate(R.layout.d1_order_price_dialog, null);
    mPriceDialog = new Dialog(D1_OrderActivity.this, R.style.dialog);
    mPriceDialog.setContentView(view);/*from ww  w  .  j av  a2 s  .c  o  m*/
    mPriceDialog.setCanceledOnTouchOutside(false);
    mPriceDialog.show();

    mOrderPriceDialogPrice = (TextView) view.findViewById(R.id.order_price_dialog_price);
    mOrderPriceDialogChangePrice = (EditText) view.findViewById(R.id.order_price_dialog_change_price);
    mOrderPriceDialogOk = (Button) view.findViewById(R.id.order_price_dialog_ok);
    mOrderPriceDialogCancel = (Button) view.findViewById(R.id.order_price_dialog_cancel);

    if (mOrderInfoModel.publicOrder.offer_price != null) {
        mOrderPriceDialogPrice.setText(Utils.formatBalance(mOrderInfoModel.publicOrder.offer_price) + "");
    }

    mOrderPriceDialogChangePrice.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            if (s.toString().length() > 0) {
                if (s.toString().substring(0, 1).equals(".")) {
                    s = s.toString().substring(1, s.length());
                    mOrderPriceDialogChangePrice.setText(s);
                }
            }
            if (s.toString().length() > 1) {
                if (s.toString().substring(0, 1).equals("0")) {
                    if (!s.toString().substring(1, 2).equals(".")) {
                        s = s.toString().substring(1, s.length());
                        mOrderPriceDialogChangePrice.setText(s);
                        CharSequence charSequencePirce = mOrderPriceDialogChangePrice.getText();
                        if (charSequencePirce instanceof Spannable) {
                            Spannable spanText = (Spannable) charSequencePirce;
                            Selection.setSelection(spanText, charSequencePirce.length());
                        }
                    }
                }
            }
            boolean flag = false;
            for (int i = 0; i < s.toString().length() - 1; i++) {
                String getstr = s.toString().substring(i, i + 1);
                if (getstr.equals(".")) {
                    flag = true;
                    break;
                }
            }
            if (flag) {
                int i = s.toString().indexOf(".");
                if (s.toString().length() - 3 > i) {
                    String getstr = s.toString().substring(0, i + 3);
                    mOrderPriceDialogChangePrice.setText(getstr);
                    CharSequence charSequencePirce = mOrderPriceDialogChangePrice.getText();
                    if (charSequencePirce instanceof Spannable) {
                        Spannable spanText = (Spannable) charSequencePirce;
                        Selection.setSelection(spanText, charSequencePirce.length());
                    }
                }
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
        }
    });

    mOrderPriceDialogCancel.setOnClickListener(new OnClickListener() {

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

    mOrderPriceDialogOk.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mOrderInfoModel.done(mOrderId, mOrderPriceDialogChangePrice.getText().toString());
            mPriceDialog.dismiss();
        }
    });

}

From source file:com.liangxun.yuejiula.huanxin.chat.activity.GroupsActivity.java

private void showMsgFenghao() {
    final Dialog picAddDialog = new Dialog(GroupsActivity.this, R.style.dialog);
    View picAddInflate = View.inflate(this, R.layout.msg_mine_dialog, null);
    TextView jubao_sure = (TextView) picAddInflate.findViewById(R.id.jubao_sure);
    final TextView content = (TextView) picAddInflate.findViewById(R.id.content);
    content.setText("????");
    //??/*from w  ww . ja v a 2 s.  com*/
    jubao_sure.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getManagerBySchoolId();
            picAddDialog.dismiss();
        }
    });

    //?
    TextView jubao_cancle = (TextView) picAddInflate.findViewById(R.id.jubao_cancle);
    jubao_cancle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            picAddDialog.dismiss();
        }
    });
    picAddDialog.setContentView(picAddInflate);
    picAddDialog.show();
}

From source file:com.jiandanbaoxian.fragment.DialogFragmentCreater.java

private Dialog showSingleChoiceDialog(final Context mContext) {
    View convertView = LayoutInflater.from(mContext).inflate(R.layout.dialog_single_choice, null);
    final Dialog dialog = new Dialog(mContext, R.style.CustomDialog);
    View.OnClickListener listener = new View.OnClickListener() {
        @Override//from w w w .j a va2 s  .  c  o  m
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.tv_confirm:
                onDialogClickLisenter.viewClick("tv_confirm");
                dismiss();
                break;
            }
        }
    };
    TextView tv_confirm = (TextView) convertView.findViewById(R.id.tv_confirm);
    TextView tv_explain = (TextView) convertView.findViewById(R.id.tv_explain);

    tv_explain.setText(StringConstant.TEXT_SHOW_AFTER_CALL_POLICE_SUCCESS);
    if (onDialogClickLisenter != null) {
        onDialogClickLisenter.controlView(tv_confirm, null, null, tv_explain);
    }
    tv_confirm.setOnClickListener(listener);

    dialog.setContentView(convertView);
    dialog.getWindow().setWindowAnimations(R.style.dialog_right_control_style);
    return dialog;
}

From source file:com.huofu.RestaurantOS.ui.splash.activate.java

/**
 * ?//w  w w .  j  a  va 2s  .  c om
 */
public void widgetConfigure() {

    buttonActivate.setOnClickListener(new OnClickListener() {

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

            if (authDialog == null) {
                authDialog = new Dialog(activate.this, R.style.PauseDialog);
            }
            if (ttv.getParent() != null) {
                ttv = new TitanicTextView(ctxt);
            }

            String key = etActivteCode.getText().toString();
            if (key.length() >= 16) {
                CommonUtils.LogWuwei(tag, "key is " + key);
                CommonUtils.sendMsg("?", activate.SHOW_LOADING_TEXT, mUiHandler);
                activate(ctxt, key);
            } else {
                CommonUtils.sendMsg("????", activate.SHOW_ERROR_MESSAGE, mUiHandler);
            }

        }
    });

    InputFilter filter = new InputFilter() {

        @Override
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                int dend) {
            // TODO Auto-generated method stub
            for (int i = start; i < end; i++) {
                //???'-'
                if (!Character.isLetter(source.charAt(i)) && source.charAt(i) != '-') {
                    return "";
                }
            }
            return null;
        }
    };

    InputFilter filterLength = new InputFilter.LengthFilter(19);

    etActivteCode.setCursorVisible(false);
    etActivteCode.setFilters(new InputFilter[] { filter, filterLength });
    etActivteCode.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

            etActivteCode.setCursorVisible(true);
            etActivteCode.removeTextChangedListener(this);// ?
            etActivteCode.setText(s.toString().toUpperCase());// ?
            etActivteCode.setSelection(s.toString().length());// ??
            etActivteCode.addTextChangedListener(this);// ?
            String licensePlateNumber = etActivteCode.getText().toString().trim();

            if (s.length() == 19) {
                InputMethodUtils.HideKeyboard(etActivteCode);
            }

        }
    });
    etActivteCode.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // TODO Auto-generated method stub
            if (keyCode == KeyEvent.KEYCODE_DEL) {
                CommonUtils.LogWuwei(tag, "delete");
                etActivteCode.setCursorVisible(false);
            }
            return false;
        }
    });

    rl_activate_qrscan_ready.setVisibility(View.INVISIBLE);

    OnClickListener oclGetQrCode = new OnClickListener() {
        @Override
        public void onClick(View v) {
            flagInQrcodeDialog = true;
            CommonUtils.sendMsg("??", SHOW_LOADING_TEXT, mUiHandler);

            if (LocalDataDeal.readFromLocalPublicKey(ctxt) == null
                    || LocalDataDeal.readFromLocalPublicKey(ctxt).equals("")) {
                ApisManager.GetPublicKey(new ApiCallback() {
                    @Override
                    public void success(Object object) {
                        sendUIMessage(HIDE_LOADING, "");
                        try {
                            org.json.JSONObject obj = new org.json.JSONObject((String) object);
                            String public_key = obj.getString("public_key");
                            LocalDataDeal.writeToLocalPublicKey(public_key, ctxt);//key?base64?
                        } catch (Exception e) {
                        }
                        CommonUtils.sendMsg("", GET_QRCODE, mUiHandler);
                    }

                    @Override
                    public void error(BaseApi.ApiResponse response) {
                        sendUIMessage(HIDE_LOADING, "");
                        sendUIMessage(SHOW_ERROR_MESSAGE, response.error_message);
                    }
                });
            } else {
                CommonUtils.sendMsg("", GET_QRCODE, mUiHandler);
            }

            rl_activate_input.setVisibility(View.INVISIBLE);
            rl_activate_qrscan_ready.setVisibility(View.VISIBLE);
            imageViewQrcode.setVisibility(View.INVISIBLE);
            rl_activate_qrscan_ready
                    .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big));

            textviewScanStauts.setTextColor(Color.parseColor("#898989"));
            textviewScanStauts.setText(R.string.activateByQrCodeTips);

            rl_activate_qrscan_ready
                    .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_left_in));
            rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_right_out));
        }
    };

    buttonSwitchQrScan.setOnClickListener(oclGetQrCode);
    findViewById(R.id.rl_switch_activate_qrcode_way).setOnClickListener(oclGetQrCode);

    buttonSwitchInputCode.setOnClickListener(new OnClickListener() {

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

            flagInQrcodeDialog = false;
            flagWaitingCmd = false;
            rl_activate_qrscan_ready.setVisibility(View.INVISIBLE);
            rl_activate_input.setVisibility(View.VISIBLE);
            rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big));

            stopQrScanTimer();

            rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_right_in));
            rl_activate_qrscan_ready
                    .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_left_out));

        }
    });

    findViewById(R.id.rl_switch_activate_keyboard_way).setOnClickListener(new OnClickListener() {

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

            flagInQrcodeDialog = false;
            flagWaitingCmd = false;
            rl_activate_qrscan_ready.setVisibility(View.INVISIBLE);
            rl_activate_input.setVisibility(View.VISIBLE);
            rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big));

            stopQrScanTimer();
        }
    });

    PackageManager manager;
    PackageInfo info = null;
    manager = this.getPackageManager();
    String versionName = null;
    try {
        info = manager.getPackageInfo(this.getPackageName(), 0);
        versionName = info.versionName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    ((TextView) findViewById(R.id.tv_app_version))
            .setText(getResources().getString(R.string.app_name) + " V" + versionName);

    LocalDataDeal.writeToLocalVersion(versionName, ctxt);
    LocalDataDeal.writeToLocalVersionCode(info.versionCode, ctxt);

    ftpServiceStart();
}

From source file:com.oonhee.oojs.inappbrowser.InAppBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url           The url to load.
 * @param jsonObject//from w w  w  . j  av a  2  s. c  om
 */
public String showWebPage(final String url, HashMap<String, Boolean> features) {
    // Determine if we should hide the location bar.
    showLocationBar = true;
    openWindowHidden = false;
    if (features != null) {
        Boolean show = features.get(LOCATION);
        if (show != null) {
            showLocationBar = show.booleanValue();
        }
        Boolean hidden = features.get(HIDDEN);
        if (hidden != null) {
            openWindowHidden = hidden.booleanValue();
        }
        Boolean cache = features.get(CLEAR_ALL_CACHE);
        if (cache != null) {
            clearAllCache = cache.booleanValue();
        } else {
            cache = features.get(CLEAR_SESSION_CACHE);
            if (cache != null) {
                clearSessionCache = cache.booleanValue();
            }
        }
    }

    final CordovaWebView thatWebView = this.webView;

    // Create dialog in new thread
    Runnable runnable = new Runnable() {
        /**
         * Convert our DIP units to Pixels
         *
         * @return int
         */
        private int dpToPixels(int dipValue) {
            int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue,
                    cordova.getActivity().getResources().getDisplayMetrics());

            return value;
        }

        public void run() {
            // Let's create the main dialog
            dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
            dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCancelable(true);
            dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                public void onDismiss(DialogInterface dialog) {
                    closeDialog();
                }
            });

            // Main container layout
            LinearLayout main = new LinearLayout(cordova.getActivity());
            main.setOrientation(LinearLayout.VERTICAL);

            // Toolbar layout
            RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
            //Please, no more black! 
            toolbar.setBackgroundColor(android.graphics.Color.LTGRAY);
            toolbar.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44)));
            toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
            toolbar.setHorizontalGravity(Gravity.LEFT);
            toolbar.setVerticalGravity(Gravity.TOP);

            // Action Button Container layout
            RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity());
            actionButtonContainer.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            actionButtonContainer.setHorizontalGravity(Gravity.LEFT);
            actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL);
            actionButtonContainer.setId(1);

            // Back button
            Button back = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
            back.setLayoutParams(backLayoutParams);
            back.setContentDescription("Back Button");
            back.setId(2);
            back.setText("<");
            back.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    goBack();
                }
            });

            // Forward button
            Button forward = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2);
            forward.setLayoutParams(forwardLayoutParams);
            forward.setContentDescription("Forward Button");
            forward.setId(3);
            forward.setText(">");
            forward.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    goForward();
                }
            });

            // Edit Text Box
            edittext = new EditText(cordova.getActivity());
            RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
            textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
            edittext.setLayoutParams(textLayoutParams);
            edittext.setId(4);
            edittext.setSingleLine(true);
            edittext.setText(url);
            edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
            edittext.setImeOptions(EditorInfo.IME_ACTION_GO);
            edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE
            edittext.setOnKeyListener(new View.OnKeyListener() {
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    // If the event is a key-down event on the "enter" button
                    if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                        navigate(edittext.getText().toString());
                        return true;
                    }
                    return false;
                }
            });

            // Close button
            Button close = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            close.setLayoutParams(closeLayoutParams);
            forward.setContentDescription("Close Button");
            close.setId(5);
            close.setText(buttonLabel);
            close.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    closeDialog();
                }
            });

            // WebView
            inAppWebView = new AmazonWebView(cordova.getActivity());

            CordovaActivity app = (CordovaActivity) cordova.getActivity();
            cordova.getFactory().initializeWebView(inAppWebView, 0x00FF00, false, null);

            inAppWebView.setLayoutParams(
                    new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
            inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView));
            AmazonWebViewClient client = new InAppBrowserClient(thatWebView, edittext);
            inAppWebView.setWebViewClient(client);
            AmazonWebSettings settings = inAppWebView.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            settings.setBuiltInZoomControls(true);
            settings.setPluginState(com.amazon.android.webkit.AmazonWebSettings.PluginState.ON);

            //Toggle whether this is enabled or not!
            Bundle appSettings = cordova.getActivity().getIntent().getExtras();
            boolean enableDatabase = appSettings == null ? true
                    : appSettings.getBoolean("InAppBrowserStorageEnabled", true);
            if (enableDatabase) {
                String databasePath = cordova.getActivity().getApplicationContext()
                        .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath();
                settings.setDatabasePath(databasePath);
                settings.setDatabaseEnabled(true);
            }
            settings.setDomStorageEnabled(true);

            if (clearAllCache) {
                AmazonCookieManager.getInstance().removeAllCookie();
            } else if (clearSessionCache) {
                AmazonCookieManager.getInstance().removeSessionCookie();
            }

            inAppWebView.loadUrl(url);
            inAppWebView.setId(6);
            inAppWebView.getSettings().setLoadWithOverviewMode(true);
            inAppWebView.getSettings().setUseWideViewPort(true);
            inAppWebView.requestFocus();
            inAppWebView.requestFocusFromTouch();

            // Add the back and forward buttons to our action button container layout
            actionButtonContainer.addView(back);
            actionButtonContainer.addView(forward);

            // Add the views to our toolbar
            toolbar.addView(actionButtonContainer);
            toolbar.addView(edittext);
            toolbar.addView(close);

            // Don't add the toolbar if its been disabled
            if (getShowLocationBar()) {
                // Add our toolbar to our main view/layout
                main.addView(toolbar);
            }

            // Add our webview to our main view/layout
            main.addView(inAppWebView);

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            lp.copyFrom(dialog.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.MATCH_PARENT;
            lp.height = WindowManager.LayoutParams.MATCH_PARENT;

            dialog.setContentView(main);
            dialog.show();
            dialog.getWindow().setAttributes(lp);
            // the goal of openhidden is to load the url and not display it
            // Show() needs to be called to cause the URL to be loaded
            if (openWindowHidden) {
                dialog.hide();
            }
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
    return "";
}

From source file:com.jiandanbaoxian.fragment.DialogFragmentCreater.java

private Dialog showRegionChoiceDialog(final Context mContext) {
    View convertView = LayoutInflater.from(mContext).inflate(R.layout.dialog_region_choice, null);
    final Dialog dialog = new Dialog(mContext, R.style.CustomDialog);
    View.OnClickListener listener = new View.OnClickListener() {
        @Override/*  w  w  w . j  a  va  2  s  .  co  m*/
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.layout_back:
                if (onDialogBackClickLisenter != null) {
                    onDialogBackClickLisenter.onClickBack(titleText, regionBeans, v);
                }
                break;
            }
        }
    };

    tvTitle = (TextView) convertView.findViewById(R.id.tv_region_name);
    listView = (ListView) convertView.findViewById(R.id.list_view);
    layoutBack = (LinearLayout) convertView.findViewById(R.id.layout_back);
    adapter = new RegionListAdapter(regionBeans, mContext);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (onDialogBackClickLisenter != null) {
                onDialogBackClickLisenter.onItemClickListener(position, id);
            }

        }
    });

    tvTitle.setText(titleText);
    layoutBack.setOnClickListener(listener);

    dialog.setContentView(convertView);
    dialog.getWindow().setWindowAnimations(R.style.dialog_right_control_style);
    return dialog;
}

From source file:com.actionbarsherlock.plus.SherlockDialogPlusFragment.java

/**
 * Override to build your own custom Dialog container.  This is typically
 * used to show an AlertDialog instead of a generic Dialog; when doing so,
 * {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)} does not need
 * to be implemented since the AlertDialog takes care of its own content.
 * //w  w  w. j a v a  2 s.c  o  m
 * <p>This method will be called after {@link #onCreate(Bundle)} and
 * before {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}.  The
 * default implementation simply instantiates and returns a {@link Dialog}
 * class.
 * 
 * <p><em>Note: DialogFragment own the {@link Dialog#setOnCancelListener
 * Dialog.setOnCancelListener} and {@link Dialog#setOnDismissListener
 * Dialog.setOnDismissListener} callbacks.  You must not set them yourself.</em>
 * To find out about these events, override {@link #onCancel(DialogInterface)}
 * and {@link #onDismiss(DialogInterface)}.</p>
 * 
 * @param savedInstanceState The last saved instance state of the Fragment,
 * or null if this is a freshly created Fragment.
 * 
 * @return Return a new Dialog instance to be displayed by the Fragment.
 */
public Dialog onCreateDialog(Bundle savedInstanceState) {
    return new Dialog(getActivity(), getTheme());
}

From source file:com.gpsmobitrack.gpstracker.MenuItems.SettingsPage.java

/**
 *  Background updates show ON or OFF/*w w w.  j  av a  2 s. com*/
 */
private void showAlert(String Message, String Title, final int alertCode) {
    final Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(false);
    dialog.setContentView(R.layout.alert_dialog_main);
    final TextView alertTitle = (TextView) dialog.findViewById(R.id.alert_title);
    final TextView alertMsg = (TextView) dialog.findViewById(R.id.alert_msg);
    final EditText alertEditTxt = (EditText) dialog.findViewById(R.id.alert_edit_txt);
    Button okBtn = (Button) dialog.findViewById(R.id.alert_ok_btn);
    Button cancelBtn = (Button) dialog.findViewById(R.id.alert_cancel_btn);
    alertTitle.setText(Title);
    alertMsg.setText(Message);
    alertEditTxt.setVisibility(View.GONE);
    if (alertCode == 0 || alertCode == UPDATE_INT || alertCode == 7) {
        cancelBtn.setVisibility(View.VISIBLE);
    } else {
        cancelBtn.setVisibility(View.GONE);
    }
    cancelBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            if (alertCode == 7) {
                backUpdateToggle.setChecked(true);
                editor.putBoolean(AppConstants.IS_SERVICE_ENABLED_PREF, true);
                editor.commit();
            }
        }
    });
    okBtn.setOnClickListener(new OnClickListener() {
        @SuppressWarnings("unused")
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            if (alertCode == 3 || alertCode == 4) {

                session.logoutUser(getActivity());
                Intent i = new Intent(getActivity(), Login.class);
                startActivity(i);
                getActivity().finish();
            } else if (alertCode == 0) {
                deactivateAcc();
            } else if (alertCode == UPDATE_INT) {
                getActivity().finish();
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("market://details?id=com.gpstracker.pro"));
                startActivity(intent);
            } else if (alertCode == 7) {
                backUpdateToggle.setChecked(false);
                editor.putBoolean(AppConstants.IS_SERVICE_ENABLED_PREF, false);
                editor.commit();
                AlarmManager alarm = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
                Calendar cal = Calendar.getInstance();
                Intent intent2 = new Intent(getActivity(), BackgroundService.class);
                PendingIntent pintent = PendingIntent.getService(getActivity(), 0, intent2, 0);
                if (PendingIntent.getService(getActivity(), 0, intent2, PendingIntent.FLAG_NO_CREATE) != null) {
                    alarm.cancel(pintent);
                }
            }
        }
    });
    dialog.show();
}

From source file:com.aero2.android.DefaultActivities.SmogMapActivity.java

protected void showSplashScreen() {
    SharedPreferences afterServiceCompletion = getApplicationContext()
            .getSharedPreferences("AFTER_SERVICE_COMPLETED", Context.MODE_WORLD_WRITEABLE);
    SharedPreferences afterPermissionGranted = getApplicationContext()
            .getSharedPreferences("AFTER_PERMISSION_GRANTED", Context.MODE_WORLD_WRITEABLE);
    boolean serviceJustCompleted = afterServiceCompletion.getBoolean("AFTER_SERVICE_COMPLETED", false);
    splashScreen = new Dialog(this, R.style.SplashScreen);
    permissionJustGranted = afterPermissionGranted.getBoolean("AFTER_PERMISSION_GRANTED", false);

    if (!serviceJustCompleted && !permissionJustGranted) {

        //            View splashIcon=(View) findViewById(R.id.splash_icon);
        //            View splashText=(View) findViewById(R.id.splash_text);
        //            splashIcon.setVisibility(View.GONE);
        //            splashText.setVisibility(View.GONE);
        splashScreen.setContentView(R.layout.splash_screen);
        splashScreen.setCancelable(false);
        splashScreen.show();/*from ww w  .ja  v a2  s.c o m*/
    } else if (serviceJustCompleted) {
        SharedPreferences.Editor afterServiceCompletionEditor = afterServiceCompletion.edit();
        afterServiceCompletionEditor.putBoolean("AFTER_SERVICE_COMPLETED", false);
        afterServiceCompletionEditor.commit();
        splashScreen.setCancelable(false);
        splashScreen.show();
    } else if (permissionJustGranted) {
        removeSplashScreen();
    }

}

From source file:com.appolis.receiving.AcReceiveOptionMove.java

/**
 * show alert dialog/*from   w ww. j a  va 2s  .c om*/
 * @param mContext
 * @param strMessages
 */
public void showPopUp(final Context mContext, final String strMessages) {
    final Dialog dialog = new Dialog(mContext, R.style.Dialog_NoTitle);
    dialog.setContentView(R.layout.dialogwarning);
    // set the custom dialog components - text, image and button      
    TextView text2 = (TextView) dialog.findViewById(R.id.tvScantitle2);
    text2.setText(strMessages);

    LanguagePreferences langPref = new LanguagePreferences(mContext);
    Button dialogButtonOk = (Button) dialog.findViewById(R.id.dialogButtonOK);
    dialogButtonOk.setText(langPref.getPreferencesString(GlobalParams.OK, GlobalParams.OK));

    dialogButtonOk.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            scanFlag = GlobalParams.FLAG_ACTIVE;
        }
    });
    dialog.show();
}