List of usage examples for android.view ViewGroup getId
@IdRes @ViewDebug.CapturedViewProperty public int getId()
From source file:com.alimuzaffar.ramadanalarm.widget.FragmentStatePagerAdapter.java
@SuppressLint("NewApi") @Override/*from w w w . j a va 2 s . c o m*/ 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); } fragment.setMenuVisibility(false); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { fragment.setUserVisibleHint(false); } mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment); return fragment; }
From source file:com.kevinread.sortablefragmentpager.SortableFragmentStatePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { createIdCache();/* w w w .j av a 2s . co m*/ // 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); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment); return fragment; }
From source file:com.example.craiger.nav.FragmentItemIdStatePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { if (DEBUG)/*www . j a v a2s . co m*/ Log.v(TAG, "instantiateItem() position: " + position); Long itemId = getItemId(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 = mItemIdToFragmentMap.get(itemId); if (f != null) { if (DEBUG) Log.v(TAG, "Returning cached fragment: #" + itemId + ": f=" + f); mUnusedRestoredFragments.remove(f); return f; } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); if (DEBUG) Log.v(TAG, "Adding item #" + itemId + ": f=" + fragment); mFragmentToItemIdMap.put(fragment, itemId); mItemIdToFragmentMap.put(itemId, fragment); Fragment.SavedState fss = mSavedState.get(itemId); if (fss != null) { fragment.setInitialSavedState(fss); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mCurTransaction.add(container.getId(), fragment); return fragment; }
From source file:com.jparkie.aizoban.views.adapters.BaseFragmentStatePagerAdapter.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 .ja va2 s.co m } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); String fragmentTag = getTag(position); 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); } } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment, fragmentTag); return fragment; }
From source file:org.kegbot.app.util.SortableFragmentStatePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { createIdCache();//www . j av a2 s. c o m // 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); } fragment.setMenuVisibility(false); if (Build.VERSION.SDK_INT >= 15) { fragment.setUserVisibleHint(false); } mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment); return fragment; }
From source file:br.fapema.morholt.android.wizardpager.wizard.basic.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. if (mFragments.size() > position) { Fragment f = mFragments.get(position); if (f != null) { return f; }//from w w w . j a v a 2s . c o m } 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 (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); } } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment, fragmentTag); return fragment; }
From source file:net.illusor.swipeplayer.activities.SwipePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { Fragment fragment;/*from ww w.j av a2 s .c om*/ //the last fragment in the list - is always playlistFragment //check, if we should return it if (this.isPlaylistIndex(position)) fragment = this.playlistFragment; else fragment = this.browserFragments.get(position); //if fragment is null means fragment was disposed to reduce app //memory footprint, and we should restore it from its saved state //(or this is the first run of the adapter, and there are no fragments initialized) if (fragment != null) return fragment; if (this.curTransaction == null) this.curTransaction = this.fragmentManager.beginTransaction(); //creating a new fragment if (this.isPlaylistIndex(position)) { fragment = this.getPlaylistFragment(); this.playlistFragment = fragment; } else { File folder = this.browserFolders.get(position); fragment = this.getBrowserFragment(folder); Fragment.SavedState savedState = this.browserStates.get(position); if (savedState != null) fragment.setInitialSavedState(savedState); this.browserFragments.set(position, fragment); this.browserStates.set(position, null); } this.activateFragment(fragment, false); this.curTransaction.add(container.getId(), fragment); return fragment; }
From source file:com.example.fragmentstatepagerissueexample.app.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. if (mFragments.size() > position) { Fragment f = mFragments.get(position); if (f != null) { return f; }// w ww . ja v a 2 s . c o m } 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 (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); } } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment, fragmentTag); return fragment; }
From source file:com.dandewine.user.tocleveroad.adapters.FixedFragmentStatePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { // If we already have this result_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 w w.ja va 2 s . c o m } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); String fragmentTag = getTag(position); if (DEBUG) Log.v(TAG, "Adding result_item #" + position + ": f=" + fragment + " t=" + fragmentTag); 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); } } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment, fragmentTag); return fragment; }
From source file:com.github.paradam.support.v4.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 ww w .j av a 2s . com 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); } f.setMenuVisibility(false); f.setUserVisibleHint(false); mFragments.set(position, f); mCurTransaction.add(container.getId(), f); return f; }