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:mx.developerbus.foodbus.utl.foodBUtil.java

public static boolean setFragmentWorkspace(boolean multipane, FragmentManager fragmentManager,
        Class<? extends Fragment> fragmentClass, Bundle args, int enter, int exit, int popEnter, int popExit,
        boolean staked) throws Exception {
    boolean replace = false;
    try {//from   w w w .j  a v  a2 s .  c  o m

        if (fragmentClass != null) {
            Fragment fp = fragmentManager.findFragmentById(R.id.frgWorkspace);
            FragmentTransaction tra = fragmentManager.beginTransaction();

            if (enter > 0 && exit > 0 && popEnter > 0 && popExit > 0) {
                tra.setCustomAnimations(enter, exit, popEnter, popExit);
                tra.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
            } else {
                tra.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
            }

            Fragment f = fragmentClass.newInstance();
            Bundle b = new Bundle();
            b.putBoolean("multipane", multipane);
            if (args != null) {
                b.putAll(args);
            }
            f.setArguments(b);

            if (fp != null) {
                if (fp.getClass() != fragmentClass) {
                    tra.replace(R.id.frgWorkspace, f);
                    if (staked) {
                        tra.addToBackStack(null);
                    }
                    replace = true;
                }
            } else {
                tra.add(R.id.frgWorkspace, f);
                replace = true;
            }
            tra.commit();
        }
    } catch (Exception e) {
        throw new Exception("ERROR Home - setFragment : " + e.getMessage());
    }
    return replace;
}

From source file:io.github.meness.easyintro.EasyIntroPagerAdapter.java

public int getItemPosition(Class aClass) {
    for (Fragment fragment : mFragments) {
        if (fragment.getClass().getName().equalsIgnoreCase(aClass.getName())) {
            return mFragments.indexOf(fragment);
        }/*from   www  .java 2 s. c o m*/
    }

    return -1;
}

From source file:net.naonedbus.helper.StateHelper.java

public void setSortType(Fragment fragment, int sortType) {
    mSharedPreferences.edit().putInt(fragment.getClass().getSimpleName() + SORT, sortType).commit();
}

From source file:net.naonedbus.helper.StateHelper.java

public void setFilterType(Fragment fragment, int filterType) {
    mSharedPreferences.edit().putInt(fragment.getClass().getSimpleName() + FILTER, filterType).commit();
}

From source file:net.naonedbus.helper.StateHelper.java

public int getSortType(Fragment fragment, int defaultType) {
    return mSharedPreferences.getInt(fragment.getClass().getSimpleName() + SORT, defaultType);
}

From source file:net.naonedbus.helper.StateHelper.java

public int getFilterType(Fragment fragment, int defaultType) {
    return mSharedPreferences.getInt(fragment.getClass().getSimpleName() + FILTER, defaultType);
}

From source file:com.odoo.core.utils.OFragmentUtils.java

private void loadFragment(Fragment fragment, Boolean addToBackState) {
    String tag = fragment.getClass().getCanonicalName();
    if (fragmentManager.findFragmentByTag(tag) != null && savedInstance != null) {
        fragmentManager.popBackStack(tag, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }/* w ww  .ja  v a 2s . c  om*/
    if (savedInstance == null) {
        Log.i(TAG, "Fragment Loaded (" + tag + ")");
        FragmentTransaction tran = fragmentManager.beginTransaction().replace(R.id.fragment_container, fragment,
                tag);
        if (addToBackState)
            tran.addToBackStack(tag);
        tran.commitAllowingStateLoss();
    }
}

From source file:nick.dev.sina.app.content.FragmentController.java

private void init() {
    FragmentManager fragmentManager = mFragmentManager;
    FragmentTransaction transaction = fragmentManager.beginTransaction();

    for (Fragment fragment : mPages) {
        transaction.add(R.id.container, fragment, fragment.getClass().getSimpleName());
        transaction.hide(fragment);//from  w ww  .j av  a2  s .com
    }

    transaction.commitAllowingStateLoss();
    fragmentManager.executePendingTransactions();
}

From source file:com.karmick.dragcontroller.PhotoSortrActivity.java

public void changeFragmentFromActivity(Fragment fragment, int a1, int a2, String tag) {

    String backStateName = fragment.getClass().getName();

    FragmentManager manager = getSupportFragmentManager();
    /*boolean fragmentPopped = manager.popBackStackImmediate (backStateName, 0);
            /*from ww w. j a  va 2 s .c  om*/
    if (!fragmentPopped){ //fragment not in back stack, create it.*/
    FragmentTransaction ft = manager.beginTransaction();
    ft.replace(R.id.container, fragment);
    ft.addToBackStack(backStateName);
    ft.commit();
    //}

}

From source file:au.com.lumo.ameego.utils.Navigator.java

/**
 * This is just a helper method which returns the simple name of
 * the fragment.//from   w w  w  . jav  a 2  s. c o  m
 * @param fragment that get added to the history (BackStack)
 * @return the simple name of the given fragment
 */
protected String getName(final Fragment fragment) {
    return fragment.getClass().getSimpleName();
}