Example usage for android.app Fragment getChildFragmentManager

List of usage examples for android.app Fragment getChildFragmentManager

Introduction

In this page you can find the example usage for android.app Fragment getChildFragmentManager.

Prototype

final public FragmentManager getChildFragmentManager() 

Source Link

Document

Return a private FragmentManager for placing and managing Fragments inside of this Fragment.

Usage

From source file:Main.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static FragmentManager getChildFragmentManagerIfAvailable(Fragment fragment) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return fragment.getChildFragmentManager();
    } else {/*from www. j av a2 s. co  m*/
        return fragment.getFragmentManager();
    }
}

From source file:org.onepf.opfiab.FragmentIabHelperImpl.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
FragmentIabHelperImpl(@Nullable final android.support.v4.app.Fragment supportFragment,
        @Nullable final android.app.Fragment fragment) {
    super(supportFragment == null ? null : supportFragment.getChildFragmentManager(),
            fragment == null ? null : fragment.getChildFragmentManager());
    this.fragment = fragment;
    this.supportFragment = supportFragment;
}

From source file:com.blue.leaves.util.task.SugarTask.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void registerHookToContext(@NonNull Fragment fragment) {
    FragmentManager manager = fragment.getChildFragmentManager();

    HookFragment hookFragment = (HookFragment) manager.findFragmentByTag(TAG_HOOK);
    if (hookFragment == null) {
        hookFragment = new HookFragment();
        manager.beginTransaction().add(hookFragment, TAG_HOOK).commitAllowingStateLoss();
    }/*from  www  .j  a  va  2  s  .  c  om*/
}

From source file:com.blue.leaves.util.task.SugarTask.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void unregisterHookToContext(@NonNull Fragment fragment) {
    FragmentManager manager = fragment.getChildFragmentManager();

    HookFragment hookFragment = (HookFragment) manager.findFragmentByTag(TAG_HOOK);
    if (hookFragment != null) {
        hookFragment.postEnable = false;
        manager.beginTransaction().remove(hookFragment).commitAllowingStateLoss();
    }/*  w w  w .  j  av a  2s . co m*/
}

From source file:com.blue.leaves.util.task.SugarTask.java

private void registerHookToContext(@NonNull android.support.v4.app.Fragment fragment) {
    android.support.v4.app.FragmentManager manager = fragment.getChildFragmentManager();

    HookSupportFragment hookSupportFragment = (HookSupportFragment) manager.findFragmentByTag(TAG_HOOK);
    if (hookSupportFragment == null) {
        hookSupportFragment = new HookSupportFragment();
        manager.beginTransaction().add(hookSupportFragment, TAG_HOOK).commitAllowingStateLoss();
    }/*from w w  w  . j a va2s  .co  m*/
}

From source file:com.blue.leaves.util.task.SugarTask.java

private void unregisterHookToContext(@NonNull android.support.v4.app.Fragment fragment) {
    android.support.v4.app.FragmentManager manager = fragment.getChildFragmentManager();

    HookSupportFragment hookSupportFragment = (HookSupportFragment) manager.findFragmentByTag(TAG_HOOK);
    if (hookSupportFragment != null) {
        hookSupportFragment.postEnable = false;
        manager.beginTransaction().remove(hookSupportFragment).commitAllowingStateLoss();
    }//w w w  .j  av a  2 s.  c  o  m
}

From source file:cn.org.eshow.framwork.view.sliding.AbSlidingTabView.java

/**
 * Fragment??xml/*  ww w. j  a  va  2  s  .c o m*/
 * getChildFragmentManager?fragment?
 *
 * @param fragment the fragment
 */
public AbSlidingTabView(Fragment fragment) {

    super(fragment.getActivity());

    this.context = fragment.getActivity();
    initView();
    if (VERSION.SDK_INT <= 17) {
        AbLogUtil.e(AbSlidingTabView.class, "AbSlidingTabView(Fragment fragment) ?SDK17");
        return;
    }
    FragmentManager mFragmentManager = fragment.getChildFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    this.addView(mViewPager,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

}

From source file:com.bangqu.eshow.view.sliding.ESSlidingTabView.java

/**
 * Fragment??xml//from  w ww .java  2s. c o  m
 * getChildFragmentManager?fragment?
 *
 * @param fragment the fragment
 */
public ESSlidingTabView(Fragment fragment) {

    super(fragment.getActivity());

    this.context = fragment.getActivity();
    initView();
    if (VERSION.SDK_INT <= 17) {
        ESLogUtil.e(ESSlidingTabView.class, "AbSlidingTabView(Fragment fragment) ?SDK17");
        return;
    }
    FragmentManager mFragmentManager = fragment.getChildFragmentManager();
    mFragmentPagerAdapter = new ESFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    this.addView(mViewPager,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

}

From source file:com.ab.view.sliding.AbSlidingTabView_fix.java

/**
 * Instantiates a new ab sliding tab view.
 * /*from   ww w . ja  v a2  s  .c  om*/
 * @param fragment
 *            the fragment
 */
public AbSlidingTabView_fix(Fragment fragment) {

    super(fragment.getActivity());

    this.context = fragment.getActivity();
    initView();
    if (VERSION.SDK_INT <= 17) {
        AbLogUtil.e(AbSlidingTabView_fix.class, "AbSlidingTabView(Fragment fragment) ?SDK17");
        return;
    }
    FragmentManager mFragmentManager = fragment.getChildFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerStateAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    this.addView(mViewPager,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

}