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


Java FragmentTransactionBugFixHack类代码示例

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


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

示例1: popToFix

import android.support.v4.app.FragmentTransactionBugFixHack; //导入依赖的package包/类
/**
 * 解决popTo多个fragment时动画引起的异常问题
 */
private void popToFix(String fragmentTag, int flag, final FragmentManager fragmentManager) {
    if (fragmentManager.getFragments() == null) return;

    mActivity.preparePopMultiple();
    fragmentManager.popBackStackImmediate(fragmentTag, flag);
    mActivity.popFinish();

    mHandler.post(new Runnable() {
        @Override
        public void run() {
            FragmentTransactionBugFixHack.reorderIndices(fragmentManager);
        }
    });
}
 
开发者ID:LonelyMushroom,项目名称:aarLibrary,代码行数:18,代码来源:FragmentationDelegate.java

示例2: dispatchStartTransaction

import android.support.v4.app.FragmentTransactionBugFixHack; //导入依赖的package包/类
/**
 * 分发start事务
 *
 * @param from        当前Fragment
 * @param to          目标Fragment
 * @param requestCode requestCode
 * @param launchMode  启动模式
 * @param type        类型
 */
void dispatchStartTransaction(FragmentManager fragmentManager, SupportFragment from, SupportFragment to, int requestCode, int launchMode, int type) {
    fragmentManager = checkFragmentManager(fragmentManager, from);
    if (fragmentManager == null) return;

    if ((from != null && from.isRemoving())) {
        Log.e(TAG, from.getClass().getSimpleName() + " is poped, maybe you want to call startWithPop()!");
        return;
    }

    checkNotNull(to, "toFragment == null");

    if (from != null) {
        bindContainerId(from.getContainerId(), to);
    }

    // process SupportTransaction
    String toFragmentTag = to.getClass().getName();
    TransactionRecord transactionRecord = to.getTransactionRecord();
    if (transactionRecord != null) {
        if (transactionRecord.tag != null) {
            toFragmentTag = transactionRecord.tag;
        }

        if (transactionRecord.requestCode != null && transactionRecord.requestCode != 0) {
            requestCode = transactionRecord.requestCode;
            type = TYPE_ADD_RESULT;
        }

        if (transactionRecord.launchMode != null) {
            launchMode = transactionRecord.launchMode;
        }

        if (transactionRecord.withPop != null && transactionRecord.withPop) {
            type = TYPE_ADD_WITH_POP;
        }

        // 这里发现使用addSharedElement时,在被强杀重启时导致栈内顺序异常,这里进行一次hack顺序
        if (transactionRecord.sharedElementList != null) {
            FragmentTransactionBugFixHack.reorderIndices(fragmentManager);
        }
    }

    if (type == TYPE_ADD_RESULT) {
        saveRequestCode(to, requestCode);
    }

    if (handleLaunchMode(fragmentManager, to, toFragmentTag, launchMode)) return;

    switch (type) {
        case TYPE_ADD:
        case TYPE_ADD_RESULT:
            start(fragmentManager, from, to, toFragmentTag, transactionRecord == null ? null : transactionRecord.sharedElementList);
            break;
        case TYPE_ADD_WITH_POP:
            if (from != null) {
                startWithPop(fragmentManager, from, to, toFragmentTag);
            }
            break;
    }
}
 
开发者ID:LonelyMushroom,项目名称:aarLibrary,代码行数:70,代码来源:FragmentationDelegate.java


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