List of usage examples for android.support.v4.app Fragment getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:cn.jarlen.richcommon.ui.FragmentStack.java
public static void replaceChildFrament(Fragment context, int containerId, Fragment newFragment) { FragmentManager fragmentManager = context.getChildFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(containerId, newFragment, newFragment.getClass().getSimpleName()).commit(); }
From source file:cn.jarlen.richcommon.ui.FragmentStack.java
/** * put one fragment(which is contained by activity) into stack * @param context/*from w ww . jav a 2 s . co m*/ * the activity * @param containerId * fragment containerId * @param newFragment * fragment object */ public static void addFragmentToStack(FragmentActivity context, int containerId, Fragment newFragment) { FragmentManager fragmentManager = context.getSupportFragmentManager(); 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(); }
From source file:com.joulespersecond.oba.ObaAnalytics.java
/** * For reporting fragments on Start/*from w ww . j ava2s .co m*/ * * @param fragment The fragment being reported */ public static void reportFragmentStart(Fragment fragment) { if (isAnalyticsActive()) { Tracker tracker = Application.get().getTracker(Application.TrackerName.APP_TRACKER); tracker.setScreenName(fragment.getClass().getSimpleName()); tracker.send(new HitBuilders.ScreenViewBuilder().build()); Tracker tracker2 = Application.get().getTracker(Application.TrackerName.GLOBAL_TRACKER); tracker2.setScreenName(fragment.getClass().getSimpleName()); tracker2.send(new HitBuilders.ScreenViewBuilder().build()); } }
From source file:scott.android.com.repository.base.view.BaseActivity.java
/** * Method to navigate using FragmentTransaction and FragmentManager. *///from w ww . j av a 2 s . com private static void navigateTo(FragmentManager manager, Fragment newFragment, int containerId, boolean options) { FragmentTransaction ft = manager.beginTransaction(); ft.replace(containerId, newFragment, newFragment.getClass().getSimpleName()); if (options) { ft.addToBackStack(newFragment.getClass().getSimpleName()); } ft.commit(); }
From source file:com.cylan.jiafeigou.utils.ActivityUtils.java
/** * ?fragment//from w w w . j av a2 s. c o m */ public static void replaceFragment(int id, FragmentManager fragmentManager, Fragment fragment) { fragmentManager .beginTransaction().setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_in_left, R.anim.slide_out_right) .replace(id, fragment, fragment.getClass().getSimpleName()).commit(); }
From source file:com.fenlisproject.elf.core.framework.ElfBinder.java
public static void bindFragmentArgument(Fragment receiver) { Field[] fields = receiver.getClass().getDeclaredFields(); for (Field field : fields) { field.setAccessible(true);/* w ww . j a v a 2 s. c o m*/ FragmentArgument fragmentArgument = field.getAnnotation(FragmentArgument.class); if (fragmentArgument != null) { try { Bundle bundle = receiver.getArguments(); if (bundle != null) { Class<?> type = field.getType(); if (type == Boolean.class || type == boolean.class) { field.set(receiver, bundle.getBoolean(fragmentArgument.value())); } else if (type == Byte.class || type == byte.class) { field.set(receiver, bundle.getByte(fragmentArgument.value())); } else if (type == Character.class || type == char.class) { field.set(receiver, bundle.getChar(fragmentArgument.value())); } else if (type == Double.class || type == double.class) { field.set(receiver, bundle.getDouble(fragmentArgument.value())); } else if (type == Float.class || type == float.class) { field.set(receiver, bundle.getFloat(fragmentArgument.value())); } else if (type == Integer.class || type == int.class) { field.set(receiver, bundle.getInt(fragmentArgument.value())); } else if (type == Long.class || type == long.class) { field.set(receiver, bundle.getLong(fragmentArgument.value())); } else if (type == Short.class || type == short.class) { field.set(receiver, bundle.getShort(fragmentArgument.value())); } else if (type == String.class) { field.set(receiver, bundle.getString(fragmentArgument.value())); } else if (type == Boolean[].class || type == boolean[].class) { field.set(receiver, bundle.getBooleanArray(fragmentArgument.value())); } else if (type == Byte[].class || type == byte[].class) { field.set(receiver, bundle.getByteArray(fragmentArgument.value())); } else if (type == Character[].class || type == char[].class) { field.set(receiver, bundle.getCharArray(fragmentArgument.value())); } else if (type == Double[].class || type == double[].class) { field.set(receiver, bundle.getDoubleArray(fragmentArgument.value())); } else if (type == Float[].class || type == float[].class) { field.set(receiver, bundle.getFloatArray(fragmentArgument.value())); } else if (type == Integer[].class || type == int[].class) { field.set(receiver, bundle.getIntArray(fragmentArgument.value())); } else if (type == Long[].class || type == long[].class) { field.set(receiver, bundle.getLongArray(fragmentArgument.value())); } else if (type == Short[].class || type == short[].class) { field.set(receiver, bundle.getShortArray(fragmentArgument.value())); } else if (type == String[].class) { field.set(receiver, bundle.getStringArray(fragmentArgument.value())); } else if (Serializable.class.isAssignableFrom(type)) { field.set(receiver, bundle.getSerializable(fragmentArgument.value())); } else if (type == Bundle.class) { field.set(receiver, bundle.getBundle(fragmentArgument.value())); } } } catch (IllegalAccessException e) { e.printStackTrace(); } } } }
From source file:cn.jarlen.richcommon.ui.FragmentStack.java
public static void replaceFragment(FragmentActivity context, int containerId, Fragment newFragment) { FragmentManager fragmentManager = context.getSupportFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.setCustomAnimations(anim_In, anim_out); ft.replace(containerId, newFragment, newFragment.getClass().getSimpleName()); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit();// w w w . j a v a2s. c om }
From source file:org.comixwall.pffw.Utils.java
/** * Show the given message in a toast.// ww w .j a va 2 s .c o m * Do not show the message if the fragment is not visible, which is possible if the user has * switched to another fragment by the time this method is called. * * @param owner Fragment which initiated the call to this method. * @param message Message to display. */ static void showMessage(final Fragment owner, final String message) { // Make sure the fragment still has a context if (owner.isVisible()) { Toast.makeText(owner.getContext(), message, Toast.LENGTH_SHORT).show(); } else { logger.info("Fragment not visible on showMessage: " + owner.getClass().getSimpleName()); } }
From source file:cn.jarlen.richcommon.ui.FragmentStack.java
public static void addFrament(FragmentActivity context, int containerId, Fragment newFragment) { try {//from w ww . ja va 2s. c o m FragmentManager fragmentManager = context.getSupportFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.setCustomAnimations(anim_In, anim_out); ft.add(containerId, newFragment, newFragment.getClass().getSimpleName()).commit(); } catch (IllegalStateException e) { if (e.getMessage().startsWith("Fragment already added")) { removeFragment(context, newFragment); addFrament(context, containerId, newFragment); } } }
From source file:com.cylan.jiafeigou.utils.ActivityUtils.java
/** * The {@code fragment} is added to the container view with msgId {@code frameId}. The operation is * performed by the {@code fragmentManager}. *//*from w ww. j a v a 2 s. c o m*/ public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment, int frameId) { // checkNotNull(fragmentManager); // checkNotNull(fragment); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(frameId, fragment); transaction.addToBackStack(fragment.getClass().getSimpleName()); transaction.commit(); }