topView回调调整

This commit is contained in:
tongchenfei
2020-05-27 17:27:49 +08:00
parent f469f59a16
commit 27d736e535

View File

@@ -7,6 +7,8 @@ import android.transition.TransitionManager;
import android.util.ArrayMap;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.BounceInterpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.ImageView;
import android.widget.TextView;
@@ -113,11 +115,14 @@ public class TopViewAnimHelper {
IMogoTopViewStatusListener listener;
if (isTopViewOut) {
listener = statusListenerMap.remove(currentAnimatingView);
}else{
if(listener!=null) {
listener.onViewRemoved(currentAnimatingView);
}
} else {
listener = statusListenerMap.get(currentAnimatingView);
}
if (listener != null) {
listener.onViewAdded(currentAnimatingView);
if(listener!=null) {
listener.onViewAdded(currentAnimatingView);
}
}
}
@@ -148,8 +153,9 @@ public class TopViewAnimHelper {
private View currentAnimatingView = null;
public void startTopInAnim(View view, ViewGroup.LayoutParams params, IMogoTopViewStatusListener statusListener) {
Logger.d(TAG, "startTopInAnim====="+isTopViewOut);
public void startTopInAnim(View view, ViewGroup.LayoutParams params,
IMogoTopViewStatusListener statusListener) {
Logger.d(TAG, "startTopInAnim=====" + isTopViewOut);
if (view == null) {
throw new IllegalArgumentException("method addTopView params view is null");
}
@@ -231,9 +237,9 @@ public class TopViewAnimHelper {
naviBg.getLayoutParams().height =
(int) topMotionLayout.getContext().getResources().getDimension(R.dimen.module_ext_navi_info_panel_small_height);
int scene = 0;
if(naviBg.getVisibility() == View.VISIBLE){
if (naviBg.getVisibility() == View.VISIBLE) {
scene = Scene.NAVI_WITH_ROAD_EVENT;
}else{
} else {
scene = Scene.AIMLESS_WITH_ROAD_EVENT;
}
Logger.d(TAG, "show top setMapCenterPointByScene: " + scene);
@@ -245,9 +251,9 @@ public class TopViewAnimHelper {
/**
* 退出最新的也就是最上面的view
*/
private void startLatestTopOutAnim(){
if (topContainer.getChildCount() > 0) {
startTopOutAnim(topContainer.getChildAt(topContainer.getChildCount() - 1));
private void startLatestTopOutAnim() {
if (topContainer.getChildCount() > 0) {
startTopOutAnim(topContainer.getChildAt(topContainer.getChildCount() - 1));
}
}
@@ -255,9 +261,10 @@ public class TopViewAnimHelper {
Logger.d("TopViewAnimHelper", "startTopOutAnim=====");
if (!isTopViewOut) {
if(topContainer.getChildCount() >1){
if (topContainer.getChildCount() > 1) {
// 顶部view包含多个view只推出当前view不进行整体上移
Logger.d(TAG, "小view退出: " + view.getTranslationY() + " height: " + view.getHeight());
Logger.d(TAG,
"小view退出: " + view.getTranslationY() + " height: " + view.getHeight());
view.animate().translationY(-(view.getHeight())).setDuration(500).setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -266,13 +273,13 @@ public class TopViewAnimHelper {
@Override
public void onAnimationEnd(Animator animation) {
Logger.d(TAG,"onAnimationEnd: "+view);
Logger.d(TAG, "onAnimationEnd: " + view);
viewCaches.remove(view);
topContainer.removeView(view);
IMogoTopViewStatusListener listener = statusListenerMap.remove(view);
if (listener != null) {
listener.onViewRemoved(view);
}else{
} else {
Logger.d(TAG, "listener is null");
}
}
@@ -288,7 +295,7 @@ public class TopViewAnimHelper {
}
}).start();
}else {
} else {
// 顶部view仅剩一个view需要整体上移
currentAnimatingView = view;
isTopViewOut = true;
@@ -299,7 +306,7 @@ public class TopViewAnimHelper {
}
constraintSet.clone(topMotionLayout);
constraintSet.clear(R.id.module_entrance_id_top_container,ConstraintSet.TOP);
constraintSet.clear(R.id.module_entrance_id_top_container, ConstraintSet.TOP);
constraintSet.connect(R.id.module_entrance_id_top_container, ConstraintSet.BOTTOM,
R.id.module_entrance_id_top_motion_layout, ConstraintSet.TOP);
TransitionManager.beginDelayedTransition(topMotionLayout, transition);
@@ -326,9 +333,9 @@ public class TopViewAnimHelper {
naviBg.getLayoutParams().height =
(int) topMotionLayout.getContext().getResources().getDimension(R.dimen.module_ext_navi_info_panel_height);
int scene = 0;
if(naviBg.getVisibility() == View.VISIBLE){
if (naviBg.getVisibility() == View.VISIBLE) {
scene = Scene.NAVI;
}else{
} else {
scene = Scene.AIMLESS;
}
Logger.d(TAG, "hide top setMapCenterPointByScene: " + scene);
@@ -399,9 +406,9 @@ public class TopViewAnimHelper {
remainTimeGroup.setVisibility(View.GONE);
arriveTimeGroup.setVisibility(View.GONE);
int scene = 0;
if(isTopViewOut){
if (isTopViewOut) {
scene = Scene.AIMLESS_WITH_ROAD_EVENT;
}else{
} else {
scene = Scene.AIMLESS;
}
Logger.d(TAG, "hide navi setMapCenterPointByScene: " + scene);