Skip to content

Commit

Permalink
增加removeWithAnimation接口
Browse files Browse the repository at this point in the history
  • Loading branch information
weikaiyun committed Jan 13, 2021
1 parent c138969 commit ade9514
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()出栈
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit ade9514

Please sign in to comment.