增加两个动画回调接口

This commit is contained in:
tongchenfei
2020-06-16 19:33:52 +08:00
parent c40df5ee4d
commit 67c7fd8e87
2 changed files with 24 additions and 1 deletions

View File

@@ -184,6 +184,9 @@ public class TopViewAnimHelper {
topContainer.addView(view, params);
Logger.d(TAG, "顶部view已经有布局了增加新增view滑入动画: " + view.getTranslationY() + " height:" +
" " + view.getHeight() + " paramsHeight: " + params.height);
if (statusListenerMap.get(view) != null) {
statusListenerMap.get(view).beforeViewAddAnim(view);
}
view.animate().translationY(0).setDuration(500).setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -217,7 +220,9 @@ public class TopViewAnimHelper {
// tvNextRoad.setTextSize(getDimen(R.dimen.dp_34));
// }
topContainer.addView(view, params);
if (statusListenerMap.get(view) != null) {
statusListenerMap.get(view).beforeViewAddAnim(view);
}
topContainer.setChildAddedListener(child -> {
if (naviBg.getVisibility() == View.VISIBLE) {
remainDistanceGroup.setVisibility(View.GONE);
@@ -300,6 +305,9 @@ public class TopViewAnimHelper {
// 顶部view包含多个view只推出当前view不进行整体上移
Logger.d(TAG,
"小view退出: " + view.getTranslationY() + " height: " + view.getHeight());
if (statusListenerMap.get(view) != null) {
statusListenerMap.get(view).beforeViewRemoveAnim(view);
}
view.animate().translationY(-(view.getHeight())).setDuration(500).setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -333,6 +341,9 @@ public class TopViewAnimHelper {
} else {
// 顶部view仅剩一个view需要整体上移
currentAnimatingView = view;
if (statusListenerMap.get(view) != null) {
statusListenerMap.get(view).beforeViewRemoveAnim(view);
}
isTopViewOut = true;
// if (naviBg.getVisibility() == View.VISIBLE) {
// tvNextRoad.setTextSize(getDimen(R.dimen

View File

@@ -19,4 +19,16 @@ public interface IMogoTopViewStatusListener {
* @param view 移除的view
*/
void onViewRemoved(View view);
/**
* view添加动画开始之前
* @param view 添加的view
*/
void beforeViewAddAnim(View view);
/**
* view 移除动画开始之前
* @param view 移除的view
*/
void beforeViewRemoveAnim(View view);
}