List of usage examples for android.app Fragment setMenuVisibility
public void setMenuVisibility(boolean menuVisible)
From source file:com.alimuzaffar.ramadanalarm.widget.FragmentStatePagerAdapter.java
@SuppressLint("NewApi") @Override//from ww w . j a v a 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:edu.benlerner.perfectshuffle.MyFragmentPagerAdapter.java
public Object instantiateItem(View container, int position) { if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); }/*ww w. ja v a 2 s .co m*/ // Do we already have this fragment? String name = makeFragmentName(container.getId(), 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.add(container.getId(), fragment, makeFragmentName(container.getId(), position)); } if (fragment != mCurrentPrimaryItem) { fragment.setMenuVisibility(false); } return fragment; }
From source file:tw.com.ischool.dominator.util.ViewPagerAdapter.java
@Override public Object instantiateItem(View container, int position) { if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); }//w w w. j a v a 2 s . c o m // Do we already have this fragment? String name = makeFragmentName(container.getId(), 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.add(container.getId(), fragment, makeFragmentName(container.getId(), position)); } if (fragment != mCurrentPrimaryItem) { fragment.setMenuVisibility(false); } // save register fragment mRegisteredFragments.put(position, fragment); return fragment; }
From source file:org.wen.rubychina.ui.adapter.internal.FragmentPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); }//from w w w. ja v a 2 s.co m final long itemId = getItemId(position); // Do we already have this fragment? String name = makeFragmentName(container.getId(), itemId); 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, makeFragmentName(container.getId(), itemId)); } if (fragment != mCurrentPrimaryItem) { fragment.setMenuVisibility(false); setUserVisibleHint(fragment); } return fragment; }
From source file:com.teamboid.twitter.TaggedFragmentAdapter.java
@Override public Object instantiateItem(View 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 w w. j a v a 2s.c o m } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment liveFragment = mFragmentManager.findFragmentByTag("page:" + Integer.toString(position)); if (liveFragment != null) { mCurTransaction.attach(liveFragment); return liveFragment; } 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); } if (fragment != mCurrentPrimaryItem) { fragment.setMenuVisibility(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { Api15.setUserVisibleHint(fragment, false); } } mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment, "page:" + Integer.toString(position)); return fragment; }
From source file:pt.rupeal.invoicexpress.adapters.FragmentPagerAdapter.java
@Override public Object instantiateItem(View container, int position) { if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); }//from www . ja va2 s . c om String name = makeFragmentName(position); Fragment fragment = mFragmentManager.findFragmentByTag(name); // Do we already have this fragment? if (fragment != null) { // updateArguments(fragment, getArgs()); mCurTransaction.attach(fragment); } else { fragment = getItem(position); mCurTransaction.add(container.getId(), fragment, name); // adiconar o filho InvoiceXpress.getInstance().getLastFragment().getFragmentsTagChildren().add(name); } if (fragment != mCurrentPrimaryItem) { fragment.setMenuVisibility(false); } if (InvoiceXpress.DEBUG) { Log.d(this.getClass().getCanonicalName(), "attach or add fragment " + name); } 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()); }/* ww w. ja va 2 s. co m*/ 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:org.kegbot.app.util.SortableFragmentStatePagerAdapter.java
@Override public void setPrimaryItem(ViewGroup container, int position, Object object) { Fragment fragment = (Fragment) object; if (fragment != mCurrentPrimaryItem) { if (mCurrentPrimaryItem != null) { mCurrentPrimaryItem.setMenuVisibility(false); if (Build.VERSION.SDK_INT >= 15) { mCurrentPrimaryItem.setUserVisibleHint(false); }//from ww w . ja v a2s . c o m } if (fragment != null) { fragment.setMenuVisibility(true); if (Build.VERSION.SDK_INT >= 15) { fragment.setUserVisibleHint(true); } } mCurrentPrimaryItem = fragment; } }
From source file:com.airbitz.adapters.FragmentPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); }//ww w .j a v a 2 s . c om // Do we already have this fragment? String name = makeFragmentName(container.getId(), 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.add(container.getId(), fragment, makeFragmentName(container.getId(), position)); } if (fragment != mCurrentPrimaryItem) { fragment.setMenuVisibility(false); } return fragment; }
From source file:com.nashlincoln.blink.app.FragmentPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); }//from w w w. j a va 2s . co m // Do we already have this fragment? String name = makeFragmentName(container.getId(), 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.add(container.getId(), fragment, makeFragmentName(container.getId(), position)); } if (fragment != mCurrentPrimaryItem) { fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); } return fragment; }