添加接口完成,此提交带了调试代码
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.mogo.module.extensions.entrance;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
@@ -10,7 +11,9 @@ import android.transition.AutoTransition;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionManager;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -112,7 +115,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
private IMogoAuthorizeModuleManager mIMogoAuthorizeModuleManager;
|
||||
private IMogoStatusManager mStatusManager;
|
||||
|
||||
private TopViewAnimHelper topViewAnimHelper;
|
||||
|
||||
/**
|
||||
* 搜索莫模块
|
||||
@@ -199,9 +201,13 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
mUploadRoadCondition.setOnClickListener( view -> {
|
||||
// todo 测试动画
|
||||
if (!naviToggle) {
|
||||
topViewAnimHelper.showNaviView();
|
||||
View v = LayoutInflater.from(getContext()).inflate(R.layout.demo_top, null);
|
||||
ViewGroup.LayoutParams params =
|
||||
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
(int) getResources().getDimension(R.dimen.dp_350));
|
||||
mApis.getTopViewManager().addTopView(v, params);
|
||||
}else{
|
||||
topViewAnimHelper.hideNaviView();
|
||||
mApis.getTopViewManager().removeTopView();
|
||||
}
|
||||
naviToggle = !naviToggle;
|
||||
// 原始逻辑
|
||||
@@ -230,9 +236,9 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
mMove2CurrentLocation.setOnClickListener( view -> {
|
||||
// todo 测试动画
|
||||
if (!toggle) {
|
||||
topViewAnimHelper.startTopInAnim();
|
||||
TopViewAnimHelper.getInstance().showNaviView();
|
||||
}else{
|
||||
topViewAnimHelper.startTopOutAnim();
|
||||
TopViewAnimHelper.getInstance().hideNaviView();
|
||||
}
|
||||
toggle = !toggle;
|
||||
// 原始逻辑
|
||||
@@ -251,7 +257,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
// mNaviInfo = findViewById( R.id.module_entrance_id_navi_info_panel );
|
||||
ConstraintLayout rootView = findViewById(R.id.module_entrance_id_top_motion_layout);
|
||||
if(rootView!=null) {
|
||||
topViewAnimHelper = new TopViewAnimHelper(rootView);
|
||||
TopViewAnimHelper.getInstance().init(rootView);
|
||||
}
|
||||
|
||||
mExitNavi = findViewById( R.id.module_entrance_id_exit_navi );
|
||||
@@ -278,13 +284,16 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
|
||||
mCameraMode = findViewById( R.id.module_ext_id_north );
|
||||
mCameraMode.setOnClickListener( view -> {
|
||||
if ( mCameraMode.isSelected() ) {
|
||||
mMApUIController.changeMapMode( EnumMapUI.CarUp_2D );
|
||||
} else {
|
||||
mMApUIController.changeMapMode( EnumMapUI.NorthUP_2D );
|
||||
}
|
||||
mCameraMode.setSelected( !mCameraMode.isSelected() );
|
||||
mCameraMode.setText( getString( mCameraMode.isSelected() ? R.string.mode_car_up : R.string.mode_north_up ) );
|
||||
// todo 测试动画
|
||||
TopViewAnimHelper.getInstance().debug();
|
||||
// 原始逻辑
|
||||
// if ( mCameraMode.isSelected() ) {
|
||||
// mMApUIController.changeMapMode( EnumMapUI.CarUp_2D );
|
||||
// } else {
|
||||
// mMApUIController.changeMapMode( EnumMapUI.NorthUP_2D );
|
||||
// }
|
||||
// mCameraMode.setSelected( !mCameraMode.isSelected() );
|
||||
// mCameraMode.setText( getString( mCameraMode.isSelected() ? R.string.mode_car_up : R.string.mode_north_up ) );
|
||||
} );
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mogo.module.extensions.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.res.Resources;
|
||||
import android.transition.AutoTransition;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionManager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -15,6 +18,8 @@ import androidx.constraintlayout.widget.Group;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
/**
|
||||
* 顶部动画帮助类
|
||||
@@ -30,22 +35,40 @@ public class TopViewAnimHelper {
|
||||
private ImageView ivTurnIcon;
|
||||
private TextView tvNextDistance;
|
||||
private TextView tvNextRoad;
|
||||
private FrameLayout topContainer;
|
||||
|
||||
private ConstraintSet constraintSet = new ConstraintSet();
|
||||
private Transition transition = new AutoTransition();
|
||||
private TextView cameraMode;
|
||||
|
||||
public TopViewAnimHelper(ConstraintLayout rootView) {
|
||||
this(rootView, null);
|
||||
private TopViewAnimHelper() {
|
||||
}
|
||||
|
||||
public TopViewAnimHelper(ConstraintLayout rootView, OnTopViewAnimSimpleListener listener) {
|
||||
private volatile static TopViewAnimHelper instance = null;
|
||||
|
||||
public static TopViewAnimHelper getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (TopViewAnimHelper.class) {
|
||||
if (instance == null) {
|
||||
instance = new TopViewAnimHelper();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void init(ConstraintLayout rootView) {
|
||||
init(rootView, null);
|
||||
}
|
||||
|
||||
public void init(ConstraintLayout rootView, OnTopViewAnimSimpleListener listener) {
|
||||
topMotionLayout = rootView;
|
||||
naviBg = rootView.findViewById(R.id.module_map_id_navi_bg);
|
||||
naviGroup = rootView.findViewById(R.id.naviGroup);
|
||||
remainTimeGroup = rootView.findViewById(R.id.remainTimeGroup);
|
||||
remainDistanceGroup = rootView.findViewById(R.id.remainDistanceGroup);
|
||||
arriveTimeGroup = rootView.findViewById(R.id.arriveTimeGroup);
|
||||
topContainer = rootView.findViewById(R.id.module_entrance_id_top_container);
|
||||
|
||||
ivTurnIcon = rootView.findViewById(R.id.module_map_id_navi_next_info_road_turn_icon);
|
||||
tvNextDistance = rootView.findViewById(R.id.module_map_id_navi_next_info_distance);
|
||||
@@ -62,6 +85,9 @@ public class TopViewAnimHelper {
|
||||
|
||||
@Override
|
||||
public void onTransitionEnd(Transition transition) {
|
||||
if (isTopViewOut) {
|
||||
topContainer.removeAllViews();
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onAnimEnd();
|
||||
}
|
||||
@@ -88,10 +114,13 @@ public class TopViewAnimHelper {
|
||||
|
||||
private boolean isTopViewOut = true;
|
||||
|
||||
public void startTopInAnim() {
|
||||
public void startTopInAnim(View view, ViewGroup.LayoutParams params) {
|
||||
Logger.d("TopViewAnimHelper", "startTopInAnim=====");
|
||||
if (isTopViewOut) {
|
||||
isTopViewOut = false;
|
||||
|
||||
topContainer.addView(view, params);
|
||||
|
||||
constraintSet.clone(topMotionLayout);
|
||||
|
||||
constraintSet.getConstraint(R.id.module_entrance_id_top_container).layout.bottomToTop = -1;
|
||||
@@ -186,7 +215,8 @@ public class TopViewAnimHelper {
|
||||
// ivTurnIcon.getLayoutParams().width =
|
||||
// (int) getDimen(R.dimen.module_ext_navi_info_panel_turn_icon_width);
|
||||
// naviBg.getLayoutParams().height =
|
||||
// (int) topMotionLayout.getContext().getResources().getDimension(R.dimen.module_ext_navi_info_panel_height);
|
||||
// (int) topMotionLayout.getContext().getResources().getDimension(R.dimen
|
||||
// .module_ext_navi_info_panel_height);
|
||||
constraintSet.applyTo(topMotionLayout);
|
||||
} else {
|
||||
remainDistanceGroup.setVisibility(View.GONE);
|
||||
@@ -207,7 +237,8 @@ public class TopViewAnimHelper {
|
||||
// ivTurnIcon.getLayoutParams().width =
|
||||
// (int) getDimen(R.dimen.module_ext_navi_info_panel_turn_icon_small_width);
|
||||
// naviBg.getLayoutParams().height =
|
||||
// (int) topMotionLayout.getContext().getResources().getDimension(R.dimen.module_ext_navi_info_panel_small_height);
|
||||
// (int) topMotionLayout.getContext().getResources().getDimension(R.dimen
|
||||
// .module_ext_navi_info_panel_small_height);
|
||||
constraintSet.applyTo(topMotionLayout);
|
||||
}
|
||||
|
||||
@@ -233,7 +264,8 @@ public class TopViewAnimHelper {
|
||||
} else {
|
||||
if (isTopViewOut) {
|
||||
constraintSet.connect(cameraMode.getId(), ConstraintSet.TOP, naviBg.getId(),
|
||||
ConstraintSet.BOTTOM, (int) getDimen(R.dimen.module_ext_north_goneMarginTop));
|
||||
ConstraintSet.BOTTOM,
|
||||
(int) getDimen(R.dimen.module_ext_north_goneMarginTop));
|
||||
} else {
|
||||
constraintSet.connect(cameraMode.getId(), ConstraintSet.TOP,
|
||||
R.id.module_entrance_id_top_container,
|
||||
@@ -255,4 +287,12 @@ public class TopViewAnimHelper {
|
||||
|
||||
void onAnimEnd();
|
||||
}
|
||||
|
||||
private int[] iconRes = new int[]{R.drawable.ic_1, R.drawable.ic_2, R.drawable.ic_3};
|
||||
|
||||
public void debug() {
|
||||
Random random = new Random();
|
||||
int index = random.nextInt(3);
|
||||
ivTurnIcon.setImageResource(iconRes[index]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.mogo.module.extensions.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.windowview.IMogoTopViewManager;
|
||||
|
||||
/**
|
||||
* 顶部1/2界面管理
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_EXTENSIONS_TOP_VIEW_MANAGER)
|
||||
public class TopViewManager implements IMogoTopViewManager {
|
||||
|
||||
@Override
|
||||
public void addTopView(View view, ViewGroup.LayoutParams params) {
|
||||
if (view == null) {
|
||||
throw new IllegalArgumentException("method addTopView params view is null");
|
||||
}
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("method addTopView params LayoutParams is null");
|
||||
}
|
||||
TopViewAnimHelper.getInstance().startTopInAnim(view, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTopView() {
|
||||
TopViewAnimHelper.getInstance().startTopOutAnim();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user