项目:aarLibrary
文件:FragmentationDelegate.java
/**
* 解决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);
}
});
}
项目:aarLibrary
文件:FragmentationDelegate.java
/**
* 分发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,transactionRecord == null ? null : transactionRecord.sharedElementList);
break;
case TYPE_ADD_WITH_POP:
if (from != null) {
startWithPop(fragmentManager,toFragmentTag);
}
break;
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。