List of usage examples for android.support.v4.app FragmentActivity getSupportFragmentManager
public FragmentManager getSupportFragmentManager()
From source file:jahirfiquitiva.iconshowcase.dialogs.WallpaperDialog.java
private static void showBase(final FragmentActivity context, final String url, final WallpaperEvent.Step step) { Fragment frag = context.getSupportFragmentManager().findFragmentByTag(TAG); if (frag != null) ((WallpaperDialog) frag).dismiss(); WallpaperDialog.newInstance(url, step).show(context.getSupportFragmentManager(), TAG); }
From source file:org.kaaproject.kaa.demo.photoframe.util.Utils.java
public static void addBackStackFragment(FragmentActivity activity, Fragment fragment, String tag) { if (activity == null) { Log.e(TAG, "Unable pop fragment. Invalid args."); return;/*from w w w . j a v a 2s. c om*/ } FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.container, fragment, tag); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.addToBackStack(tag); ft.commit(); }
From source file:im.neon.activity.MXCActionBarActivity.java
/** * Dismiss any opened dialog./*from w ww. j a v a 2 s . c o m*/ * @param activity the parent activity. */ public static void dismissDialogs(FragmentActivity activity) { // close any opened dialog FragmentManager fm = activity.getSupportFragmentManager(); java.util.List<android.support.v4.app.Fragment> fragments = fm.getFragments(); if (null != fragments) { for (Fragment fragment : fragments) { if (fragment instanceof DialogFragment) { ((DialogFragment) fragment).dismissAllowingStateLoss(); } } } }
From source file:org.kaaproject.kaa.demo.photoframe.util.Utils.java
public static void replaceFragment(FragmentActivity activity, Fragment fragment, String tag) { if (activity == null) { Log.e(TAG, "Unable to replace fragment. Invalid args."); return;//www .j av a 2 s . c om } FragmentManager fm = activity.getSupportFragmentManager(); fm.beginTransaction().replace(R.id.container, fragment, tag).commit(); }
From source file:siarhei.luskanau.gps.tracker.free.ui.progress.ProgressDialogFragment.java
public static void show(FragmentActivity activity, CharSequence title, CharSequence message, String refreshAction) {//ww w .ja v a 2 s . co m FragmentManager fragmentManager = activity.getSupportFragmentManager(); Fragment fragment = fragmentManager.findFragmentByTag(TAG); if (fragment != null) { if (fragment instanceof ProgressDialogFragment) { ((ProgressDialogFragment) fragment).updateProgressDialog(title, message, refreshAction); } } else { newInstance(title, message, refreshAction).show(fragmentManager, TAG); } }
From source file:com.bdevlin.apps.utils.HelpUtils.java
public static void showOpenSourceLicenses(FragmentActivity activity) { FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog_licenses"); if (prev != null) { ft.remove(prev);//from w ww .j a v a2 s.c o m } ft.addToBackStack(null); new OpenSourceLicensesDialog().show(ft, "dialog_licenses"); }
From source file:com.hpush.app.fragments.AboutDialogFragment.java
/** * To open showing open source licenses. * * @param activity//from w w w . jav a 2s . c o m * Host {@link android.support.v4.app.FragmentActivity}. */ private static void showOpenSourceLicenses(FragmentActivity activity) { FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog_licenses"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); new OpenSourceLicensesDialog().show(ft, "dialog_licenses"); }
From source file:com.hpush.app.fragments.AboutDialogFragment.java
/** * Dialog to open showing the "End User License Agreement". * * @author Xinyue Zhao// www. j a v a 2s. c om */ public static void showEula(FragmentActivity activity) { FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog_eula"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); new EulaDialog().show(ft, "dialog_eula"); }
From source file:com.github.michalbednarski.intentslab.valueeditors.framework.ChildFragmentWorkaround.java
/** * Start an activity for result on fragment * * Use this instead of standard startActivityForResult on child fragments *//*w ww .j av a 2 s .c o m*/ public static void startActivityForResultFromFragment(Fragment fragment, Intent intent, int requestCode) { FragmentActivity activity = fragment.getActivity(); FragmentManager topFragmentManager = activity.getSupportFragmentManager(); FragmentManager fragmentManager = fragment.getFragmentManager(); // No workaround needed? if (topFragmentManager == fragmentManager) { fragment.startActivityForResult(intent, requestCode); return; } DeliverResultInfo deliverInfo = new DeliverResultInfo(fragment, requestCode); // Create instance ChildFragmentWorkaround instance = (ChildFragmentWorkaround) topFragmentManager.findFragmentByTag(TAG_F); if (instance == null) { instance = new ChildFragmentWorkaround(); instance.mNextSendIntent = intent; instance.mNextSendDeliverInfo = deliverInfo; topFragmentManager.beginTransaction().add(instance, TAG_F).commit(); } else { instance.doStartActivity(intent, deliverInfo); } }
From source file:com.github.fi3te.iliasdownloader.view.util.MenuItemSelectedUtil.java
public static boolean onOptionsItemSelected(final FragmentActivity activity, MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.coursesItem: FragmentManager fm = activity.getSupportFragmentManager(); Fragment loadCoursesTask = new LoadCoursesDialogFragment(); fm.beginTransaction().add(loadCoursesTask, IliasActivity.TASK_FRAGMENT_TAG).commit(); fm.executePendingTransactions(); return true; case R.id.licencesItem: activity.startActivity(new Intent(activity, LicensesActivity.class)); return true; case R.id.imprintItem: DialogUtil.showImprint(activity); return true; case R.id.aboutItem: String version = null;/*from w w w .j av a 2 s . c o m*/ try { PackageInfo packageInfo = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0); version = packageInfo.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } final String v = (version == null) ? "" : (" " + version); new MaterialDialog.Builder(activity).icon(activity.getResources().getDrawable(R.mipmap.ic_launcher)) .title(activity.getResources().getString(R.string.about)) .content(activity.getResources().getString(R.string.app_name) + ((version != null) ? (" " + version) : "") + "\n" + "Fiete Wennier" + "\n" + "https://github.com/fi3te/ILIASDownloaderAndroid") .positiveText(activity.getResources().getString(R.string.support)) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "fiete.wennier@gmail.com", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, activity.getResources().getString(R.string.app_name) + v); activity.startActivity(Intent.createChooser(emailIntent, "E-Mail")); dialog.cancel(); } }).show(); return true; } return false; }