List of usage examples for android.support.v4.app Fragment getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.cylan.jiafeigou.utils.ActivityUtils.java
public static boolean addFragmentSlideInFromLeft(FragmentManager fragmentManager, Fragment fragment, int containerId) { final String tag = fragment.getClass().getSimpleName(); Fragment f = fragmentManager.findFragmentByTag(tag); if (f != null && f.isVisible()) { return false; }// w w w . j av a2 s .c o m fragmentManager .beginTransaction().setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_out_right, R.anim.slide_out_right) .add(containerId, fragment, tag).addToBackStack(tag).commit(); return true; }
From source file:com.cylan.jiafeigou.utils.ActivityUtils.java
/** * ?fragment/*from ww w. j a v a2 s . c om*/ */ public static void replaceFragmentNoAnimation(int id, FragmentManager fragmentManager, Fragment fragment) { fragmentManager.beginTransaction().replace(id, fragment, fragment.getClass().getSimpleName()).commit(); }
From source file:com.cylan.jiafeigou.utils.ActivityUtils.java
public static boolean addFragmentSlideInFromRight(FragmentManager fragmentManager, Fragment fragment, int containerId, boolean noStack) { final String tag = fragment.getClass().getSimpleName(); Fragment f = fragmentManager.findFragmentByTag(tag); if (f != null && f.isVisible()) { return false; }// www . jav a 2 s . c o m fragmentManager.beginTransaction().setCustomAnimations(R.anim.slide_right_in, R.anim.slide_out_left, R.anim.slide_out_right, R.anim.slide_out_right).add(containerId, fragment, tag).commit(); return true; }
From source file:com.cylan.jiafeigou.utils.ActivityUtils.java
public static boolean addFragmentSlideInFromLeft(FragmentManager fragmentManager, Fragment fragment, int containerId, boolean noStatck) { final String tag = fragment.getClass().getSimpleName(); Fragment f = fragmentManager.findFragmentByTag(tag); if (f != null && f.isVisible()) { return false; }/*w w w . j a va 2 s . c o m*/ fragmentManager.beginTransaction().setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_out_right, R.anim.slide_out_right).add(containerId, fragment, tag).commit(); return true; }
From source file:com.cylan.jiafeigou.utils.ActivityUtils.java
public static boolean addFragmentSlideInFromRight(FragmentManager fragmentManager, Fragment fragment, int containerId, String stackName) { final String tag = fragment.getClass().getSimpleName(); Fragment f = fragmentManager.findFragmentByTag(tag); if (f != null && f.isVisible()) { return false; }/*ww w . ja v a2s . c o m*/ fragmentManager.beginTransaction() .setCustomAnimations(R.anim.slide_right_in, R.anim.slide_out_left, R.anim.slide_out_right, R.anim.slide_out_right) .add(containerId, fragment, tag).addToBackStack(stackName).commitAllowingStateLoss(); return true; }
From source file:cn.bingoogolapple.scaffolding.util.UMAnalyticsUtil.java
/** * MvcFragment handleOnVisibilityChangedToUser * * @param fragment//from ww w . j a v a 2s. c o m * @param isVisibleToUser */ public static void onVisibilityChangedToUser(Fragment fragment, boolean isVisibleToUser) { if (sIsInit) { // ? if (isVisibleToUser) { MobclickAgent.onPageStart(fragment.getClass().getSimpleName()); } else { MobclickAgent.onPageEnd(fragment.getClass().getSimpleName()); } } }
From source file:com.apchernykh.todo.atleap.sample.ui.MainActivity.java
private static void replaceFragmentIfNeeded(FragmentActivity activity, int containerId, Class<? extends Fragment> fragmentClazz) { if (activity == null) { return;// w ww .j a va 2s. c om } FragmentManager fragmentManager = activity.getSupportFragmentManager(); Fragment fragment = fragmentManager.findFragmentById(containerId); if (fragment == null || !fragmentClazz.isAssignableFrom(fragment.getClass())) { try { fragment = fragmentClazz.newInstance(); NavUtil.replaceFragment(activity, containerId, fragment); } catch (InstantiationException ex) { Ln.e(ex, "Cannot create instance of fragment"); } catch (IllegalAccessException ex) { Ln.e(ex, "Cannot create instance of fragment"); } } }
From source file:com.sun.inject.Injector.java
public static final void injectFragment(Fragment frgment, View view) { if (frgment == null || view == null) return;/*from w ww.j a v a 2 s . c om*/ Field[] fields = frgment.getClass().getDeclaredFields(); if (fields == null || fields.length == 0) return; try { for (Field field : fields) { if (field.isAnnotationPresent(InjectView.class)) { injectViewByFragment(field, frgment, view); } else if (field.isAnnotationPresent(InjectFragment.class)) { injectFragmentByFragment(field, frgment); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:dagger.android.support.AndroidSupportInjection.java
/** * Injects {@code fragment} if an associated {@link dagger.android.AndroidInjector} implementation * can be found, otherwise throws an {@link IllegalArgumentException}. * * <p>Uses the following algorithm to find the appropriate {@code AndroidInjector<Fragment>} to * use to inject {@code fragment}:/*from w ww.ja v a 2 s . co m*/ * * <ol> * <li>Walks the parent-fragment hierarchy to find the a fragment that implements {@link * HasSupportFragmentInjector}, and if none do * <li>Uses the {@code fragment}'s {@link Fragment#getActivity() activity} if it implements * {@link HasSupportFragmentInjector}, and if not * <li>Uses the {@link android.app.Application} if it implements {@link * HasSupportFragmentInjector}. * </ol> * * If none of them implement {@link HasSupportFragmentInjector}, a {@link * IllegalArgumentException} is thrown. * * @throws IllegalArgumentException if no parent fragment, activity, or application implements * {@link HasSupportFragmentInjector}. */ public static void inject(Fragment fragment) { Preconditions.checkNotNull(fragment, "fragment"); HasSupportFragmentInjector hasSupportFragmentInjector = findHasFragmentInjector(fragment); Log.d(TAG, String.format("An injector for %s was found in %s", fragment.getClass().getCanonicalName(), hasSupportFragmentInjector.getClass().getCanonicalName())); AndroidInjector<Fragment> fragmentInjector = hasSupportFragmentInjector.supportFragmentInjector(); Preconditions.checkNotNull(fragmentInjector, "%s.supportFragmentInjector() returned null", hasSupportFragmentInjector.getClass().getCanonicalName()); fragmentInjector.inject(fragment); }
From source file:cn.jarlen.richcommon.ui.FragmentStack.java
/** * * @param context/*www .j av a 2 s .c o m*/ * @param containerId * @param newFragment */ public static void addFragmentToStack(Fragment context, int containerId, Fragment newFragment) { FragmentManager fragmentManager = context.getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(containerId, newFragment, newFragment.getClass().getSimpleName()); ft.setCustomAnimations(anim_In, anim_out); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.addToBackStack(null); ft.commit(); }