Example usage for android.app Dialog setCancelable

List of usage examples for android.app Dialog setCancelable

Introduction

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

Prototype

public void setCancelable(boolean flag) 

Source Link

Document

Sets whether this dialog is cancelable with the KeyEvent#KEYCODE_BACK BACK key.

Usage

From source file:Main.java

public static void dialogCancelable(Dialog dialog) {
    dialog.setCancelable(false);
}

From source file:Main.java

public static Dialog showPreloader(Context context, String title, String message) {
    Dialog dialog = ProgressDialog.show(context, title, message, true);
    dialog.setCancelable(true);
    return dialog;
}

From source file:com.memetro.android.alerts.CommentDialog.java

public static void showDialog(final Context context, String comment, String creator, boolean isMine,
        final Long id) {

    final Dialog mDialog = new Dialog(context);
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.setContentView(R.layout.comment_dialog);
    mDialog.setCancelable(true);

    TextView titleText = (TextView) mDialog.findViewById(R.id.title);
    TextView messageText = (TextView) mDialog.findViewById(R.id.message);
    Button closeButton = (Button) mDialog.findViewById(R.id.close);
    Button deleteButton = (Button) mDialog.findViewById(R.id.delete);

    titleText.setText(titleText.getText().toString() + " " + creator);
    messageText.setMovementMethod(ScrollingMovementMethod.getInstance());
    messageText.setText(comment);//w w  w  . j a  v  a2  s.  com

    if (isMine) {
        deleteButton.setVisibility(View.VISIBLE);
        deleteButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                new DeleteInBg(context, String.valueOf(id)).execute();
                mDialog.dismiss();
                // TODO Refrescar las alertas
            }
        });
    }

    closeButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mDialog.dismiss();
        }
    });

    mDialog.show();

}

From source file:fi.tuukka.weather.utils.Utils.java

public static void showImage(Activity activity, View view, Bitmap bmp) {
    final Dialog imageDialog = new Dialog(activity);
    imageDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    imageDialog.setContentView(R.layout.showimage);
    imageDialog.setCancelable(true);

    ImageView imageView = (ImageView) imageDialog.findViewById(R.id.imageView);
    // Getting width & height of the given image.
    DisplayMetrics displayMetrics = activity.getResources().getDisplayMetrics();
    int wn = displayMetrics.widthPixels;
    int hn = displayMetrics.heightPixels;
    int wo = bmp.getWidth();
    int ho = bmp.getHeight();
    Matrix mtx = new Matrix();
    // Setting rotate to 90
    mtx.preRotate(90);/*from   w  w w  . j  a  v  a  2  s. c o  m*/
    // Setting resize
    mtx.postScale(((float) 1.3 * wn) / ho, ((float) 1.3 * hn) / wo);
    // Rotating Bitmap
    Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, wo, ho, mtx, true);
    BitmapDrawable bmd = new BitmapDrawable(rotatedBMP);

    imageView.setImageDrawable(bmd);

    imageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View button) {
            imageDialog.dismiss();
        }
    });

    imageDialog.show();
}

From source file:com.kubotaku.android.sample.sensordataviewer.fragments.AbsDialogFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    final Dialog dialog = getDialog();
    dialog.setCancelable(false);

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    int dialogWidth = (int) (metrics.widthPixels * getDialogWidthRatio());

    WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
    lp.width = dialogWidth;/*  w w w . j a va  2  s. com*/
    dialog.getWindow().setAttributes(lp);
}

From source file:com.kubotaku.android.code4kyoto5374.fragments.OpenSourceLicenseDialog.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    final Dialog dialog = getDialog();
    dialog.setCancelable(true);

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    int dialogWidth = (int) (metrics.widthPixels * 0.95f);

    WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
    lp.width = dialogWidth;/*w w w .j  a va2 s  .  c  o m*/
    dialog.getWindow().setAttributes(lp);

    dialog.setCanceledOnTouchOutside(true);
}

From source file:me.evervasquez.sociales.fragment.dialog.ProgressDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Log.d(TAG, "ProgressDialogFragment.onCreateDialog");

    final Bundle args = getArguments();

    final String paramMessage = args.getString(PARAM_MESSAGE);

    Dialog dialog = ProgressDialog.show(getActivity(), "Executing request", paramMessage);
    dialog.setCancelable(true);
    return dialog;
}

From source file:it.flaviomascetti.posture.MainActivity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override//from w ww. ja v a 2  s  . co m
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_license) {
        Dialog d = new Dialog(this);
        d.setTitle(R.string.license);
        d.setCancelable(true);
        d.setContentView(R.layout.app_license_popup);
        d.show();
    } else if (id == R.id.nav_acc_test) {
        getSupportFragmentManager().beginTransaction().replace(R.id.container, new AccuracyTestFragment())
                .commit();
    } else if (id == R.id.nav_posture_check) {
        getSupportFragmentManager().beginTransaction().replace(R.id.container, new PostureCheckFragment())
                .commit();
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:com.deange.githubstatus.push.PushBaseActivity.java

private boolean performPlayServicesCheck() {

    mNeedToCheckPlayServices = false;/*from www .  j  av a  2 s  . c  o  m*/
    final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (resultCode == ConnectionResult.SUCCESS) {
        return true;

    } else {
        Log.d(TAG, "isGooglePlayServicesAvailable = " + resultCode);

        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
            final Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, 0);
            dialog.setCancelable(false);
            dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    mNeedToCheckPlayServices = true;
                }
            });
            dialog.show();

        } else {
            Log.e(TAG, "Unrecoverable error checking Google Play Services.");
            finish();
        }

        return false;
    }
}

From source file:com.kubotaku.android.code4kyoto5374.fragments.NotifySettingsDialogFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    final Dialog dialog = getDialog();
    dialog.setCancelable(true);

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    int dialogWidth = (int) (metrics.widthPixels * 0.9f);

    WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
    lp.width = dialogWidth;//  w ww  . j a va 2 s  .c  om
    dialog.getWindow().setAttributes(lp);
}