List of usage examples for android.support.v4.app Fragment getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
public static boolean isFragmentAdded(FragmentManager fragmentManager, Fragment fragment) { Fragment fragmentByTag = fragmentManager.findFragmentByTag(fragment.getClass().getSimpleName()); return !(fragmentByTag == null); }
From source file:Main.java
public static void startFragment(FragmentManager fm, Fragment fragment, int resId) { Fragment mFragment = fm.findFragmentByTag(fragment.getClass().getName()); FragmentTransaction ft = fm.beginTransaction(); if (mFragment == null) { ft.add(resId, fragment, fragment.getClass().getName()); }/* ww w.ja va 2s. c om*/ ft.show(fragment); ft.commitAllowingStateLoss(); }
From source file:Main.java
public static void loadFragmentNoAnimation(int id, FragmentManager fragmentManager, Fragment fragment) { fragmentManager.beginTransaction().add(id, fragment, fragment.getClass().getSimpleName()).commit(); }
From source file:Main.java
public static void replaceFragmentNoAnimation(int id, FragmentManager fragmentManager, Fragment fragment) { fragmentManager.beginTransaction().replace(id, fragment, fragment.getClass().getSimpleName()).commit(); }
From source file:Main.java
public static void addFragment(FragmentManager manager, Fragment fragment, int containerViewId) { manager.beginTransaction().add(containerViewId, fragment, fragment.getClass().getSimpleName()).commit(); }
From source file:Main.java
public static void replaceFragment(FragmentManager manager, Fragment fragment, int containerViewId) { manager.beginTransaction().replace(containerViewId, fragment, fragment.getClass().getSimpleName()).commit(); }
From source file:com.jetradar.multibackstack.BackStackEntry.java
@NonNull public static BackStackEntry create(@NonNull FragmentManager fm, @NonNull Fragment f) { String fname = f.getClass().getName(); SavedState state = fm.saveFragmentInstanceState(f); Bundle args = f.getArguments();/*from www . java2 s .c o m*/ return new BackStackEntry(fname, state, args); }
From source file:com.example.library.inject.InjectUtil.java
public static void inject(Fragment target, View view) { init(view.getContext());//from w w w .ja v a 2s . c o m Class<? extends Fragment> targetClazz = target.getClass(); InjectViewUtil.injectField(targetClazz, target, view); InjectEventUtil.injectMethod(targetClazz, target, view); }
From source file:com.thelastcrusade.soundstream.util.EteUtils.java
/** * Returns a boolean as to whether the given fragment is visible or not. * // ww w.j a v a2s.c om * Assumes that the current activity must be core activity (currently our only activity), * and that there is only one instance of each type of fragment ever in existance. Currently * these assumptions hold true, but may vary in the future. * * @param solo - The solenium object from the robotium testing architecture * @param fragment - The * @return Whether the specified fragment is visible or not * @throws IllegalStateException - If the activity has switched to something other than the core activity */ public static boolean isFragmentVisible(Solo solo, Class<? extends Fragment> fragment) throws IllegalStateException { // If we switched to another activity something broke if (!(solo.getCurrentActivity() instanceof CoreActivity)) { throw new IllegalStateException("Current Activity isn't CoreActivity, as expected"); } CoreActivity core = (CoreActivity) solo.getCurrentActivity(); // Condition for if the fragment is visible or not, to be updated with logic below boolean vis = false; for (Fragment f : core.getAttachedFragments()) { if (f.getClass().equals(fragment)) { // The menu fragment is always listed as visible, even when it's // not on screen. This uses the menu's own method to determine // visibility. if (f.getClass().equals(MenuFragment.class)) { vis |= core.getSlidingMenu().isMenuShowing(); } else { // Set visiblity to true only if the fragment is listed as // visible, and not currently being removed (which will make // it not visible shortly) vis |= f.isVisible() && !f.isRemoving(); } } } // Return overall visiblity condition for the given fragment return vis; }
From source file:Main.java
public static void addFragment(FragmentManager manager, @IdRes int layout, Fragment fragment, int transitionStyle) { FragmentTransaction fragmentTransaction = manager.beginTransaction(); fragmentTransaction.add(layout, fragment, fragment.getClass().getSimpleName()); fragmentTransaction.setTransition(transitionStyle); //fragmentTransaction.addToBackStack(fragment.getClass().getSimpleName()); fragmentTransaction.commit();//w ww . j a va 2s . c o m manager.executePendingTransactions(); }