下面列出了android.support.v4.app.DialogFragment#show ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onClick(int payType, String imsi, String price, String currency) {
DialogFragment df = new ProgressDialogFragment();
df.setCancelable(false);
df.show(getSupportFragmentManager(), "pleaseWaitDialog");
PayProductRequestUnitel requestUnitel = new PayProductRequestUnitel();
requestUnitel.setProductId(String.valueOf(aptoideProductId));
requestUnitel.setPayType(String.valueOf(payType));
requestUnitel.setToken(token);
requestUnitel.setImsi(imsi);
requestUnitel.setPrice(price);
requestUnitel.setCurrency(currency);
requestUnitel.setRepo(repo);
requestsetExtra(requestUnitel);
requestUnitel.setRetryPolicy(noRetryPolicy);
spiceManager.execute(requestUnitel, new PurchaseRequestListener());
}
private void parseNonPromptingAndShow(String keyPassphrase, CommandBean command) {
final DialogFragment runCommandDialog = new RunCommandDialog();
final Bundle args = new Bundle();
String cmdString = command.getCommand();
Map<String, String> nonPromptingPlaceholders = parseNonPromptingPlaceholders(command.getCommand(), currentDevice);
for (Map.Entry<String, String> entry : nonPromptingPlaceholders.entrySet()) {
cmdString = cmdString.replace(entry.getKey(), entry.getValue());
}
command.setCommand(cmdString);
args.putSerializable("pi", currentDevice);
args.putSerializable("cmd", command);
if (keyPassphrase != null) {
args.putString("passphrase", keyPassphrase);
}
runCommandDialog.setArguments(args);
runCommandDialog.show(getSupportFragmentManager(), "runCommand");
}
@Override
public void onDisplayPreferenceDialog(Preference preference) {
DialogFragment dialogFragment = null;
if (preference instanceof TimePreference) {
dialogFragment = new TimePreferenceDialogFragmentCompat();
Bundle bundle = new Bundle(1);
bundle.putString("key", preference.getKey());
dialogFragment.setArguments(bundle);
}
// Show dialog
if (dialogFragment != null) {
dialogFragment.setTargetFragment(this, 0);
dialogFragment.show(getChildFragmentManager(), TAG_FRAGMENT_DIALOG);
} else {
super.onDisplayPreferenceDialog(preference);
}
}
@Override
public void onLongClickDialogSelection(Photoset photoset, int which) {
Log.d(TAG, "onLongClickDialogSelection()");
FragmentTransaction ft =
mActivity.getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(android.R.anim.fade_in,
android.R.anim.fade_out);
if (photoset != null) {
Fragment prev = mActivity.getSupportFragmentManager()
.findFragmentByTag(AddToPhotosetDialogFragment.TAG);
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
DialogFragment newFragment =
AddToPhotosetDialogFragment.newInstance(photoset);
newFragment.show(ft, AddToPhotosetDialogFragment.TAG);
} else {
Log.e(TAG, "onLongClickDialogSelection: photoset is null");
}
}
protected void performAction (WifiAuthenticator.AuthAction action) {
if (action == WifiAuthenticator.AuthAction.DEFAULT)
return;
if (authParams.authAction != action && isAlwaysDoThat()) {
authParams.authAction = action;
wifiAuth.storeAuthAction(action);
}
switch (action) {
case BROWSER :
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url.toURI().toString())));
} catch (URISyntaxException e) { }
finish();
break;
case IGNORE :
if (authParams.wifiAction.perform(this))
finish();
else {
DialogFragment dialogDiableWifi = new DisableWifiDialogFragment();
dialogDiableWifi.show (getSupportFragmentManager(),"DisableWifiDialogFragment");
}
break;
default:
break;
}
}
public static void showOtherAppsDialog(@NonNull FragmentManager fm) {
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag(TAG);
if (prev != null) {
ft.remove(prev);
}
try {
DialogFragment dialog = OtherAppsFragment.newInstance();
dialog.show(ft, TAG);
} catch (IllegalStateException | IllegalArgumentException ignored) {}
}
private void showDialogDetail(String name) {
SqliteStorageManager storage = new SqliteStorageManager();
StringBuilder sb = new StringBuilder("This sensor is used by the following Virtual Sensors:\n");
for (String s : storage.getVSfromSource(name)) {
sb.append(" - ").append(s).append("\n");
}
DialogFragment newFragment = DetailedDataFragment.newInstance(sb.toString());
newFragment.show(((FragmentActivity) context).getSupportFragmentManager(), "dialog");
}
public static void show(@NonNull final Context context,
@NonNull final Class<? extends DeleteItemDialogFragment> tClass,
@NonNull final FragmentManager fragmentManager,
@NonNull final String tag,
final long targetId,
@Nullable final String targetName) {
final DialogFragment f = (DialogFragment) Fragment.instantiate(context,
tClass.getCanonicalName(), createArguments(targetId, targetName));
f.show(fragmentManager, tag);
}
private void showEndGameDialog() {
DialogFragment endGameDialog = new EndGameDialogFragment();
Bundle args = new Bundle();
args.putInt("steps", game.getSteps());
args.putBoolean("game_won", game.checkWin());
args.putString("seed", game.getSeed());
endGameDialog.setArguments(args);
endGameDialog.show(getSupportFragmentManager(), "EndGameDialog");
return;
}
/**
* Builds and displays a licenses fragment with no Close button. Requires
* "/res/raw/licenses.html" and "/res/layout/licenses_fragment.xml" to be
* present.
*
* @param fm A fragment manager instance used to display this LicensesFragment.
*/
public static void displayLicensesFragment(FragmentManager fm) {
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag(FRAGMENT_TAG);
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
// Create and show the dialog.
DialogFragment newFragment = LicensesFragment.newInstance();
newFragment.show(ft, FRAGMENT_TAG);
}
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof ShaderListPreference) {
DialogFragment f = ShaderListPreferenceDialogFragment
.newInstance(preference.getKey());
f.setTargetFragment(this, 0);
f.show(getFragmentManager(),
"ShaderListPreferenceDialogFragment");
return;
}
super.onDisplayPreferenceDialog(preference);
}
@Override
// from ItemFragment
public void onListItemClickFragmentInteraction(Item item) {
DialogFragment myDialog = ItemActionListFragment.newInstance(item.getItemId().toString());
// for API >= 23 the title is disable by default -- we set a style that enables it
myDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.ItemActionListDialogFragment);
myDialog.show(getSupportFragmentManager(), getString(R.string.item_action_list_dialog_fragment_tag));
}
public static void showDialog(IBricksListDialogCaller bricksListDialogCaller, String dialogId,
String[] brickNames, Bundle args) {
FragmentTransaction ft = bricksListDialogCaller.getSupportFragmentManager().beginTransaction();
Fragment prev = bricksListDialogCaller.getSupportFragmentManager().findFragmentByTag(TAG);
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
// Create and show the dialog.
DialogFragment newFragment = BricksListDialogFragment.newInstance(dialogId, brickNames, args);
newFragment.show(ft, TAG);
}
public static void forceShowDialog(FragmentActivity activity, DialogFragment dialogFragment) {
try {
dialogFragment.show(activity.getSupportFragmentManager(), "");
activity.getSupportFragmentManager().executePendingTransactions();
} catch (Exception ignored) {
}
}
@Override
public void onMissedClick(View v) {
super.onMissedClick(v);
AlertDialog alert;
if (v.equals(measuredFGView)) {
alert = alertBuilder.editTextFloatAlert(measuredFGViewText, measuredFGViewTitle).create();
}
else if (v.equals(measuredOGView)) {
alert = alertBuilder.editTextFloatAlert(measuredOGViewText, measuredOGViewTitle).create();
}
else if (v.equals(measuredBatchSizeView)) {
alert = alertBuilder.editTextFloatAlert(measuredBatchSizeViewText,
measuredBatchSizeViewTitle).create();
}
else if (v.equals(brewDateView)) {
// Show the brew date picker and return.
DialogFragment newFragment = new DatePickerFragment();
Bundle args = new Bundle();
newFragment.setArguments(args);
newFragment.show(this.getSupportFragmentManager(), "datePicker");
return;
}
else {
Log.d("EditRecipeActivity", "onMissedClick did not handle the clicked view");
return; // In case its none of those views...
}
// Force keyboard open and show popup
alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
alert.show();
}
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof ChameleonMiniSlotPickerPreference) {
DialogFragment dialogFragment =
new ChameleonMiniSlotPickerPreference.NumberPickerFragment();
final Bundle b = new Bundle();
b.putString("key", preference.getKey());
dialogFragment.setArguments(b);
dialogFragment.show(this.getChildFragmentManager(),
"settings_dialog");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
private void showAddConnection() {
DialogFragment fragment = ConnectionEditDialogFragment.newInstance(0);
fragment.show(getSupportFragmentManager(), null);
}
public void showDatePickerDialog(View v) {
DialogFragment fragment = DatePickerFragment.newInstance(this, mSelectedYear,
mSelectedMonth, mSelectedDayOfMonth);
fragment.show(getSupportFragmentManager(), "DatePicker");
}
private void editCollection() {
DialogFragment fragment = CollectionEditDialogFragment.newInstance(mCollectionIndex);
fragment.show(getFragmentManager(), null);
}
public void showListDialog() {
// Create an instance of the dialog fragment and show it
DialogFragment dialog = new ListDialog();
dialog.show(getSupportFragmentManager(), "ListDialogFragment");
}