diff --git a/fragmentation/src/main/java/com/weikaiyun/fragmentation/ExtraTransaction.java b/fragmentation/src/main/java/com/weikaiyun/fragmentation/ExtraTransaction.java index 0397c71..f89b18c 100644 --- a/fragmentation/src/main/java/com/weikaiyun/fragmentation/ExtraTransaction.java +++ b/fragmentation/src/main/java/com/weikaiyun/fragmentation/ExtraTransaction.java @@ -60,7 +60,9 @@ public abstract ExtraTransaction setCustomAnimations(@AnimatorRes @AnimRes int t public abstract void replaceChild(ISupportFragment toFragment); public abstract void remove(ISupportFragment toFragment); + public abstract void removeWithAnimation(ISupportFragment toFragment, int targetFragmentExit); public abstract void removeChild(ISupportFragment toFragment); + public abstract void removeChildWithAnimation(ISupportFragment toFragment, int targetFragmentExit); /** * 使用setTag()自定义Tag时,使用下面popTo()/popToChild()出栈 @@ -157,11 +159,21 @@ public void remove(ISupportFragment toFragment) { mTransactionDelegate.remove(getFragmentManager(), toFragment); } + @Override + public void removeWithAnimation(ISupportFragment toFragment, int targetFragmentExit) { + mTransactionDelegate.remove(getFragmentManager(), toFragment, targetFragmentExit); + } + @Override public void removeChild(ISupportFragment toFragment) { mTransactionDelegate.remove(getChildFragmentManager(), toFragment); } + @Override + public void removeChildWithAnimation(ISupportFragment toFragment, int targetFragmentExit) { + mTransactionDelegate.remove(getChildFragmentManager(), toFragment, targetFragmentExit); + } + @Override public void popTo(String targetFragmentTag, boolean includeTargetFragment) { popTo(targetFragmentTag, includeTargetFragment, null); diff --git a/fragmentation/src/main/java/com/weikaiyun/fragmentation/TransactionDelegate.java b/fragmentation/src/main/java/com/weikaiyun/fragmentation/TransactionDelegate.java index 70e7117..105b3ee 100644 --- a/fragmentation/src/main/java/com/weikaiyun/fragmentation/TransactionDelegate.java +++ b/fragmentation/src/main/java/com/weikaiyun/fragmentation/TransactionDelegate.java @@ -119,6 +119,18 @@ public void run() { }); } + void remove(final FragmentManager fm, final ISupportFragment toFragment, final int targetFragmentExit) { + enqueue(fm, new Action(Action.ACTION_POP) { + @Override + public void run() { + FragmentTransaction ft = fm.beginTransaction(); + ft.setCustomAnimations(0, targetFragmentExit, 0, 0); + ft.remove((Fragment) toFragment); + supportCommit(fm, ft); + } + }); + } + /** * Dispatch the start transaction. */