Example usage for android.app Dialog getWindow

List of usage examples for android.app Dialog getWindow

Introduction

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

Prototype

public @Nullable Window getWindow() 

Source Link

Document

Retrieve the current Window for the activity.

Usage

From source file:com.nextgis.ngm_clink_monitoring.dialogs.YesNoDialog.java

@NonNull
@Override/*from w ww.ja  va2 s.c o m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Idea from here
    // http://thanhcs.blogspot.ru/2014/10/android-custom-dialog-fragment.html
    Dialog dialog = new Dialog(getActivity());

    Window window = dialog.getWindow();
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    dialog.setContentView(R.layout.dialog_yes_no);

    mIcon = (ImageView) dialog.findViewById(R.id.title_icon);
    mTitle = (TextView) dialog.findViewById(R.id.title_text);

    mDialogBodyScroll = (ScrollView) dialog.findViewById(R.id.dialog_body_scroll);
    mDialogBodyLayoutScrolled = (LinearLayout) dialog.findViewById(R.id.dialog_body_scrolled);
    mDialogBodyLayout = (LinearLayout) dialog.findViewById(R.id.dialog_body);

    mButtons = (TableLayout) dialog.findViewById(R.id.dialog_buttons_yn);
    mBtnPositive = (Button) dialog.findViewById(R.id.dialog_btn_positive_yn);
    mBtnNegative = (Button) dialog.findViewById(R.id.dialog_btn_negative_yn);

    if (null != mIconId) {
        mIcon.setVisibility(View.VISIBLE);
        mIcon.setImageResource(mIconId);
    }

    if (null != mTitleId) {
        mTitle.setText(mTitleId);
    }
    if (null != mTitleText) {
        mTitle.setText(mTitleText);
    }

    if (null != mMessageId) {
        setMessageView();
        mMessage.setText(mMessageId);
    }
    if (null != mMessageText) {
        setMessageView();
        mMessage.setText(mMessageText);
    }

    if (null != mView) {
        if (mAddScrollForView) {
            mDialogBodyScroll.setVisibility(View.VISIBLE);
            mDialogBodyLayoutScrolled.addView(mView);
        } else {
            mDialogBodyLayout.setVisibility(View.VISIBLE);
            mDialogBodyLayout.addView(mView);
        }
    }

    if (null != mPositiveTextId) {
        mButtons.setVisibility(View.VISIBLE);
        mBtnPositive.setVisibility(View.VISIBLE);
        mBtnPositive.setText(mPositiveTextId);
    }
    if (null != mPositiveText) {
        mButtons.setVisibility(View.VISIBLE);
        mBtnPositive.setVisibility(View.VISIBLE);
        mBtnPositive.setText(mPositiveText);
    }

    if (null != mNegativeTextId) {
        mButtons.setVisibility(View.VISIBLE);
        mBtnNegative.setVisibility(View.VISIBLE);
        mBtnNegative.setText(mNegativeTextId);
    }
    if (null != mNegativeText) {
        mButtons.setVisibility(View.VISIBLE);
        mBtnNegative.setVisibility(View.VISIBLE);
        mBtnNegative.setText(mNegativeText);
    }

    if (null != mOnPositiveClickedListener) {
        mButtons.setVisibility(View.VISIBLE);
        mBtnPositive.setVisibility(View.VISIBLE);
        mBtnPositive.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != mOnPositiveClickedListener) {
                    mOnPositiveClickedListener.onPositiveClicked();
                }
                dismiss();
            }
        });
    }

    if (null != mOnNegativeClickedListener) {
        mButtons.setVisibility(View.VISIBLE);
        mBtnNegative.setVisibility(View.VISIBLE);
        mBtnNegative.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != mOnNegativeClickedListener) {
                    mOnNegativeClickedListener.onNegativeClicked();
                }
                dismiss();
            }
        });
    }

    return dialog;
}

From source file:com.nextgis.libngui.dialog.StyledDialogFragment.java

@NonNull
@Override//www  . java 2  s . c o m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Idea from here
    // http://thanhcs.blogspot.ru/2014/10/android-custom-dialog-fragment.html

    Dialog dialog = new Dialog(mContext);

    Window window = dialog.getWindow();
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return dialog;
}

From source file:com.robopupu.api.mvp.ViewCompatDialogFragment.java

@Override
public void onStart() {
    super.onStart();
    state.onStart();/*from   w  w  w  . j  av  a 2s  .c om*/

    final Dialog dialog = getDialog();

    if (dialog != null) {
        final Window window = dialog.getWindow();
        setupWindowLayout(window);
        setupWindowParams(window);
    }

    final T_Presenter presenter = resolvePresenter();
    if (presenter != null) {
        presenter.onViewStart(this);
        binder.initialise();
    }
}

From source file:piuk.blockchain.android.ui.dialogs.RequestIdentifierDialog.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();
    final LayoutInflater inflater = LayoutInflater.from(activity);

    final Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.Theme_Dialog));

    dialog.setTitle(R.string.wallet_identifier_title);

    final View view = inflater.inflate(R.layout.wallet_identifier_dialog, null);

    dialog.setView(view);//from w ww .  j a va  2s. c  o m

    final Button continueButton = (Button) view.findViewById(R.id.identifier_continue);

    continueButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {

            try {
                final TextView identifierField = (TextView) view.findViewById(R.id.identifier_field);

                final String guid = identifierField.getText().toString();

                validateGUIDorThrow(guid);

                callback.onSuccess(guid);

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

                dismiss();

                callback.onFail(e.getLocalizedMessage());
            }
        }
    });

    Dialog d = dialog.create();

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();

    lp.dimAmount = 0;
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;

    d.show();

    d.getWindow().setAttributes(lp);

    d.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return d;
}

From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java

/**
 * ???/* ww w.j a v a2s  .  c o  m*/
 * @param theme 
 * @param animation 
 * @param windowFeature ?
 * @return dialog
 */
protected Dialog createDialog(int theme, int animation, int windowFeature) {
    Dialog dialog = new Dialog(mContext, theme);
    dialog.getWindow().getAttributes().windowAnimations = animation;
    dialog.requestWindowFeature(windowFeature);
    dialog.setCancelable(true);
    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        public void onDismiss(DialogInterface dialog) {
            mBrowserListener.onDismiss(mWebContext);
        }
    });
    return dialog;
}

From source file:com.bitants.wally.fragments.ImageZoomFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (getActivity() != null) {
        final Dialog dialog = new Dialog(getActivity());
        dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.activity_image_zoom);
        dialog.getWindow().setBackgroundDrawableResource(R.color.Transparent);
        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
        layoutParams.copyFrom(dialog.getWindow().getAttributes());
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
        dialog.getWindow().setAttributes(layoutParams);
        initToolbar(dialog);/* ww w . j av a 2s  . co  m*/
        progressBar = dialog.findViewById(R.id.zoom_loader);
        zoomableImageView = (PhotoView) dialog.findViewById(R.id.image_zoom_photoview);
        if (bitmap != null) {
            if (rect != null) {
                animateIn(dialog);
            }
        } else if (fileUri != null) {
            showLoader();
            Glide.with(getActivity()).load(fileUri).fitCenter()
                    .listener(new RequestListener<Uri, GlideDrawable>() {
                        @Override
                        public boolean onException(Exception e, Uri model, Target<GlideDrawable> target,
                                boolean isFirstResource) {
                            return false;
                        }

                        @Override
                        public boolean onResourceReady(GlideDrawable resource, Uri model,
                                Target<GlideDrawable> target, boolean isFromMemoryCache,
                                boolean isFirstResource) {
                            hideLoader();
                            return false;
                        }
                    }).into(zoomableImageView);
        } else {
            dismiss();
        }
        photoViewAttacher = new PhotoViewAttacher(zoomableImageView);
        photoViewAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
            @Override
            public void onViewTap(View view, float x, float y) {
                dismiss();
            }
        });
        return dialog;
    } else {
        return null;
    }
}

From source file:com.bitants.wally.fragments.MaterialDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (getActivity() != null) {
        final Dialog dialog = new Dialog(getActivity(),
                android.support.v7.appcompat.R.style.Base_Theme_AppCompat_Light_Dialog);
        //                    android.R.style.Theme_DeviceDefault_Light_Dialog);
        dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog.setContentView(R.layout.dialog_base_material);
        textViewTitle = (TextView) dialog.findViewById(R.id.dialog_title);
        buttonNegative = (Button) dialog.findViewById(R.id.dialog_button_negative);
        buttonPositive = (Button) dialog.findViewById(R.id.dialog_button_positive);
        scrollView = (ScrollView) dialog.findViewById(R.id.dialog_scrollview);
        viewStub = (ViewStub) dialog.findViewById(R.id.dialog_viewstub);

        setupViews(dialog.getContext());
        hideEmptyViews();/*from  ww  w .jav  a  2s. com*/

        if (!isCancelable()) {
            buttonNegative.setVisibility(View.GONE);
        }

        return dialog;
    } else {
        return null;
    }
}

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

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

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

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

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

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

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

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

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

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

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

        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:piuk.blockchain.android.ui.dialogs.AddNoteDialog.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();
    final LayoutInflater inflater = LayoutInflater.from(activity);
    final WalletApplication application = (WalletApplication) activity.getApplication();
    final MyRemoteWallet wallet = application.getRemoteWallet();

    if (wallet == null)
        return null;

    final Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.Theme_Dialog));

    String existingNote = wallet.getTxNotes().get(tx);

    final View view = inflater.inflate(R.layout.add_note_dialog, null);

    dialog.setView(view);/*from   ww  w.  j a  v  a2s.c o m*/

    final EditText noteView = (EditText) view.findViewById(R.id.edit_note_field);
    final Button saveButton = (Button) view.findViewById(R.id.save_note_button);

    if (existingNote != null) {
        noteView.setText(existingNote);

        dialog.setTitle(R.string.edit_note);
    } else {
        dialog.setTitle(R.string.add_note);
    }

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

            try {
                String text = noteView.getText().toString().trim();

                if (text.length() == 0) {
                    Toast.makeText(getActivity().getApplication(), R.string.please_enter_note,
                            Toast.LENGTH_SHORT).show();
                    return;
                }

                if (wallet.addTxNote(new Hash(tx), text)) {
                    application.saveWallet(new SuccessCallback() {
                        @Override
                        public void onSuccess() {

                            Toast.makeText(getActivity().getApplication(), R.string.note_saved,
                                    Toast.LENGTH_SHORT).show();

                            dismiss();
                        }

                        @Override
                        public void onFail() {

                            Toast.makeText(getActivity().getApplication(), R.string.toast_error_syncing_wallet,
                                    Toast.LENGTH_SHORT).show();

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

                Toast.makeText(getActivity().getApplication(), e.getLocalizedMessage(), Toast.LENGTH_SHORT)
                        .show();
            }
        }
    });

    Dialog d = dialog.create();

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();

    lp.dimAmount = 0;
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;

    d.show();

    d.getWindow().setAttributes(lp);

    d.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return d;
}

From source file:com.gumgoose.app.quakebuddy.EarthquakeActivity.java

private void showWhatsNewDialog() {
    // Display the change log for QuakeBuddy on-screen
    Dialog dialog = new Dialog(this, android.R.style.Theme_Dialog);
    dialog.setCanceledOnTouchOutside(true);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    dialog.setContentView(R.layout.dialog_change_log);
    dialog.show();/*from  w  w  w .j  a  v a  2  s . co  m*/
}