当前位置: 首页>>代码示例>>Java>>正文


Java Fragment.setInitialSavedState方法代码示例

本文整理汇总了Java中android.support.v4.app.Fragment.setInitialSavedState方法的典型用法代码示例。如果您正苦于以下问题:Java Fragment.setInitialSavedState方法的具体用法?Java Fragment.setInitialSavedState怎么用?Java Fragment.setInitialSavedState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.app.Fragment的用法示例。


在下文中一共展示了Fragment.setInitialSavedState方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: instantiateItem

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {
    final Fragment existing = fragments.get(position);
    if (existing != null) {
        return existing;
    }
    if (currentTransaction == null) {
        currentTransaction = fragmentManager.beginTransaction();
    }
    Fragment fragment = getItem(position);
    if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
    if (enableSavedStates && savedState.size() > position) {
        Fragment.SavedState fss = savedState.get(position);
        if (fss != null) {
            fragment.setInitialSavedState(fss);
        }
    }
    if (fragment != currentPrimaryItem) {
        setItemVisible(fragment, false);
    }
    fragments.put(position, fragment);
    currentTransaction.add(container.getId(), fragment);
    return fragment;
}
 
开发者ID:Laaidback,项目名称:A.scribe,代码行数:25,代码来源:FragmentStatePagerAdapter2.java

示例2: instantiateItem

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
@NonNull
public Object instantiateItem(ViewGroup container, int position) {
    long tag = getItemId(position);
    Fragment fragment = mFragments.get(tag);
    // 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 (fragment != null) {
        return fragment;
    }

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

    fragment = getItem(position);
    // restore state
    final Fragment.SavedState savedState = mSavedStates.get(tag);
    if (savedState != null) {
        fragment.setInitialSavedState(savedState);
    }
    fragment.setMenuVisibility(false);
    fragment.setUserVisibleHint(false);
    mFragments.put(tag, fragment);
    mCurTransaction.add(container.getId(), fragment, "f" + tag);

    return fragment;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:UpdatableFragmentPagerAdapter.java

示例3: instantiateItem

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@SuppressLint("CommitTransaction")
@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;
    }
  }

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

  Fragment fragment = getItem(position);
  if (DEBUG) Timber.v("Adding item #%d: f=%s", position, 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;
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:37,代码来源:FragmentStatePagerAdapter.java

示例4: instantiateItem

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@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;
        }
    }

    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;
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:36,代码来源:CustomFragmentStatePagerAdapter.java

示例5: removeToDetachFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private Fragment removeToDetachFragment(StateChange stateChange, Path key) {
    Fragment fragment = fragmentManager.findFragmentByTag(key.getFragmentTag());
    if(fragment != null && (fragment.isDetached() || fragment.getView() == null)) {
        FragmentTransaction fragmentTransaction = beginFragmentTransaction(stateChange);
        Fragment.SavedState savedState = fragmentManager.saveFragmentInstanceState(fragment);
        fragmentTransaction.remove(fragment);
        fragmentTransaction.commitNow();
        fragment.setInitialSavedState(savedState);
    }
    return fragment;
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:12,代码来源:MasterDetailFragmentStateChanger.java

示例6: instantiateItem

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@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 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);
        Fragment.SavedState fss = mSavedState.get(position);
        if (fss != null) {
            fragment.setInitialSavedState(fss);
        }
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
        mFragments.put(position, fragment);
        mCurTransaction.add(container.getId(), fragment);

        return fragment;
    }
 
开发者ID:snowwolf10285,项目名称:PicShow-zhaipin,代码行数:30,代码来源:FragmentListPageAdapter.java

示例7: instantiateItem

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@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 = getCurrentFragment(position);
        if (f != null) {
            return f;
        }
    }

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

    int currentViewMode = getCurrentViewMode(position);
    Fragment fragment = getItem(position, currentViewMode);
    // NEW: record the fragment's position and view mode
    viewModeMap.put(fragment, currentViewMode);
    positionMap.put(fragment, position);
    if (DEBUG)
        Log.v(TAG, "Adding item #" + position + "-" + currentViewMode + ": f=" + fragment);
    if (mSavedState.size() > position) {
        Fragment.SavedState fss = getCurrentSavedState(position);
        if (fss != null) {
            fragment.setInitialSavedState(fss);
        }
    }
    while (mFragments.size() <= position) {
        mFragments.add(null);
    }
    fragment.setMenuVisibility(false);
    fragment.setUserVisibleHint(false);
    setCurrentFragment(position, fragment);

    mCurTransaction.add(container.getId(), fragment);

    return fragment;
}
 
开发者ID:mocircle,项目名称:devsuite-android,代码行数:42,代码来源:MultiFragmentStatePagerAdapter.java


注:本文中的android.support.v4.app.Fragment.setInitialSavedState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。