com.afollestad.materialdialogs.DialogAction Java Examples

The following examples show how to use com.afollestad.materialdialogs.DialogAction. 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 Project: candybar   Author: zixpo   File: ReportBugsHelper.java    License: Apache License 2.0 6 votes vote down vote up
public static void prepareReportBugs(@NonNull Context context) {
    MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
    builder.customView(R.layout.dialog_report_bugs, true);
    builder.typeface(
            TypefaceHelper.getMedium(context),
            TypefaceHelper.getRegular(context));
    builder.positiveText(R.string.report_bugs_send);
    builder.negativeText(R.string.close);

    MaterialDialog dialog = builder.build();

    EditText editText = (EditText) dialog.findViewById(R.id.input_desc);
    TextInputLayout inputLayout = (TextInputLayout) dialog.findViewById(R.id.input_layout);

    dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(view -> {
        if (editText.getText().length() > 0) {
            inputLayout.setErrorEnabled(false);
            ReportBugsTask.start(context, editText.getText().toString(), AsyncTask.THREAD_POOL_EXECUTOR);
            dialog.dismiss();
            return;
        }

        inputLayout.setError(context.getResources().getString(R.string.report_bugs_desc_empty));
    });
    dialog.show();
}
 
Example #2
Source Project: Focus   Author: ihewro   File: MJavascriptInterface.java    License: GNU General Public License v3.0 6 votes vote down vote up
@android.webkit.JavascriptInterface
public void openUrl(final String url) {
    new MaterialDialog.Builder(activity)
            .title("即将前往")
            .content("点击「确定」将会访问该链接地址")
            .positiveText("确定")
            .negativeText("取消")
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    WebViewUtil.openLink(url, (Activity) activity);

                }
            })
    .show();
}
 
Example #3
Source Project: Focus   Author: ihewro   File: MJavascriptInterface.java    License: GNU General Public License v3.0 6 votes vote down vote up
@android.webkit.JavascriptInterface
public void openUrl(final String url) {
    new MaterialDialog.Builder(activity)
            .title("即将前往")
            .content("点击「确定」将会访问该链接地址")
            .positiveText("确定")
            .negativeText("取消")
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    WebViewUtil.openLink(url, (Activity) activity);

                }
            })
    .show();
}
 
Example #4
Source Project: GreenBits   Author: greenaddress   File: FailHardActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    final Intent i = getIntent();
    Log.e(TAG, i.getStringExtra("errorTitle") + ':' + i.getStringExtra("errorContent"));

    UI.popup(this, i.getStringExtra("errorTitle"))
              .content(i.getStringExtra("errorContent"))
              .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(final MaterialDialog dlg, final DialogAction which) {
                    final Intent main = new Intent(Intent.ACTION_MAIN);
                    main.addCategory(Intent.CATEGORY_HOME);
                    main.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(main);
                    finish();
                }
              }).build().show();
}
 
Example #5
Source Project: oversec   Author: oversecio   File: IabUtil.java    License: GNU General Public License v3.0 6 votes vote down vote up
public synchronized void doIfFullOrShowPurchaseDialog(final Activity activity, final Runnable okRunnable, final int requestCode) {
    checkFullVersion(new FullVersionListener() {
        @Override
        public void onFullVersion_MAIN_THREAD(boolean isFullVersion) {
            if (isFullVersion) {
                okRunnable.run();
            } else {
                makePurchaseDialog(activity)
                        .onPositive(new MaterialDialog.SingleButtonCallback() {
                            @Override
                            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                showPurchaseActivity(activity, requestCode);
                            }
                        })
                        .show();

            }
        }
    });


}
 
Example #6
Source Project: oversec   Author: oversecio   File: IabUtil.java    License: GNU General Public License v3.0 6 votes vote down vote up
public synchronized void doIfFullOrShowPurchaseDialog(final Fragment fragment, final Runnable okRunnable, final int requestCode) {
    checkFullVersion(new FullVersionListener() {
        @Override
        public void onFullVersion_MAIN_THREAD(boolean isFullVersion) {
            if (isFullVersion) {
                okRunnable.run();
            } else {
                makePurchaseDialog(fragment.getActivity())
                        .onPositive(new MaterialDialog.SingleButtonCallback() {
                            @Override
                            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                showPurchaseActivity(fragment, requestCode);
                            }
                        })
                        .show();

            }
        }
    });

}
 
Example #7
Source Project: PowerFileExplorer   Author: PowerExplorer   File: GeneralDialogCreation.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void showHistoryDialog(final DataUtils dataUtils, Futils utils, final ContentFragment m, AppTheme appTheme) {
     int accentColor = m.activity.getColorPreference().getColor(ColorUsage.ACCENT);
     final MaterialDialog.Builder a = new MaterialDialog.Builder(m.getActivity());
     a.positiveText(R.string.cancel);
     a.positiveColor(accentColor);
     a.negativeText(R.string.clear);
     a.negativeColor(accentColor);
     a.title(R.string.history);
     a.onNegative(new MaterialDialog.SingleButtonCallback() {
	@Override
	public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
		dataUtils.clearHistory();
	}
});
     a.theme(appTheme.getMaterialDialogTheme());

     a.autoDismiss(true);
     HiddenAdapter adapter = new HiddenAdapter(m.getActivity(), m, utils, R.layout.bookmarkrow,
									  toHFileArray(dataUtils.getHistory()), null, true);
     a.adapter(adapter, null);

     MaterialDialog x= a.build();
     adapter.updateDialog(x);
     x.show();
 }
 
Example #8
Source Project: SimpleNews   Author: dlangerenken   File: CategorySelectionFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.share_categories:
            shareCategories(mCategories);
            return true;
        case R.id.restore_categories:
            new MaterialDialog.Builder(getActivity())
                    .title(R.string.restore_categories_title)
                    .content(R.string.restore_categories_message)
                    .positiveText(R.string.restore_categories_yes)
                    .negativeText(R.string.restore_categories_no)
                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                        @Override
                        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                            DatabaseHandler.getInstance().removeAllCategories();
                            PrefUtilities.getInstance().saveLoading(false);
                            onRestore();
                        }
                    }).show();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example #9
Source Project: uPods-android   Author: KKorvin   File: FragmentPlayer.java    License: Apache License 2.0 6 votes vote down vote up
private void askPhoneStatePermissions() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Prefs.getBoolean(PREF_PHONE_PERM_ASKED, false)) {
        Prefs.putBoolean(PREF_PHONE_PERM_ASKED, true);
        new MaterialDialog.Builder(getActivity())
                .title(R.string.phone_state_permissions)
                .content(R.string.phone_state_description)
                .positiveText(R.string.ok)
                .onAny(new MaterialDialog.SingleButtonCallback() {
                    @TargetApi(Build.VERSION_CODES.M)
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        getActivity().requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE}, CODE_PERMISSIONS_PHONE_STATE);
                    }
                }).build().show();
    }
}
 
Example #10
Source Project: Duolingo-Clone   Author: rickpms   File: TSTaskActivity.java    License: MIT License 6 votes vote down vote up
@Override
public void onBackPressed() {

    new MaterialDialog.Builder(this)
            .title("Are you sure about that?")
            .content("All progress in this lesson will be lost.")
            .positiveText("QUIT")
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {

                    progressBarValue = 0;

                    Hawk.put("progressBarValue", progressBarValue);

                    finish();
                }
            })
            .negativeText("CANCEL")
            .show();
}
 
Example #11
Source Project: Duolingo-Clone   Author: rickpms   File: TapPairActivity.java    License: MIT License 6 votes vote down vote up
@Override
public void onBackPressed() {

    new MaterialDialog.Builder(this)
            .title("Are you sure about that?")
            .content("All progress in this lesson will be lost.")
            .positiveText("QUIT")
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {

                    progressBarValue = 0;

                    Hawk.put("progressBarValue", progressBarValue);

                    finish();
                }
            })
            .negativeText("CANCEL")
            .show();
}
 
Example #12
Source Project: Duolingo-Clone   Author: rickpms   File: WordTaskActivity.java    License: MIT License 6 votes vote down vote up
@Override
public void onBackPressed() {

    new MaterialDialog.Builder(this)
            .title("Are you sure about that?")
            .content("All progress in this lesson will be lost.")
            .positiveText("QUIT")
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {

                    progressBarValue = 0;

                    Hawk.put("progressBarValue", progressBarValue);

                    finish();
                }
            })
            .negativeText("CANCEL")
            .show();
}
 
Example #13
Source Project: homeassist   Author: axzae   File: FaultUtil.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("SameParameterValue")
public static void showError(final Context context, String title, String content) {
    new MaterialDialog.Builder(context)
            .cancelable(false)
            .title(title)
            .content(content)
            .positiveText(R.string.button_continue)
            .positiveColorRes(R.color.md_red_500)
            .buttonRippleColorRes(R.color.md_grey_200)
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    dialog.dismiss();
                }
            })
            .show();
}
 
Example #14
Source Project: homeassist   Author: axzae   File: CommonUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void fixDialogKeyboard(final MaterialDialog dialog) {
    //https://github.com/afollestad/material-dialogs/issues/1105
    EditText inputEditText = dialog.getInputEditText();
    if (inputEditText != null) {
        inputEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE) || (actionId == EditorInfo.IME_ACTION_SEARCH)) {
                    View positiveButton = dialog.getActionButton(DialogAction.POSITIVE);
                    if (dialog.getActionButton(DialogAction.POSITIVE).isEnabled()) {
                        positiveButton.callOnClick();
                    } else {
                        return true;
                    }
                }
                return false;
            }
        });
    }
}
 
Example #15
Source Project: FriendBook   Author: z-chu   File: MainPresenter.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void showAppUpdateDialog(final Activity activity, final AppRelease release) {
    new MaterialDialog
            .Builder(activity)
            .title("新版本:"+release.getVersionName())
            .content(release.getReleaseNotes())
            .positiveText("立即下载")
            .negativeText("以后再说")
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    UpdateService.Builder.create(release.getSourceFileUrl()).build(activity);
                }
            })
            .show();

}
 
Example #16
Source Project: FriendBook   Author: z-chu   File: BookcaseFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void showDeleteConfirmDialog() {
    new MaterialDialog
            .Builder(getActivity())
            .title("确认删除")
            .content("真的要将这" + bookcaseAdapter.getSelectedBookTbs().size() + "本书从书架中删除吗?")
            .positiveText("删除")
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    getPresenter().deleteItems(bookcaseAdapter.getSelectedBookTbs());
                    toggleEditMenu();
                    bookcaseAdapter.cancelEdit();
                }
            })
            .negativeText("取消")
            .show();
}
 
Example #17
Source Project: MagicalCamera   Author: fabian7593   File: SharedPreferenceActivity.java    License: Apache License 2.0 6 votes vote down vote up
private View popUpLayout(final int idLayout) {
    MaterialDialog dialog = new MaterialDialog.Builder(this)
            .title(R.string.shared_change_color)
            .customView(idLayout, true)
            .positiveText(R.string.shared_accept)
            .autoDismiss(false)
            .backgroundColor(getResources().getColor(R.color.colorWhite))
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
                    materialDialog.dismiss();
                    materialDialog.cancel();
                }
            })

            .show();

    return dialog.getCustomView();
}
 
Example #18
Source Project: candybar-library   Author: danimahardhika   File: ReportBugsHelper.java    License: Apache License 2.0 6 votes vote down vote up
public static void prepareReportBugs(@NonNull Context context) {
    MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
    builder.customView(R.layout.dialog_report_bugs, true);
    builder.typeface(
            TypefaceHelper.getMedium(context),
            TypefaceHelper.getRegular(context));
    builder.positiveText(R.string.report_bugs_send);
    builder.negativeText(R.string.close);

    MaterialDialog dialog = builder.build();

    EditText editText = (EditText) dialog.findViewById(R.id.input_desc);
    TextInputLayout inputLayout = (TextInputLayout) dialog.findViewById(R.id.input_layout);

    dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(view -> {
        if (editText.getText().length() > 0) {
            inputLayout.setErrorEnabled(false);
            ReportBugsTask.start(context, editText.getText().toString(), AsyncTask.THREAD_POOL_EXECUTOR);
            dialog.dismiss();
            return;
        }

        inputLayout.setError(context.getResources().getString(R.string.report_bugs_desc_empty));
    });
    dialog.show();
}
 
Example #19
Source Project: Orin   Author: aliumujib   File: ClearSmartPlaylistDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    //noinspection unchecked
    final AbsSmartPlaylist playlist = getArguments().getParcelable("playlist");
    int title = R.string.clear_playlist_title;
    //noinspection ConstantConditions
    CharSequence content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist.name));

    return new MaterialDialog.Builder(getActivity())
            .title(title)
            .content(content)
            .positiveText(R.string.clear_action)
            .negativeText(android.R.string.cancel)
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    if (getActivity() == null) {
                        return;
                    }
                    playlist.clear(getActivity());
                }
            })
            .build();
}
 
Example #20
Source Project: bleYan   Author: captain-miao   File: BleDevicesFragment.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void displayPromptForEnablingGPS() {
    final String action = Settings.ACTION_LOCATION_SOURCE_SETTINGS;


    new MaterialDialog.Builder(getActivity())
            .title(R.string.label_request_open_gps_title)
            .content(R.string.label_request_open_gps_content)
            .positiveText(R.string.label_ok)
            .onPositive(new MaterialDialog.SingleButtonCallback() {

                @Override
                public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
                    startActivityForResult(new Intent(action), REQUEST_CODE_OPEN_GPS);
                }
            })
            .negativeText(R.string.label_cancel)
            .cancelable(true)
            .negativeText(R.string.label_cancel)
            .show();
}
 
Example #21
Source Project: APlayer   Author: rRemix   File: ColorChooserDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(View v) {
  if (v.getTag() != null) {
    final String[] tag = ((String) v.getTag()).split(":");
    final int index = Integer.parseInt(tag[0]);
    final MaterialDialog dialog = (MaterialDialog) getDialog();
    final Builder builder = getBuilder();

    if (isInSub()) {
      subIndex(index);
    } else {
      topIndex(index);
      if (mColorsSub != null && index < mColorsSub.length) {
        dialog.setActionButton(DialogAction.NEGATIVE, builder.mBackBtn);
        isInSub(true);
      }
    }

    if (builder.mAllowUserCustom) {
      mSelectedCustomColor = getSelectedColor();
    }
    invalidateDynamicButtonColors();
    invalidate();
  }
}
 
Example #22
Source Project: Walrus   Author: TeamWalrus   File: ComponentDialogFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onComponentChange(Component changedComponent) {
    if (getArguments().getBoolean("editable")) {
        ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(
                component.isValid());
    }

    problemViewGroup.removeAllViews();

    if (!component.getProblems().isEmpty()) {
        problemViewGroup.addView(MultiComponent.createSpacer(getActivity()));

        for (String problem : new TreeSet<>(component.getProblems())) {
            TextView problemMessageView = new TextView(getActivity());
            problemViewGroup.addView(problemMessageView);

            int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2,
                    getActivity().getResources().getDisplayMetrics());
            problemMessageView.setPadding(0, padding, 0, padding);
            problemMessageView.setText(problem);
            problemMessageView.setTextColor(ContextCompat.getColor(getActivity(),
                    android.R.color.holo_red_light));
        }
    }
}
 
Example #23
Source Project: Walrus   Author: TeamWalrus   File: BulkReadCardsDialogFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    cardDataIOView = new CardDataIOView(getActivity());
    cardDataIOView.setDirection(true);

    return new MaterialDialog.Builder(getActivity())
            .title(R.string.bulk_reading_cards)
            .customView(cardDataIOView, false)
            .positiveText(R.string.stop_button)
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog,
                        @NonNull DialogAction which) {
                    BulkReadCardDataOperationRunner runner = getRunner();
                    if (runner != null) {
                        runner.stopReading();
                    }
                }
            })
            .build();
}
 
Example #24
Source Project: Pocket-Plays-for-Twitch   Author: SebastianRask   File: SettingsTwitchChatActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void onClickChatLandScapeWidth(View v) {
	final int landscapeWidth = settings.getChatLandscapeWidth();

	DialogService.getSliderDialog(
			this,
			new MaterialDialog.SingleButtonCallback() {
				@Override
				public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
					settings.setChatLandscapeWidth(landscapeWidth);
					updateSummaries();
				}
			},
			new Slider.OnPositionChangeListener() {
				@Override
				public void onPositionChanged(Slider view, boolean fromUser, float oldPos, float newPos, int oldValue, int newValue) {
					settings.setChatLandscapeWidth(newValue);
					updateSummaries();
				}
			},
			landscapeWidth,
			25,
			60,
			getString(R.string.chat_landscape_width_dialog)
	).show();
}
 
Example #25
Source Project: iGap-Android   Author: RooyeKhat-Media   File: ActivityManageSpaceViewModel.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public void onClickSdkEnable(View view) {

        new MaterialDialog.Builder(context)
                .title(G.context.getResources().getString(R.string.are_you_sure))
                .negativeText(G.context.getResources().getString(R.string.B_cancel))
                .content(G.context.getResources().getString(R.string.change_storage_place))
                .positiveText(G.context.getResources().getString(R.string.B_ok))
                .onPositive(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        isSdkEnable.set(!isSdkEnable.get());

                    }
                }).show();

    }
 
Example #26
Source Project: Ency   Author: Jerry-1123   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 检查更新提示框
 */
@Override
public void showUpdateDialog(final UpdateBean updateBean) {
    if (null != updateBean) {
        new MaterialDialog.Builder(mContext)
                .title(R.string.app_update)
                .content("最新版本:" + updateBean.getVersionShort() + "\n"
                        + "版本大小:" + SystemUtil.getFormatSize(updateBean.getBinary().getFsize()) + "\n"
                        + "更新内容:" + updateBean.getChangelog())
                .negativeText(R.string.no)
                .negativeColorRes(R.color.colorNegative)
                .positiveText(R.string.update)
                .positiveColorRes(R.color.colorPositive)
                .onPositive(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        showMsg(getResources().getString(R.string.start_update));
                        Intent intent = new Intent(mContext, UpdateService.class);
                        intent.putExtra("downloadurl", updateBean.getInstall_url());
                        startService(intent);
                    }
                })
                .show();
    }
}
 
Example #27
Source Project: APKMirror   Author: vojta-horanek   File: MainActivity.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onDownloadRequested(String url, String suggestedFilename, String mimeType, long contentLength, String contentDisposition, String userAgent) {

    if (isWritePermissionGranted()) {
        download(url, suggestedFilename);
    } else {
        new MaterialDialog.Builder(MainActivity.this)
                .title(R.string.write_permission)
                .content(R.string.storage_access)
                .positiveText(R.string.request_permission)
                .negativeText(android.R.string.cancel)
                .onPositive(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        //Request permission
                        ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
                    }
                })
                .show();
    }

}
 
Example #28
Source Project: Fishing   Author: Jude95   File: CommonModel.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void showUpdateDialog(Context ctx,String versionName,String content,String url){
    new MaterialDialog.Builder(ctx)
            .title("新版本 "+versionName)
            .content(content)
            .positiveText("立即升级")
            .negativeText("取消")
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
                    JUtils.Log("Get Start");
                    Intent updateIntent = new Intent(ctx, UpdateService.class);
                    updateIntent.putExtra("title", "空钩正在更新");
                    updateIntent.putExtra("url", url);
                    updateIntent.putExtra("path", findDownLoadDirectory());
                    updateIntent.putExtra("name", ctx.getString(R.string.app_name) + "v" + versionName + ".apk");
                    ctx.startService(updateIntent);
                }
            })
            .show();

}
 
Example #29
Source Project: RetroMusicPlayer   Author: deepshooter   File: ClearSmartPlaylistDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    //noinspection unchecked
    final AbsSmartPlaylist playlist = getArguments().getParcelable("playlist");
    int title = R.string.clear_playlist_title;
    //noinspection ConstantConditions
    CharSequence content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist.name));

    return new MaterialDialog.Builder(getActivity())
            .title(title)
            .content(content)
            .positiveText(R.string.clear_action)
            .negativeText(android.R.string.cancel)
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    if (getActivity() == null) {
                        return;
                    }
                    playlist.clear(getActivity());
                }
            })
            .build();
}
 
Example #30
Source Project: candybar   Author: zixpo   File: IntentChooserFragment.java    License: 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;
}