Java Code Examples for com.gianlu.commonutils.dialogs.DialogUtils#showDialog()
The following examples show how to use
com.gianlu.commonutils.dialogs.DialogUtils#showDialog() .
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: AskPermission.java From CommonUtils with Apache License 2.0 | 6 votes |
public static void ask(@NonNull final FragmentActivity activity, @NonNull final String permission, @NonNull final Listener listener) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { listener.permissionGranted(permission); return; } if (ContextCompat.checkSelfPermission(activity, permission) == PackageManager.PERMISSION_GRANTED) { listener.permissionGranted(permission); } else { if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) { MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(activity); listener.askRationale(builder); builder.setPositiveButton(android.R.string.ok, (dialog, which) -> request(activity, permission, listener)); DialogUtils.showDialog(activity, builder); } else { request(activity, permission, listener); } } }
Example 2
Source File: GamesFragment.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 6 votes |
private void askForPassword(@NonNull OnPassword listener) { if (getContext() == null) { listener.onPassword(null); return; } final EditText password = new EditText(getContext()); password.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); builder.setTitle(R.string.gamePassword) .setView(password) .setNegativeButton(android.R.string.cancel, null) .setPositiveButton(R.string.submit, (dialog, which) -> listener.onPassword(password.getText().toString())); DialogUtils.showDialog(getActivity(), builder); }
Example 3
Source File: OngoingGameFragment.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 6 votes |
public void goBack() { if (isVisible() && DialogUtils.hasVisibleDialog(getActivity())) { DialogUtils.dismissDialog(getActivity()); return; } if (getContext() == null) return; MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); builder.setTitle(R.string.leaveGame) .setMessage(R.string.leaveGame_confirm) .setPositiveButton(android.R.string.yes, (dialog, which) -> leaveGame()) .setNegativeButton(android.R.string.no, null); DialogUtils.showDialog(getActivity(), builder); }
Example 4
Source File: UserInfoDialog.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 6 votes |
public static void loadAndShow(@NonNull RegisteredPyx pyx, @NonNull FragmentActivity activity, @NonNull String name) { DialogUtils.showDialog(activity, DialogUtils.progressDialog(activity, R.string.loading)); pyx.request(PyxRequests.whois(name), activity, new Pyx.OnResult<WhoisResult>() { @Override public void onDone(@NonNull WhoisResult result) { DialogUtils.dismissDialog(activity); DialogUtils.showDialog(activity, UserInfoDialog.get(result), null); } @Override public void onException(@NonNull Exception ex) { DialogUtils.dismissDialog(activity); Log.e(TAG, "Failed whois.", ex); Toaster.with(activity).message(R.string.failedLoading).show(); } }); }
Example 5
Source File: DiagnosticFragment.java From DNSHero with GNU General Public License v3.0 | 5 votes |
private void showHelpDialog() { if (getContext() == null) return; AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(R.string.help) .setView(R.layout.dialog_diagnostic_help) .setPositiveButton(android.R.string.ok, null); DialogUtils.showDialog(getActivity(), builder); }
Example 6
Source File: GamesFragment.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
private void spectateGame(final int gid, @Nullable String password) { if (getContext() == null) return; DialogUtils.showDialog(getActivity(), DialogUtils.progressDialog(getContext(), R.string.loading)); pyx.request(PyxRequests.spectateGame(gid, password), getActivity(), new Pyx.OnResult<GamePermalink>() { @Override public void onDone(@NonNull GamePermalink game) { if (handler != null) handler.onParticipatingGame(game); DialogUtils.dismissDialog(getActivity()); AnalyticsApplication.sendAnalytics(Utils.ACTION_SPECTATE_GAME); } @Override public void onException(@NonNull Exception ex) { DialogUtils.dismissDialog(getActivity()); Log.e(TAG, "Failed spectating game.", ex); if (ex instanceof PyxException) { switch (((PyxException) ex).errorCode) { case "wp": showToast(Toaster.build().message(R.string.wrongPassword)); return; case "gf": showToast(Toaster.build().message(R.string.gameFull)); return; } } showToast(Toaster.build().message(R.string.failedSpectating)); } }); }
Example 7
Source File: GamesFragment.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
private void joinGame(int gid, @Nullable String password) { if (getContext() == null) return; DialogUtils.showDialog(getActivity(), DialogUtils.progressDialog(getContext(), R.string.loading)); pyx.request(PyxRequests.joinGame(gid, password), getActivity(), new Pyx.OnResult<GamePermalink>() { @Override public void onDone(@NonNull GamePermalink game) { if (handler != null) handler.onParticipatingGame(game); DialogUtils.dismissDialog(getActivity()); AnalyticsApplication.sendAnalytics(Utils.ACTION_JOIN_GAME); } @Override public void onException(@NonNull Exception ex) { Log.e(TAG, "Failed joining game.", ex); DialogUtils.dismissDialog(getActivity()); if (ex instanceof PyxException) { switch (((PyxException) ex).errorCode) { case "wp": showToast(Toaster.build().message(R.string.wrongPassword)); return; case "gf": showToast(Toaster.build().message(R.string.gameFull)); return; } } showToast(Toaster.build().message(R.string.failedJoining)); } }); }
Example 8
Source File: OngoingGameFragment.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
private void showPlayers() { if (manager == null || getContext() == null) return; RecyclerView recyclerView = new RecyclerView(getContext()); recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false)); recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL)); recyclerView.setAdapter(new PlayersAdapter(getContext(), manager.players(), this)); MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); builder.setTitle(R.string.playersLabel) .setView(recyclerView) .setPositiveButton(android.R.string.ok, null); DialogUtils.showDialog(getActivity(), builder); }
Example 9
Source File: OngoingGameFragment.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
private void showSpectators() { if (manager == null || getContext() == null) return; Collection<String> spectators = manager.spectators(); SuperTextView text = SuperTextView.html(getContext(), spectators.isEmpty() ? "<i>none</i>" : CommonUtils.join(spectators, ", ")); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics()); text.setPadding(padding, padding, padding, padding); MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); builder.setTitle(R.string.spectatorsLabel) .setView(text) .setPositiveButton(android.R.string.ok, null); DialogUtils.showDialog(getActivity(), builder); }
Example 10
Source File: OngoingGameFragment.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 5 votes |
private void showGameOptions() { if (manager == null || getContext() == null) return; Game.Options options = manager.gameOptions(); if (options == null) return; DialogUtils.showDialog(getActivity(), Dialogs.gameOptions(getContext(), options, pyx.firstLoad())); }
Example 11
Source File: BaseModalBottomSheet.java From CommonUtils with Apache License 2.0 | 4 votes |
public final void show(@Nullable FragmentActivity activity, @NonNull Setup payload) { if (activity == null) return; this.payload = payload; DialogUtils.showDialog(activity, this, null); }
Example 12
Source File: BaseModalBottomSheet.java From CommonUtils with Apache License 2.0 | 4 votes |
public final void show(@Nullable Fragment fragment, @NonNull Setup payload) { if (fragment == null) return; this.payload = payload; DialogUtils.showDialog(fragment, this, null); }
Example 13
Source File: OptionsDialog.java From Aria2App with GNU General Public License v3.0 | 4 votes |
@Override public void onEditOption(@NonNull final Option option) { if (getContext() == null) return; DialogUtils.showDialog(getActivity(), OptionsUtils.getEditOptionDialog(getContext(), option, optionsView.getAdapter())); }
Example 14
Source File: OngoingGameFragment.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 4 votes |
private void editGameOptions() { if (manager == null || getContext() == null) return; DialogUtils.showDialog(getActivity(), EditGameOptionsDialog.get(perm.gid, manager.gameOptions()), null); }