Example usage for android.view ViewGroup getId

List of usage examples for android.view ViewGroup getId

Introduction

In this page you can find the example usage for android.view ViewGroup getId.

Prototype

@IdRes
@ViewDebug.CapturedViewProperty
public int getId() 

Source Link

Document

Returns this view's identifier.

Usage

From source file:com.dc.focusapp.ViewPagerAdapter.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 && getItemPosition(f) == position) {
            return f;
        }/*  ww  w  .  j av  a  2  s . c o m*/
    }

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

    Fragment fragment = getItem(position);
    if (DEBUG)
        Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
    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.afollestad.impression.utils.FragmentStatePagerAdapter.java

@SuppressLint("CommitTransaction")
@Override//w ww  .  j a  va2  s .c  om
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;
        }
    }

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

    Fragment fragment = getItem(position);
    if (DEBUG)
        Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
    if (mSavedState.size() > position) {
        Fragment.SavedState fss = mSavedState.get(position);
        if (fss != null) {
            fragment.setInitialSavedState(fss);
        }
    }
    while (mFragments.size() <= position) {
        mFragments.add(null);
    }
    FragmentCompat.setMenuVisibility(fragment, false);
    FragmentCompat.setUserVisibleHint(fragment, false);
    mFragments.set(position, fragment);
    mCurTransaction.add(container.getId(), fragment, "page:" + position);

    return fragment;
}

From source file:de.andacaydin.bidirectionalviewpagerlibrary.googlecode.FragmentStatePagerAdapter.java

@Override
public BiDirectionalFragment 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) {
        BiDirectionalFragment f = mFragments.get(position);
        if (f != null) {
            return f;
        }/* w  ww .  j a va 2s  .  com*/
    }

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

    BiDirectionalFragment fragment = getItem(position);
    if (DEBUG)
        Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
    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:cl.monsoon.s1next.widget.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;
        }/*  w  ww .j  av  a  2  s  .  com*/
    }

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

    Fragment fragment = getItem(position);
    if (DEBUG) {
        Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
    }
    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);

    // here we did to add a tag to the Fragment!
    mCurTransaction.add(container.getId(), fragment,
            "android:FragmentStatePagerAdapter:" + container.getId() + ":" + position);

    return fragment;
}

From source file:com.hongsec.frame.tab.view.indicator.FragmentListPageAdapter.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 ww w .  java2 s  . c  om*/
    }

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

    Fragment fragment = getItem(position);
    if (DEBUG)
        //         Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
        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.btmura.android.reddit.app.FragmentStateItemPagerAdapter.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;
        }// www . ja  v a  2 s  .c  o m
    }

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

    Fragment fragment = getItem(position);
    if (DEBUG) {
        Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
    }
    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:info.guardianproject.otr.app.im.app.DynamicPagerAdapter.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;
        }//ww w.j a va  2  s .  c o m
    }

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

    Fragment fragment = getItem(position);
    if (DEBUG)
        Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
    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.bilibili.lib.pageradapter.IDFragmentStatePagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    final int id = getItemId(position);
    // find in restored fragments cache
    Fragment f = mFragments.get(id);//from ww w. jav a  2 s  . co m
    if (f != null) {
        return f;
    }

    if (mCurrentTransaction == null) {
        // will commit() when finishUpdate() call
        mCurrentTransaction = mFragmentManager.beginTransaction();
    }

    Fragment fragment = getItem(id);
    if (DEBUG) {
        Log.v(TAG, "Adding item #" + position + ": id =" + id + ", f=" + fragment);
    }
    Fragment.SavedState fss = mSavedState.get(id);
    if (fss != null) {
        Bundle state;
        try {
            state = Reflection.on(Fragment.SavedState.class).fieldValue(fss, "mState");
        } catch (NoSuchFieldException e) {
            if (DEBUG)
                Log.w(TAG, "No field name 'mState'!");
            state = null;
        }
        if (state != null) {
            state.setClassLoader(fragment.getClass().getClassLoader());
        }
        fragment.setInitialSavedState(fss);
    }
    fragment.setMenuVisibility(false);
    fragment.setUserVisibleHint(false);
    mFragments.put(id, fragment);
    mCurrentTransaction.add(container.getId(), fragment);

    return fragment;
}

From source file:com.tct.mail.utils.FragmentStatePagerAdapter2.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.
    final Fragment existing = mFragments.get(position);
    if (existing != null) {
        return existing;
    }/*from   www  .  j  a va2  s .  co m*/

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

    Fragment fragment = getItem(position);
    if (DEBUG)
        LogUtils.v(TAG, "Adding item #" + position + ": f=" + fragment);
    if (mEnableSavedStates && mSavedState.size() > position) {
        Fragment.SavedState fss = mSavedState.get(position);
        if (fss != null) {
            fragment.setInitialSavedState(fss);
        }
    }
    //TS: jian.xu 2015-11-02 EMAIL BUGFIX-1106488 MOD_S
    if (fragment != null && fragment != mCurrentPrimaryItem) {
        setItemVisible(fragment, false);
    }
    //TS: jian.xu 2015-11-02 EMAIL BUGFIX-1106488 MOD_E
    mFragments.put(position, fragment);
    mCurTransaction.add(container.getId(), fragment);

    return fragment;
}

From source file:com.warlkerpower.walker.tabview.indicator.FragmentListPageAdapter.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 ww w . jav a2 s .c om
    }

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

    Fragment fragment = getItem(position);
    if (DEBUG)
        Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
    if (fragment == null) {
        return null;
    }

    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;
}