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.github.paradam.infinitepager.InfiniteFragmentStatePagerAdapter.java

/**
 * Create the page for the given position.  The adapter is responsible for adding the view to
 * the container given here, although it only must ensure this is done by the time it returns
 * from {@link #finishUpdate(android.view.ViewGroup)}.
 *
 * @param container The containing View in which the page will be shown.
 * @param position  The page position to be instantiated.
 * @return Returns an Object representing the new page.  This does not need to be a View, but
 * can be some other container of the page.
 *///from www. j a  va 2  s. co  m
public Object instantiateRelativeItem(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.
    Fragment f;
    if (mFragments.size() > position) {
        f = mFragments.get(position);
        if (f != null) {
            return f;
        }
    }

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

    if (f.getView() != null) {
        mCurTransaction.remove(f);
    }

    if (mSavedState.size() > position) {
        Fragment.SavedState fss = mSavedState.get(position);
        if (fss != null && !f.isAdded()) {
            f.setInitialSavedState(fss);
        } else if (f.isAdded()) {
            Log.e(TAG, "Error when instantiating Fragment: " + f + ", FragmentSavedState: " + fss
                    + ", fragment already added: " + f.isAdded());
        }
    }
    while (mFragments.size() <= position) {
        mFragments.add(null);
    }

    FragmentCompat.setMenuVisibility(f, false);
    FragmentCompat.setUserVisibleHint(f, false);
    mFragments.set(position, f);
    mCurTransaction.add(container.getId(), f);

    return f;
}

From source file:com.sbrukhanda.fragmentviewpager.adapters.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.
    // -----------------------------------------------------------------------------------------

    Fragment existingFragment = getFragment(position);
    if (existingFragment != null) {
        return existingFragment;
    }/* w  w w. ja va2  s  . c o  m*/

    // -----------------------------------------------------------------------------------------
    // Else, continue with normal flow.
    // -----------------------------------------------------------------------------------------

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

    Fragment fragment = instantiateFragment(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.tapchatapp.android.app.ui.TapchatFragmentStatePagerAdapter.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) {
            int newPos = getItemPosition(f);
            if (position == newPos) {
                if (f.getView() != null && f.getView().getParent() != container) {
                    ((ViewGroup) f.getView().getParent()).removeView(f.getView());
                    container.addView(f.getView());
                }//from   ww  w . j  a  v  a 2  s .com
                return f;
            } else {
                mFragments.remove(position);
                mFragments.ensureCapacity(newPos + 1);
                for (int i = mFragments.size(); i < (newPos + 1); i++) {
                    mFragments.add(null);
                }
                mFragments.set(newPos, 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);
    }
    fragment.setMenuVisibility(false);
    mFragments.set(position, fragment);
    mCurTransaction.add(container.getId(), fragment, getTag(position));

    return fragment;
}

From source file:com.webalcove.travelbook.FixedFragmentStatePagerAdapter.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.
    // need to force position 0 to always update sinze has stop image and configuration change won't update it!
    if (position > 0 && mFragments.size() > position) {
        Fragment f = mFragments.get(position);
        if (f != null) {
            return f;
        }/*ww w. j a  v  a2  s  . c om*/
    }

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

    Fragment fragment = getItem(position);
    //String fragmentTag = getTag(position);
    //if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment + " t=" + fragmentTag);
    if (DEBUG)
        Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
    if (mSavedState.size() > position) {
        //            String savedTag = mSavedFragmentTags.get(position);
        //            if (TextUtils.equals(fragmentTag, savedTag)) {
        //                Fragment.SavedState fss = mSavedState.get(position);
        //                if (fss != null) {
        //                    fragment.setInitialSavedState(fss);
        //                }
        //            }
        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, fragmentTag);
    mCurTransaction.add(container.getId(), fragment);

    return fragment;
}

From source file:org.chromium.chrome.browser.toolbar.ToolbarPhone.java

private void setAncestorsShouldClipChildren(boolean clip) {
    if (!isLocationBarShownInNTP())
        return;//from   www  . ja va  2  s  . c o  m
    ViewGroup parent = this;
    while (parent != null) {
        parent.setClipChildren(clip);
        if (!(parent.getParent() instanceof ViewGroup))
            break;
        if (parent.getId() == android.R.id.content)
            break;
        parent = (ViewGroup) parent.getParent();
    }
}