List of usage examples for android.support.v4.app FragmentActivity getSupportFragmentManager
public FragmentManager getSupportFragmentManager()
From source file:net.simonvt.fragmentstack.FragmentStack.java
private FragmentStack(FragmentActivity activity, int containerId, Callback callback) { this.activity = activity; fragmentManager = activity.getSupportFragmentManager(); this.containerId = containerId; this.callback = callback; handler = new Handler(); }
From source file:org.goodev.discourse.utils.ImageLoader.java
/** * Creates an ImageLoader with Bitmap memory cache. No default placeholder image will be shown while the image is being fetched and * loaded.//from w w w .j av a 2 s . com */ private ImageLoader(FragmentActivity activity) { super(newRequestQueue(activity), BitmapCache.getInstance(activity.getSupportFragmentManager())); mResources = activity.getResources(); }
From source file:it.mb.whatshare.Dialogs.java
/** * Shows a dialog informing the user that the action she's trying to perform * requires an Internet connection which is not available at the moment. * /*ww w .j a v a 2 s .c o m*/ * @param activity * the caller activity * @param whyItsNeeded * the resource ID within <tt>strings.xml</tt> that explains to * the user why an Internet connection is needed by the operation * @param finishActivityOnOk * whether the caller activity must be {@link Activity#finish()} * 'ed after the user hides the dialog */ public static void noInternetConnection(final FragmentActivity activity, final int whyItsNeeded, final boolean finishActivityOnOk) { new PatchedDialogFragment() { public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder; if (finishActivityOnOk) { builder = getNoUiBuilder(activity); } else { builder = getBuilder(activity); } builder.setMessage(getString(R.string.no_internet_connection, getString(whyItsNeeded))); Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(!finishActivityOnOk); return dialog; } }.show(activity.getSupportFragmentManager(), "no_internet"); }
From source file:com.owncloud.android.files.FileMenuFilter.java
private boolean anyFileVideoPreviewing() { final FragmentActivity activity = (FragmentActivity) mContext; Fragment secondFragment = activity.getSupportFragmentManager().findFragmentByTag(TAG_SECOND_FRAGMENT); boolean videoPreviewing = false; if (secondFragment instanceof PreviewVideoFragment) { for (int i = 0; !videoPreviewing && i < mFiles.size(); i++) { videoPreviewing = ((PreviewVideoFragment) secondFragment).getFile().equals(mFiles.get(i)); }/* w w w.ja v a 2 s . co m*/ } return videoPreviewing; }
From source file:net.sarangnamu.common.ui.dlg.DlgCalendar.java
public void show(FragmentActivity act) { Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DATE); dlg = CalendarDatePickerDialog.newInstance(this, year, month, day); if (baseColor != 0) { dlg.setBaseColor(baseColor);//from w w w . j a va2 s. co m } dlg.show(act.getSupportFragmentManager(), "fragment_date_picker_name"); }
From source file:com.kuassivi.october.util.Navigator.java
/** * Pops back to a specific BackStack position. * <p>/*from ww w. j a v a 2s .c o m*/ * It will detach and destroy forwarded Fragments. * * @param index index in the back stack entry */ public void popToStack(int index) { if (!(activity instanceof FragmentActivity)) { throw new RuntimeException("The activity must inherits from FragmentActivity or AppCompatActivity"); } FragmentActivity fragmentActivity = (FragmentActivity) activity; FragmentManager fragmentManager = fragmentActivity.getSupportFragmentManager(); /* * The method isFinishing() prevents to load a Fragment * when the activity is going to be killed or destroyed. */ if (fragmentManager == null || fragmentActivity.isFinishing()) { return; } final int firstFragmentCount = 1; int backStackCount = fragmentManager.getBackStackEntryCount(); if (backStackCount <= firstFragmentCount) { fragmentActivity.finish(); } else { if (index > 0) { List<Fragment> fragments = fragmentManager.getFragments(); this.fragment = fragments.get(index - 1); fragmentManager.popBackStackImmediate(index, FragmentManager.POP_BACK_STACK_INCLUSIVE); } } }
From source file:com.kuassivi.october.util.Navigator.java
/** * Pops back with some specific fragment arguments. * * @param clazz The fragment class * @param args Arguments to update into the Fragment * @param clearArguments if true clear the current Fragment arguments *///from w w w . j a v a 2s. c om public void popToFragment(@NonNull Class<?> clazz, Bundle args, boolean clearArguments) { if (!(activity instanceof FragmentActivity)) { throw new RuntimeException("The activity must inherits from FragmentActivity or AppCompatActivity"); } FragmentActivity fragmentActivity = (FragmentActivity) activity; FragmentManager fragmentManager = fragmentActivity.getSupportFragmentManager(); /* * The method isFinishing() prevents to load a Fragment * when the activity is going to be killed or destroyed. */ if (fragmentManager == null || fragmentActivity.isFinishing()) { return; } List<Fragment> fragments = fragmentManager.getFragments(); int index; for (index = 0; index < fragments.size(); index++) { Fragment frag = fragments.get(index); if (frag.getClass().equals(clazz)) { if (args != null && args.size() > 0 && frag.getArguments() == null) { throw new IllegalArgumentException("Fragment constructor must call super()"); } if (frag.getArguments() != null && args != null) { if (clearArguments) { frag.getArguments().clear(); } frag.getArguments().putAll(args); } this.fragment = frag; popToStack(index + 1); break; } } }
From source file:com.frostwire.android.gui.adapters.PeerListAdapter.java
public PeerListAdapter(final FragmentActivity activity, List<Peer> peers) { super(activity, R.layout.view_peer_list_item, peers); howtoShareClickListener = new OnClickListener() { public void onClick(View v) { ShareIndicationDialog dlg = new ShareIndicationDialog(); dlg.show(activity.getSupportFragmentManager()); }//from www . ja v a2s . c om }; }
From source file:org.goodev.discourse.utils.ImageLoader.java
/** * Creates an ImageLoader with Bitmap memory cache and a default placeholder image while the image is being fetched and loaded. *//*from w ww .ja v a 2 s . c om*/ private ImageLoader(FragmentActivity activity, int defaultPlaceHolderResId) { super(newRequestQueue(activity), BitmapCache.getInstance(activity.getSupportFragmentManager())); mResources = activity.getResources(); mPlaceHolderDrawables = new ArrayList<Drawable>(1); mPlaceHolderDrawables .add(defaultPlaceHolderResId == -1 ? null : mResources.getDrawable(defaultPlaceHolderResId)); }
From source file:com.kuassivi.october.util.Navigator.java
/** * Prepares a Fragment to be committed.//from w w w . j a va 2 s . co m * * @param resourceId id for the fragment container * @param fragment Fragment to be loaded on the container * @param animate whether it must be animated * @param addToBackStack the BackStack string tag */ @Nullable private FragmentTransaction prepareFragment(@IdRes int resourceId, @NonNull Fragment fragment, boolean animate, String addToBackStack) { if (resourceId <= 0) { throw new RuntimeException("You must supply a resource id for the Fragment Container"); } if (!(activity instanceof FragmentActivity)) { throw new RuntimeException("The activity must inherits from FragmentActivity or AppCompatActivity"); } FragmentActivity fragmentActivity = (FragmentActivity) activity; FragmentManager fragmentManager = fragmentActivity.getSupportFragmentManager(); /* * The method isFinishing() prevents to load a Fragment * when the activity is going to be killed or destroyed. */ if ((fragmentManager == null || fragmentActivity.isFinishing())) { return null; } @SuppressLint("CommitTransaction") FragmentTransaction ft = fragmentManager.beginTransaction(); if (animate && animations.length > 0) { if (animations.length == 2) { ft.setCustomAnimations(animations[0], animations[1]); } else { ft.setCustomAnimations(animations[0], animations[1], animations[2], animations[3]); } } ft.addToBackStack(addToBackStack); this.fragment = fragment; return ft.replace(resourceId, fragment); }