Example usage for android.support.v4.app Fragment getClass

List of usage examples for android.support.v4.app Fragment getClass

Introduction

In this page you can find the example usage for android.support.v4.app Fragment getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:Main.java

public static void changeFragment(FragmentManager manager, @IdRes int layout, Fragment fragment,
        int transitionStyle) {
    FragmentTransaction fragmentTransaction = manager.beginTransaction();
    fragmentTransaction.replace(layout, fragment, fragment.getClass().getSimpleName());
    fragmentTransaction.setTransition(transitionStyle);
    fragmentTransaction.commit();// w  w w  . ja v  a  2s . c om
    manager.executePendingTransactions();
}

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.addToBackStack(fragment.getClass().getSimpleName());
    fragmentTransaction.commit();//from   www .  j  av a  2  s  . co  m
    manager.executePendingTransactions();
}

From source file:Main.java

public static void changeFragment(FragmentManager manager, @IdRes int layout, Fragment fragment,
        int transitionStyle) {
    FragmentTransaction fragmentTransaction = manager.beginTransaction();
    fragmentTransaction.replace(layout, fragment, fragment.getClass().getSimpleName());
    fragmentTransaction.setTransition(transitionStyle);
    fragmentTransaction.addToBackStack(fragment.getClass().getSimpleName());
    fragmentTransaction.commit();//from   www.  jav  a 2  s.co m

    manager.executePendingTransactions();
}

From source file:org.simple.injector.SimpleDagger.java

/**
 * @param fragment//  ww w.  j  av  a 2s .  co  m
 */
public static void inject(Fragment fragment, View rootView) {
    InjectAdapter<Fragment> adapter = getViewAdapter(fragment.getClass());
    if (fuckTheFragment(fragment, rootView)) {
        adapter.injects(fragment);
    }
}

From source file:org.simple.injector.SimpleDagger.java

/**
 * Fragment mView,?rootViewmView// ww w  .  j av a  2 s  .c o  m
 * 
 * @param fragment
 * @param rootView
 * @return
 */
private static boolean fuckTheFragment(Fragment fragment, View rootView) {
    try {
        Class<?> v4fragmentClass = fragment.getClass();
        while (v4fragmentClass != Object.class && !v4fragmentClass.equals(Fragment.class)) {
            v4fragmentClass = v4fragmentClass.getSuperclass();
        }
        Field rootViewField = v4fragmentClass.getDeclaredField("mView");
        rootViewField.setAccessible(true);
        rootViewField.set(fragment, rootView);
        Log.e("", "### getView " + fragment.getView());
        return true;
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    return false;
}

From source file:com.liuwuping.sm.util.ActivityUtils.java

public static void replaceFragment(FragmentManager fm, Fragment fragment, int frameId) {
    FragmentTransaction ft = fm.beginTransaction();
    ft.setCustomAnimations(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit);
    ft.replace(frameId, fragment, fragment.getClass().getSimpleName());
    //        ft.addToBackStack(null);
    ft.commit();//from  w ww.j ava 2s .  c o m
}

From source file:pedroscott.com.popularmoviesapp.app.ui.base.BaseActivity.java

/**
 * Method to navigate using  FragmentTransaction and FragmentManager.
 *//*from w w w . ja  va2 s . c  om*/
public 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  a v  a2 s . c o m*/
 */
public static void loadFragmentNoAnimation(int id, FragmentManager fragmentManager, Fragment fragment) {
    fragmentManager.beginTransaction().add(id, fragment, fragment.getClass().getSimpleName()).commit();
}

From source file:cn.jarlen.richcommon.ui.FragmentStack.java

public static void addChildFrament(Fragment context, int containerId, Fragment newFragment) {
    addChildFragmentByTag(context, containerId, newFragment, newFragment.getClass().getSimpleName());
}

From source file:com.cylan.jiafeigou.utils.ActivityUtils.java

public static boolean addFragmentSlideInFromRight(FragmentManager fragmentManager, Fragment fragment,
        int containerId) {
    final String tag = fragment.getClass().getSimpleName();
    Fragment f = fragmentManager.findFragmentByTag(tag);
    if (f != null && f.isVisible()) {
        return false;
    }/*  ww  w  . j  av a 2 s. c  om*/
    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(tag).commitAllowingStateLoss();
    return true;
}