Example usage for android.app Fragment getActivity

List of usage examples for android.app Fragment getActivity

Introduction

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

Prototype

final public Activity getActivity() 

Source Link

Document

Return the Activity this fragment is currently associated with.

Usage

From source file:com.nutomic.syncthingandroid.util.BarcodeIntentIntegrator.java

/**
 * @param fragment {@link android.support.v4.app.Fragment} invoking the integration.
 *  {@link #startActivityForResult(Intent, int)} will be called on the
 *  {@link android.support.v4.app.Fragment} instead of an {@link Activity} or
 *  {@link Fragment}./*w  ww.  ja  v a 2s.c  o m*/
 */
public BarcodeIntentIntegrator(android.support.v4.app.Fragment fragment) {
    this.activity = fragment.getActivity();
    this.fragment = null;
    this.fragmentV4 = fragment;
    initializeConfiguration();
}

From source file:com.google.zxing.integration.android.SupportIntentIntegrator.java

/**
 * @param fragment {@link android.support.v4.app.Fragment} invoking the integration.
 *  {@link #startActivityForResult(Intent, int)} will be called on the
 *  {@link android.support.v4.app.Fragment} instead of an {@link Activity} or
 *  {@link Fragment}./*  w  ww  .  j a va 2 s  . c  om*/
 */
public SupportIntentIntegrator(android.support.v4.app.Fragment fragment) {
    this.activity = fragment.getActivity();
    this.fragment = null;
    this.fragmentV4 = fragment;
    initializeConfiguration();
}

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

/**
 * Fragment??xml//  w ww .j a  v  a2 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// w ww  .j av a  2  s.  com
 * 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.co  m*/
 * @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));

}

From source file:com.xtremelabs.imageutils.ImageLoader.java

@SuppressLint("NewApi")
@Deprecated
public ImageLoader(Fragment fragment) {
    this(fragment, fragment.getActivity());
}

From source file:com.android.mail.ui.AbstractActivityController.java

/**
 * Check if the fragment is attached to an activity and has a root view.
 * @param in fragment to be checked/*from w w  w.  j a v a  2 s  .co m*/
 * @return true if the fragment is valid, false otherwise
 */
private static boolean isValidFragment(Fragment in) {
    return !(in == null || in.getActivity() == null || in.getView() == null);
}