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.commonsware.cwac.pager.ArrayPagerAdapter.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
@Override/*  w w w  .  j  av  a  2s. c  o m*/
public Object instantiateItem(ViewGroup container, int position) {
    if (currTransaction == null) {
        currTransaction = fm.beginTransaction();
    }

    Fragment fragment = getExistingFragment(position);

    if (fragment != null) {
        retentionStrategy.attach(fragment, currTransaction);
    } else {
        fragment = createFragment(entries.get(position).getDescriptor());
        currTransaction.add(container.getId(), fragment, getFragmentTag(position));
    }

    if (fragment != currPrimaryItem) {
        fragment.setMenuVisibility(false);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            fragment.setUserVisibleHint(false);
        }
    }

    return (fragment);
}

From source file:net.illusor.swipeplayer.fragments.TrackPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int fragmentPosition) {
    //if we are going to cycle adapter content, we should adjust audioFile index
    int filePosition = this.coerceCyclicPosition(fragmentPosition);

    TrackFragment fragment = this.fragments.get(fragmentPosition);
    if (fragment != null)
        return fragment;

    if (this.currentTransaction == null)
        this.currentTransaction = this.fragmentManager.beginTransaction();

    AudioFile audioFile = this.audioFiles.get(filePosition);
    fragment = TrackFragment.newInstance(audioFile);
    this.fragments.put(fragmentPosition, fragment);

    this.currentTransaction.add(container.getId(), fragment);

    return fragment;
}

From source file:com.zhangtielei.demos.badge_number.tabs.adapter.MainTabsPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    String tag = makeFragmentName(position);
    Fragment fragment = mFragmentManager.findFragmentByTag(tag);

    if (fragment == null) {
        //fragment
        fragment = new PlaceHolderFragment();
        if (DEBUG) {
            Log.v(LOG_TAG, "Adding item #" + position + ": f=" + fragment);
        }/*from  w  w w.  ja va  2 s.c  o m*/
        if (mCurTransaction == null) {
            mCurTransaction = mFragmentManager.beginTransaction();
        }
        mCurTransaction.add(container.getId(), fragment, tag);
    } else {
        //?1??2view pageroffscreen limit???
        boolean ignore = false;
        if (fragmentsAccess[position]) {
            if (fragment instanceof PlaceHolderFragment) {
                //??fragment
                if (mCurTransaction == null) {
                    mCurTransaction = mFragmentManager.beginTransaction();
                }
                if (DEBUG) {
                    Log.v(LOG_TAG, "Remove #" + position + ": f=" + fragment);
                }
                mCurTransaction.remove(fragment);
                fragment = getItem(position);
                mCurTransaction.add(container.getId(), fragment, tag);
                fragmentMap.put(position, fragment);
                if (DEBUG) {
                    Log.v(LOG_TAG, "Re-Add #" + position + ": f=" + fragment);
                }
            } else {
                ignore = true;
                fragmentMap.put(position, fragment);//?fragment?map??
            }
        } else {
            ignore = true;
        }

        if (ignore) {
            if (DEBUG) {
                Log.v(LOG_TAG,
                        "Ignore instantiate item #" + position + ": f=" + fragment + ", f.X="
                                + fragment.getView().getLeft() + ", container child count: "
                                + container.getChildCount());
            }
            /**
             * ??????viewX?????layout?
             */
            viewPager.requestLayout();
        }
    }

    if (fragment != mCurrentPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}

From source file:com.sbrukhanda.fragmentviewpager.adapters.FragmentPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }/*from   ww w .  j a v  a 2s .c  o  m*/

    final long itemId = getItemId(position);

    Fragment fragment = getFragment(position);
    if (fragment != null) {
        if (DEBUG)
            Log.v(TAG, "Attaching item #" + itemId + ": f=" + fragment);
        mCurTransaction.attach(fragment);
    } else {
        fragment = instantiateFragment(position);
        if (DEBUG)
            Log.v(TAG, "Adding item #" + itemId + ": f=" + fragment);
        mCurTransaction.add(container.getId(), fragment, makeFragmentName(this, itemId));
    }
    if (fragment != mCurrentPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}

From source file:com.dpsimple.FragmentPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }/*from ww  w  . java2  s .co m*/

    // Do we already have this fragment?
    String name = makeFragmentName(position);
    Fragment fragment = mFragmentManager.findFragmentByTag(name);
    if (fragment != null) {
        if (DEBUG)
            Log.v(TAG, "Attaching item #" + position + ": f=" + fragment);
        mCurTransaction.attach(fragment);
    } else {
        fragment = getItem(position);
        if (DEBUG)
            Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
        mCurTransaction.remove(fragment).add(container.getId(), fragment, makeFragmentName(position));
    }
    if (fragment != mCurrentPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}

From source file:ti.modules.titanium.ui.widget.abslistview.TiAbsListView.java

public static View layoutHeaderOrFooterView(TiViewProxy viewProxy, View convertView) {
    TiUIView tiView = viewProxy.getOrCreateView();
    View outerView = null;// w w w . j a  v a2s  .c om
    ViewGroup parentView = null;
    if (tiView != null) {
        outerView = tiView.getOuterView();
        parentView = (ViewGroup) outerView.getParent();
    }
    if ((parentView != null && parentView.getId() == HEADER_FOOTER_WRAP_ID)
            && (convertView == null || convertView == parentView)) {
        return parentView;
    } else {

        TiCompositeLayout wrapper = null;
        if (convertView instanceof TiCompositeLayout && convertView.getId() == HEADER_FOOTER_WRAP_ID) {
            wrapper = (TiCompositeLayout) convertView;
            wrapper.removeAllViews();
        } else {
            wrapper = new TiCompositeLayout(viewProxy.getActivity(), LayoutArrangement.DEFAULT, null);
            //add a wrapper so layout params such as height, width takes in effect.
            AbsListView.LayoutParams params = new AbsListView.LayoutParams(
                    AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT);
            wrapper.setLayoutParams(params);
            wrapper.setInternalTouchPassThrough(true);
        }
        if (parentView != null) {
            parentView.removeView(outerView);
        }
        //           TiUIHelper.removeViewFromSuperView(viewProxy);

        if (outerView != null && tiView != null) {
            TiCompositeLayout.LayoutParams headerParams = tiView.getLayoutParams();
            //If height is not dip, explicitly set it to SIZE
            if (!headerParams.fixedSizeHeight()) {
                headerParams.sizeOrFillHeightEnabled = true;
                headerParams.autoFillsHeight = false;
            }
            if (headerParams.optionWidth == null && !viewProxy.hasProperty(TiC.PROPERTY_WIDTH)) {
                headerParams.sizeOrFillWidthEnabled = true;
                headerParams.autoFillsWidth = true;
            }
            wrapper.addView(outerView, tiView.getLayoutParams());
        }
        wrapper.setId(HEADER_FOOTER_WRAP_ID);
        wrapper.setTag(HEADER_FOOTER_WRAP_ID);
        return wrapper;
    }
}

From source file:com.android.deskclock.timer.TimerPagerAdapter.java

@Override
public Fragment instantiateItem(ViewGroup container, int position) {
    if (mCurrentTransaction == null) {
        mCurrentTransaction = mFragmentManager.beginTransaction();
    }//from w w  w. ja  v  a  2  s. co m

    final Timer timer = getTimers().get(position);

    // Search for the existing fragment by tag.
    final String tag = getClass().getSimpleName() + timer.getId();
    TimerItemFragment fragment = (TimerItemFragment) mFragmentManager.findFragmentByTag(tag);

    if (fragment != null) {
        // Reattach the existing fragment.
        mCurrentTransaction.attach(fragment);
    } else {
        // Create and add a new fragment.
        fragment = TimerItemFragment.newInstance(timer);
        mCurrentTransaction.add(container.getId(), fragment, tag);
    }

    if (fragment != mCurrentPrimaryItem) {
        setItemVisible(fragment, false);
    }

    mFragments.put(timer.getId(), fragment);

    return fragment;
}

From source file:com.app.hinh.smart3g.adapter.FragmentPagerAdapterExt.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }//  w  w  w. ja  va 2 s . c o  m

    final long itemId = getItemId(position);

    // Do we already have this fragment?
    String name = makeFragmentTag(position);
    Fragment fragment = mFragmentManager.findFragmentByTag(name);
    if (fragment != null) {
        if (DEBUG)
            Log.v(TAG, "Attaching item #" + itemId + ": f=" + fragment);
        mCurTransaction.attach(fragment);
    } else {
        fragment = getItem(position);
        if (DEBUG)
            Log.v(TAG, "Adding item #" + itemId + ": f=" + fragment);
        mCurTransaction.add(container.getId(), fragment, makeFragmentTag(position));
    }
    if (fragment != mCurrentPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}

From source file:com.androidinspain.deskclock.timer.TimerPagerAdapter.java

@Override
@SuppressLint("CommitTransaction")
public Fragment instantiateItem(ViewGroup container, int position) {
    if (mCurrentTransaction == null) {
        mCurrentTransaction = mFragmentManager.beginTransaction();
    }//  w w w.j a v a2  s.  co  m

    final Timer timer = getTimers().get(position);

    // Search for the existing fragment by tag.
    final String tag = getClass().getSimpleName() + timer.getId();
    TimerItemFragment fragment = (TimerItemFragment) mFragmentManager.findFragmentByTag(tag);

    if (fragment != null) {
        // Reattach the existing fragment.
        mCurrentTransaction.attach(fragment);
    } else {
        // Create and add a new fragment.
        fragment = TimerItemFragment.newInstance(timer);
        mCurrentTransaction.add(container.getId(), fragment, tag);
    }

    if (fragment != mCurrentPrimaryItem) {
        setItemVisible(fragment, false);
    }

    mFragments.put(timer.getId(), fragment);

    return fragment;
}

From source file:istat.android.freedev.pagers.adapters.abs.AbsPagerStateAdapter.java

private void defaultInstantiateItem(ViewGroup container, int position, Fragment fragment) {
    // TODO Auto-generated method stub

    if (mSavedState.size() > position) {
        Fragment.SavedState fss = mSavedState.get(position);
        if (fss != null) {

            fragment.setInitialSavedState(fss);
        }//  w w  w . ja va2s  .c  o  m
    }
    while (mFragments.size() <= position) {
        mFragments.add(null);
    }
    fragment.setMenuVisibility(false);
    fragment.setUserVisibleHint(false);
    mFragments.set(position, fragment);

    if (fragment.getTag() == null) {
        mCurTransaction.add(container.getId(), fragment, "" + position);
    } else {
        mCurTransaction.add(container.getId(), fragment);
    }
}