Java Code Examples for com.afollestad.materialdialogs.MaterialDialog#setCanceledOnTouchOutside()

The following examples show how to use com.afollestad.materialdialogs.MaterialDialog#setCanceledOnTouchOutside() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityLocation.java    From RxTools-master with Apache License 2.0 6 votes vote down vote up
private void gpsCheck() {
    if (!RxLocationTool.isGpsEnabled(this)) {
        MaterialDialog.Builder builder = new MaterialDialog.Builder(this);
        MaterialDialog materialDialog = builder.title("GPS未打开").content("您需要在系统设置中打开GPS方可采集数据").positiveText("去设置")
                .onPositive(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        RxLocationTool.openGpsSettings(mContext);
                    }
                }).build();
        materialDialog.setCanceledOnTouchOutside(false);
        materialDialog.setCancelable(false);
        materialDialog.show();
    } else {
        getLocation();
    }
}
 
Example 2
Source File: IntentChooserFragment.java    From candybar with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity());
    builder.customView(R.layout.fragment_intent_chooser, false);
    builder.typeface(
            TypefaceHelper.getMedium(getActivity()),
            TypefaceHelper.getRegular(getActivity()));
    builder.positiveText(android.R.string.cancel);

    MaterialDialog dialog = builder.build();
    dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(view -> {
        if (mAdapter == null || mAdapter.isAsyncTaskRunning()) return;

        if (CandyBarApplication.sZipPath != null) {
            File file = new File(CandyBarApplication.sZipPath);
            if (file.exists()) {
                if (file.delete()) {
                    LogUtil.e(String.format("Intent chooser cancel: %s deleted", file.getName()));
                }
            }
        }

        RequestFragment.sSelectedRequests = null;
        CandyBarApplication.sRequestProperty = null;
        CandyBarApplication.sZipPath = null;
        dialog.dismiss();
    });
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
    setCancelable(false);

    mIntentList = (ListView) dialog.findViewById(R.id.intent_list);
    mNoApp = (TextView) dialog.findViewById(R.id.intent_noapp);
    return dialog;
}
 
Example 3
Source File: DialogHelper.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public static void startRecordingWithProgressDialog(final String filename,
                                                    final String filterQuery, final String logLevel, final Runnable onPostExecute, final Context context) {

    final MaterialDialog progressDialog = new MaterialDialog.Builder(context)
            .title(R.string.dialog_please_wait)
            .content(R.string.dialog_initializing_recorder)
            .progress(true, -1)
            .build();

    progressDialog.setCancelable(false);
    progressDialog.setCanceledOnTouchOutside(false);

    final Handler handler = new Handler(Looper.getMainLooper());
    progressDialog.show();
    new Thread(new Runnable() {
        @Override
        public void run() {
            ServiceHelper.startBackgroundServiceIfNotAlreadyRunning(context, filename, filterQuery, logLevel);
            handler.post(new Runnable() {
                @Override
                public void run() {
                    if (progressDialog.isShowing()) {
                        progressDialog.dismiss();
                    }
                    if (onPostExecute != null) {
                        onPostExecute.run();
                    }
                }
            });
        }
    }).start();

}
 
Example 4
Source File: CommonUtil.java    From homeassist with Apache License 2.0 5 votes vote down vote up
public static MaterialDialog getProgressDialog(Context context) {
    MaterialDialog dialog = new MaterialDialog.Builder(context)
            //.title("progress_dialog")
            .content(context.getString(R.string.progress_wait))
            .progress(true, 0)
            .progressIndeterminateStyle(false)
            .build();
    dialog.setCancelable(false); //BackButton
    dialog.setCanceledOnTouchOutside(false); //Outside Touch
    return dialog;
    //dialog.show();
}
 
Example 5
Source File: DialogHelper.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public static void startRecordingWithProgressDialog(final String filename,
                                                    final String filterQuery, final String logLevel, final Runnable onPostExecute, final Context context) {

    final MaterialDialog progressDialog = new MaterialDialog.Builder(context)
            .title(R.string.dialog_please_wait)
            .content(R.string.dialog_initializing_recorder)
            .progress(true, -1)
            .build();

    progressDialog.setCancelable(false);
    progressDialog.setCanceledOnTouchOutside(false);

    final Handler handler = new Handler(Looper.getMainLooper());
    progressDialog.show();
    new Thread(new Runnable() {
        @Override
        public void run() {
            ServiceHelper.startBackgroundServiceIfNotAlreadyRunning(context, filename, filterQuery, logLevel);
            handler.post(new Runnable() {
                @Override
                public void run() {
                    if (progressDialog.isShowing()) {
                        progressDialog.dismiss();
                    }
                    if (onPostExecute != null) {
                        onPostExecute.run();
                    }
                }
            });
        }
    }).start();

}
 
Example 6
Source File: IntentChooserFragment.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity());
    builder.customView(R.layout.fragment_intent_chooser, false);
    builder.typeface(
            TypefaceHelper.getMedium(getActivity()),
            TypefaceHelper.getRegular(getActivity()));
    builder.positiveText(android.R.string.cancel);

    MaterialDialog dialog = builder.build();
    dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(view -> {
        if (mAdapter == null || mAdapter.isAsyncTaskRunning()) return;

        if (CandyBarApplication.sZipPath != null) {
            File file = new File(CandyBarApplication.sZipPath);
            if (file.exists()) {
                if (file.delete()) {
                    LogUtil.e(String.format("Intent chooser cancel: %s deleted", file.getName()));
                }
            }
        }

        RequestFragment.sSelectedRequests = null;
        CandyBarApplication.sRequestProperty = null;
        CandyBarApplication.sZipPath = null;
        dialog.dismiss();
    });
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
    setCancelable(false);

    mIntentList = (ListView) dialog.findViewById(R.id.intent_list);
    mNoApp = (TextView) dialog.findViewById(R.id.intent_noapp);
    return dialog;
}
 
Example 7
Source File: DialogHelper.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
public static void startRecordingWithProgressDialog(final String filename,
                                                    final String filterQuery, final String logLevel, final Runnable onPostExecute, final Context context) {

    final MaterialDialog progressDialog = new MaterialDialog.Builder(context)
            .title(R.string.dialog_please_wait)
            .content(R.string.dialog_initializing_recorder)
            .progress(true, -1)
            .build();

    progressDialog.setCancelable(false);
    progressDialog.setCanceledOnTouchOutside(false);

    final Handler handler = new Handler(Looper.getMainLooper());
    progressDialog.show();
    new Thread(() -> {
        ServiceHelper.startBackgroundServiceIfNotAlreadyRunning(context, filename, filterQuery, logLevel);
        handler.post(() -> {
            if (progressDialog.isShowing()) {
                progressDialog.dismiss();
            }
            if (onPostExecute != null) {
                onPostExecute.run();
            }
        });
    }).start();

}
 
Example 8
Source File: DialogsUtils.java    From q-municate-android with Apache License 2.0 5 votes vote down vote up
public static void disableCancelableDialog(MaterialDialog materialDialog) {
    // Disable the back button
    DialogInterface.OnKeyListener keyListener = new DialogInterface.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            return keyCode == KeyEvent.KEYCODE_BACK;
        }
    };
    materialDialog.setOnKeyListener(keyListener);

    materialDialog.setCanceledOnTouchOutside(false);
}
 
Example 9
Source File: AbstractDialog.java    From 920-text-editor-v2 with Apache License 2.0 4 votes vote down vote up
protected void handleDialog(MaterialDialog dlg) {
    dlg.setCanceledOnTouchOutside(false);
    dlg.setCancelable(true);
}