Example usage for android.app Fragment setUserVisibleHint

List of usage examples for android.app Fragment setUserVisibleHint

Introduction

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

Prototype

public void setUserVisibleHint(boolean isVisibleToUser) 

Source Link

Document

Set a hint to the system about whether this fragment's UI is currently visible to the user.

Usage

From source file:org.wen.rubychina.ui.adapter.internal.FragmentPagerAdapter.java

@TargetApi(15)
private void setUserVisibleHint(Fragment fragment) {
    fragment.setUserVisibleHint(false);
}

From source file:cn.ieclipse.af.adapter.AfFragmentPagerAdapter.java

@TargetApi(15)
private void setUserVisibleHint(Fragment f, boolean isVisible) {
    if (Build.VERSION.SDK_INT >= 15) {
        f.setUserVisibleHint(isVisible);
    }/* w ww  .  ja  v  a2 s .co  m*/

}

From source file:com.cleveroad.slidingtutorial.FragmentPagerAdapter.java

private void setUserVisibilityHint(Fragment fragment, boolean isVisible) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
        fragment.setUserVisibleHint(isVisible);
    }/*w w w  . ja  va  2  s . c  om*/
}

From source file:com.nononsenseapps.support.app.FragmentPagerAdapter.java

@TargetApi(15)
private void setUserVisibleHint(final Fragment fragment, final boolean value) {
    if (fragment != null && context.getResources().getBoolean(R.bool.atLeast15))
        fragment.setUserVisibleHint(value);
}

From source file:com.mcxiaoke.minicat.adapter.FragmentPagerAdapter.java

@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
    Fragment fragment = (Fragment) object;
    if (fragment != mCurrentPrimaryItem) {
        if (mCurrentPrimaryItem != null) {
            fragment.setMenuVisibility(false);
            fragment.setUserVisibleHint(false);
        }//from  ww  w  .j  a  v  a  2s.c  o  m
        if (fragment != null) {
            fragment.setMenuVisibility(true);
            fragment.setUserVisibleHint(true);
        }
        mCurrentPrimaryItem = fragment;
    }
}

From source file:com.afollestad.polar.viewer.FragmentStatePagerAdapter.java

@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
    Fragment fragment = (Fragment) object;
    if (fragment != mCurrentPrimaryItem) {
        if (mCurrentPrimaryItem != null) {
            mCurrentPrimaryItem.setMenuVisibility(false);
            mCurrentPrimaryItem.setUserVisibleHint(false);
        }/*from ww  w  .  ja v  a2s .  co  m*/
        fragment.setMenuVisibility(true);
        fragment.setUserVisibleHint(true);
        mCurrentPrimaryItem = fragment;
    }
}

From source file:com.acttogethermoving.estimator.widget.FragmentPagerAdapter.java

@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
    Fragment fragment = (Fragment) object;
    if (fragment != mCurrentPrimaryItem) {
        if (mCurrentPrimaryItem != null) {
            mCurrentPrimaryItem.setMenuVisibility(false);
            mCurrentPrimaryItem.setUserVisibleHint(false);
        }// www .ja  v a2  s  . c  o  m
        if (fragment != null) {
            fragment.setMenuVisibility(true);
            fragment.setUserVisibleHint(true);
        }
        mCurrentPrimaryItem = fragment;
    }
}

From source file:com.frostwire.android.gui.views.FragmentPagerAdapter.java

@SuppressWarnings("ReferenceEquality")
@Override/*from   w  w w . j a  v  a 2 s.com*/
public void setPrimaryItem(ViewGroup container, int position, Object object) {
    Fragment fragment = (Fragment) object;
    if (fragment != mCurrentPrimaryItem) {
        if (mCurrentPrimaryItem != null) {
            mCurrentPrimaryItem.setMenuVisibility(false);
            mCurrentPrimaryItem.setUserVisibleHint(false);
        }
        if (fragment != null) {
            fragment.setMenuVisibility(true);
            fragment.setUserVisibleHint(true);
        }
        mCurrentPrimaryItem = fragment;
    }
}

From source file:com.example.study.studyproject.adapter.FragmentStatePagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    // If we already have this item instantiated, there is nothing
    // to do.  This can happen when we are restoring the entire pager
    // from its saved state, where the fragment manager has already
    // taken care of restoring the fragments we previously had instantiated.
    if (mFragments.size() > position) {
        Fragment f = mFragments.get(position);
        if (f != null) {
            return f;
        }/*from  w  ww .ja  va 2s . co m*/
    }

    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }

    Fragment fragment = getItem(position);

    if (mSavedState.size() > position) {
        Fragment.SavedState fss = mSavedState.get(position);
        if (fss != null) {
            fragment.setInitialSavedState(fss);
        }
    }
    while (mFragments.size() <= position) {
        mFragments.add(null);
    }
    fragment.setMenuVisibility(false);
    fragment.setUserVisibleHint(false);
    mFragments.set(position, fragment);
    mCurTransaction.add(container.getId(), fragment);

    return fragment;
}

From source file:com.view.FragmentStatePagerAdapter.java

@Override
public void setPrimaryItem(ViewGroup container, int positon, Object object) {
    Fragment fragment = (Fragment) object;
    if (fragment != mCurrentPrimaryItem) {
        if (mCurrentPrimaryItem != null) {
            mCurrentPrimaryItem.setMenuVisibility(false);
            mCurrentPrimaryItem.setUserVisibleHint(false);
        }/*  w w  w . java 2 s  .  c  o m*/
        if (fragment != null) {
            fragment.setMenuVisibility(true);
            fragment.setUserVisibleHint(true);
        }
        mCurrentPrimaryItem = fragment;
    }
}