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


Java FragmentTransaction.commitAllowingStateLoss方法代码示例

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


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

示例1: reloadData

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
/**
 * 重新加载数据
 *
 * @param newListFragments 新的fragment集合
 * @param newSelectedList  新的选中分类集合
 */
public void reloadData(List<? extends BaseFragment> newListFragments, List<ColumnBean> newSelectedList) {

    // 每次刷新顺序都需要清除缓存
    if (mListFragments.size() > 0) {
        FragmentTransaction ft = mFm.beginTransaction();
        for (Fragment f :
                mListFragments) {
            ft.remove(f);
        }
        ft.commitAllowingStateLoss();
        mFm.executePendingTransactions();
    }

    // 清除原有数据源
    mListFragments.clear();
    mSelectedList.clear();

    // 重新添加数据源
    mListFragments.addAll(newListFragments);
    mSelectedList.addAll(newSelectedList);

    // 刷新数据
    notifyDataSetChanged();
}
 
开发者ID:6ag,项目名称:LiuAGeAndroid,代码行数:31,代码来源:TabFragmentPagerAdapter.java

示例2: addFragments

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public void addFragments(Fragment... fragments) {
    if (fragments != null && fragments.length != 0) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        for (Fragment fragment : fragments) {
            if (fragment instanceof LetvFragmentListener) {
                LetvFragmentListener listener = (LetvFragmentListener) fragment;
                String tag = listener.getTagName();
                if (!TextUtils.isEmpty(tag)) {
                    int fragmentRes = listener.getContainerId();
                    if (fragmentRes > 0 && fragmentManager.findFragmentByTag(tag) == null) {
                        transaction.add(fragmentRes, fragment, tag);
                    }
                }
            }
        }
        try {
            transaction.commitAllowingStateLoss();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:24,代码来源:LetvBaseActivity.java

示例3: changeFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public static void changeFragment(FragmentActivity activity, Fragment nextFragment, boolean addToBackStack) {
        String name = nextFragment.getClass().getSimpleName();

        final FragmentManager fragmentManager = activity.getSupportFragmentManager();

        final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.setCustomAnimations(R.anim.slide_left_in, R.anim.slide_right_in, R.anim.slide_left_out, R.anim.slide_right_out);

        fragmentTransaction.replace(R.id.frame_content, nextFragment);

        if (addToBackStack) {
            fragmentTransaction.addToBackStack(name);
        }
        try {
            fragmentTransaction.commitAllowingStateLoss();
            fragmentManager.executePendingTransactions();
        } catch (IllegalStateException e) {
        }

}
 
开发者ID:Ubudu,项目名称:GoogleMapsLayout-Android,代码行数:21,代码来源:FragmentUtils.java

示例4: showAlreadyOpenDialog

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
@TargetApi(17)
private void showAlreadyOpenDialog() {
    FragmentManager fm = getSupportFragmentManager();
    if (fm != null && getActivity() != null && !getActivity().isDestroyed()) {
        FragmentTransaction ft = fm.beginTransaction();
        this.mAlipayAutoPayAlreadyOpenDialog = (AlipayAutoPayAlreadyOpenDialog) fm.findFragmentByTag("showmAlipayAutoPayAlreadyOpenDialog");
        if (this.mAlipayAutoPayAlreadyOpenDialog == null) {
            this.mAlipayAutoPayAlreadyOpenDialog = new AlipayAutoPayAlreadyOpenDialog();
        } else {
            ft.remove(this.mAlipayAutoPayAlreadyOpenDialog);
        }
        this.mAlipayAutoPayAlreadyOpenDialog.setAlipayConfirmCallback(this);
        ft.add(this.mAlipayAutoPayAlreadyOpenDialog, "showmAlipayAutoPayAlreadyOpenDialog");
        ft.commitAllowingStateLoss();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:17,代码来源:VipOrderDetailActivity.java

示例5: finish

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public void finish() {
    super.finish();
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    for (int key : sActualFragments.keySet()) {
        Fragment fragment = getSupportFragmentManager().findFragmentByTag(key + "_key");
        if (fragment != null) {
            fragmentTransaction.remove(fragment);
        }
    }
    fragmentTransaction.commitAllowingStateLoss();
    if (mAdsFetcher != null) {
        mAdsFetcher.cancel();
    }
    RootUtils.closeSU();
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:17,代码来源:NavigationActivity.java

示例6: onSwitchInputUrl

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public void onSwitchInputUrl() {
    setCenterTitle("输入地址");
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    hiddenOnLineFragment(ft);
    hiddenLocalVideoFragment(ft);
    hiddenLocalVideoPlayGoFragment(ft);
    hiddenOutlineFragment(ft);
    if(inputUrlFragment==null){
        inputUrlFragment = new InputUrlFragment();
        ft.add(getUserContentHolder().getContainer().getId(),inputUrlFragment);
    }else{
        ft.show(inputUrlFragment);
    }
    ft.commitAllowingStateLoss();
}
 
开发者ID:jiajunhui,项目名称:PlayerBase,代码行数:17,代码来源:HomeActivity.java

示例7: showFilterDialog

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public static void showFilterDialog(FragmentManager fm, boolean isMuzei) {
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag(TAG);
    if (prev != null) {
        ft.remove(prev);
    }

    ft.add(newInstance(isMuzei), TAG)
            .setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);

    try {
        ft.commit();
    } catch (IllegalStateException e) {
        ft.commitAllowingStateLoss();
    }
}
 
开发者ID:danimahardhika,项目名称:wallpaperboard,代码行数:17,代码来源:FilterFragment.java

示例8: processRestoreInstanceState

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void processRestoreInstanceState(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        FragmentTransaction ft = mFragment.getFragmentManager().beginTransaction();
        if (mIsHidden) {
            ft.hide(mFragment);
        } else {
            ft.show(mFragment);
        }
        ft.commitAllowingStateLoss();
    }
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:12,代码来源:SupportFragmentDelegate.java

示例9: replaceFragmentWithBackStack

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
/**
     * 替换fragement 并添加动画
     * 替换fragement的同时对fragment进行“入back栈”操作 ,据我所知并不是真正的进入内存栈
     *
     * @param id_content
     * @param anim_in
     * @param anim_out
     * @param fragment
     */
    @Deprecated
    public void replaceFragmentWithBackStack(@IdRes int id_content, @AnimRes int anim_in, @AnimRes int anim_out, Fragment fragment) {
        String tag = fragment.getClass().getSimpleName();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
//        transaction.setCustomAnimations(anim_in, anim_out);
        transaction.replace(id_content, fragment, tag);
        //记录commit一次操作,与mFragmentManager.popBackStack();匹配使用
        transaction.addToBackStack(tag);
        //commitAllowingStateLoss 优于 commit 方法,当使用commit方法时,系统将进行状态判断,如果状态(mStateSaved)已经保存,将发生"Can not perform this action after onSaveInstanceState"错误。
        //如果mNoTransactionsBecause已经存在,将发生"Can not perform this action inside of " + mNoTransactionsBecause错误。
        transaction.commitAllowingStateLoss();
    }
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:22,代码来源:BActivity.java

示例10: onCreate

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ad);
    String type = getIntent().getStringExtra("type");
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.fragment_container, BetListFragment.newInstance(1, type));
    transaction.commitAllowingStateLoss();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:BetAllActivity.java

示例11: show

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public static void show(FragmentManager fm, DocumentInfo doc) {
	final Bundle args = new Bundle();
	args.putParcelable(EXTRA_DOC, doc);
	
	final DetailFragment fragment = new DetailFragment();
	fragment.setArguments(args);

	final FragmentTransaction ft = fm.beginTransaction();
	ft.replace(R.id.container_info, fragment, TAG_DETAIL);
	ft.commitAllowingStateLoss();
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:12,代码来源:DetailFragment.java

示例12: removeDialogFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
protected void removeDialogFragment(){
    FragmentManager fm=getSupportFragmentManager();
    FragmentTransaction ft=fm.beginTransaction();
    List<Fragment> fragments=fm.getFragments();
    if (fragments==null){
        return;
    }
    for (Fragment fragment:fragments){
        if (fragment instanceof DialogFragment){
            ft.remove(fragment);
        }
    }
    ft.commitAllowingStateLoss();
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:15,代码来源:BaseActivity.java

示例13: removeCurrentFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void removeCurrentFragment() {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

    Fragment currentFrag = getSupportFragmentManager()
            .findFragmentById(R.id.mainContainer);

    if (currentFrag != null) {
        transaction.remove(currentFrag);
    }
    transaction.commitAllowingStateLoss();
}
 
开发者ID:hdpavan,项目名称:FragmentTransaction,代码行数:12,代码来源:MainActivity.java

示例14: replaceFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public void replaceFragment(Fragment fragment, final boolean addToBackStack) {
    final String fragmentName = fragment.getClass().getName();
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    if (addToBackStack) {
        ft.addToBackStack(fragmentName);
    }
    ft.replace(getFragmentTransactionReplacementResource(), fragment, fragmentName);
    if (!(this.isDestroyed() || isFinishing())) {
        ft.commitAllowingStateLoss();
    }
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:12,代码来源:BaseFragmentActivity.java

示例15: addFragmentToActivity

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 */

public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager,
                                         @NonNull Fragment fragment, int frameId, String tag, int enterAnimation, int exitAnimation,
                                         int popEnter, int popExit) {

    checkNotNull(fragmentManager);
    checkNotNull(fragment);

    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.setCustomAnimations(enterAnimation, exitAnimation, popEnter, popExit);
    fragmentTransaction.replace(frameId, fragment, tag);
    fragmentTransaction.addToBackStack(null);
    fragmentTransaction.commitAllowingStateLoss();
}
 
开发者ID:sciage,项目名称:FinalProject,代码行数:19,代码来源:ActivityUtils.java


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