添加动画帮助类
This commit is contained in:
@@ -46,6 +46,7 @@ import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.navi.NaviInfoView;
|
||||
import com.mogo.module.extensions.navi.NaviInfoView2;
|
||||
import com.mogo.module.extensions.utils.TopViewAnimHelper;
|
||||
import com.mogo.module.share.ShareControl;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
@@ -110,8 +111,8 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
private EntrancePresenter mEntrancePresenter;
|
||||
private IMogoAuthorizeModuleManager mIMogoAuthorizeModuleManager;
|
||||
private IMogoStatusManager mStatusManager;
|
||||
private ConstraintLayout topMotionLayout;
|
||||
private NaviInfoView2 naviInfoView;
|
||||
|
||||
private TopViewAnimHelper topViewAnimHelper;
|
||||
|
||||
/**
|
||||
* 搜索莫模块
|
||||
@@ -174,6 +175,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
private Rect mDisplayOverviewBounds;
|
||||
|
||||
private boolean toggle = false;
|
||||
private boolean naviToggle = false;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -196,36 +198,12 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
mUploading = findViewById( R.id.module_entrance_id_uploading );
|
||||
mUploadRoadCondition.setOnClickListener( view -> {
|
||||
// todo 测试动画
|
||||
naviInfoView.setVisibility(View.VISIBLE);
|
||||
|
||||
ConstraintSet beginSet = new ConstraintSet();
|
||||
beginSet.clone(topMotionLayout);
|
||||
ConstraintSet endSet = new ConstraintSet();
|
||||
endSet.clone(topMotionLayout);
|
||||
|
||||
beginSet.getConstraint(R.id.module_entrance_id_top_container).layout.bottomToTop =
|
||||
R.id.module_entrance_id_top_motion_layout;
|
||||
beginSet.getConstraint(R.id.module_entrance_id_top_container).layout.topToTop = -1;
|
||||
|
||||
endSet.getConstraint(R.id.module_entrance_id_top_container).layout.bottomToTop = -1;
|
||||
endSet.getConstraint(R.id.module_entrance_id_top_container).layout.topToTop =
|
||||
R.id.module_entrance_id_top_motion_layout;
|
||||
// topMotionLayout.setScene(hasNaviScene);
|
||||
Transition transition = new AutoTransition();
|
||||
transition.setDuration(500);
|
||||
TransitionManager.beginDelayedTransition(topMotionLayout,transition);
|
||||
if(!toggle) {
|
||||
endSet.applyTo(topMotionLayout);
|
||||
naviInfoView.getLayoutParams().height =
|
||||
(int) getResources().getDimension(R.dimen.module_ext_navi_info_panel_small_height);
|
||||
// naviInfoView.transitionToEnd();
|
||||
if (!naviToggle) {
|
||||
topViewAnimHelper.showNaviView();
|
||||
}else{
|
||||
beginSet.applyTo(topMotionLayout);
|
||||
naviInfoView.getLayoutParams().height =
|
||||
(int) getResources().getDimension(R.dimen.module_ext_navi_info_panel_height);
|
||||
// naviInfoView.transitionToStart();
|
||||
topViewAnimHelper.hideNaviView();
|
||||
}
|
||||
toggle = !toggle;
|
||||
naviToggle = !naviToggle;
|
||||
// 原始逻辑
|
||||
// isClickShare = true;
|
||||
// if ( mIMogoAuthorizeModuleManager.needAuthorize( AUTHORIZE_TYPE_LAUNCHER_SHARE ) ) {
|
||||
@@ -236,9 +214,6 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
// }
|
||||
} );
|
||||
|
||||
topMotionLayout = findViewById(R.id.module_entrance_id_top_motion_layout);
|
||||
naviInfoView = findViewById(R.id.mlNaviInfo);
|
||||
|
||||
mDisplayOverview = findViewById( R.id.module_ext_id_display_overview );
|
||||
mDisplayOverviewText = findViewById( R.id.module_ext_id_display_overview_text );
|
||||
mDisplayOverviewIcon = findViewById( R.id.module_ext_id_display_overview_icon );
|
||||
@@ -254,26 +229,10 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
|
||||
mMove2CurrentLocation = findViewById( R.id.module_entrance_id_move2_current_location );
|
||||
mMove2CurrentLocation.setOnClickListener( view -> {
|
||||
// todo 测试动画
|
||||
naviInfoView.setVisibility(View.GONE);
|
||||
|
||||
ConstraintSet beginSet = new ConstraintSet();
|
||||
beginSet.clone(topMotionLayout);
|
||||
ConstraintSet endSet = new ConstraintSet();
|
||||
endSet.clone(topMotionLayout);
|
||||
|
||||
beginSet.getConstraint(R.id.module_entrance_id_top_container).layout.bottomToTop =
|
||||
R.id.module_entrance_id_top_motion_layout;
|
||||
beginSet.getConstraint(R.id.module_entrance_id_top_container).layout.topToTop = -1;
|
||||
|
||||
endSet.getConstraint(R.id.module_entrance_id_top_container).layout.bottomToTop = -1;
|
||||
endSet.getConstraint(R.id.module_entrance_id_top_container).layout.topToTop =
|
||||
R.id.module_entrance_id_top_motion_layout;
|
||||
// topMotionLayout.setScene(hasNaviScene);
|
||||
TransitionManager.beginDelayedTransition(topMotionLayout);
|
||||
if(!toggle) {
|
||||
endSet.applyTo(topMotionLayout);
|
||||
if (!toggle) {
|
||||
topViewAnimHelper.startTopInAnim();
|
||||
}else{
|
||||
beginSet.applyTo(topMotionLayout);
|
||||
topViewAnimHelper.startTopOutAnim();
|
||||
}
|
||||
toggle = !toggle;
|
||||
// 原始逻辑
|
||||
@@ -290,6 +249,11 @@ 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);
|
||||
}
|
||||
|
||||
mExitNavi = findViewById( R.id.module_entrance_id_exit_navi );
|
||||
mExitNavi.setOnClickListener( view -> {
|
||||
if ( mMogoNavi != null ) {
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.mogo.module.extensions.utils;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.transition.AutoTransition;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionManager;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.ConstraintSet;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* 顶部动画帮助类
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class TopViewAnimHelper {
|
||||
|
||||
private ConstraintLayout topMotionLayout;
|
||||
private Group naviGroup,remainTimeGroup,remainDistanceGroup, arriveTimeGroup;
|
||||
private View naviBg;
|
||||
|
||||
private ConstraintSet constraintSet = new ConstraintSet();
|
||||
private Transition transition = new AutoTransition();
|
||||
|
||||
public TopViewAnimHelper(ConstraintLayout rootView) {
|
||||
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);
|
||||
transition.setDuration(2000);
|
||||
}
|
||||
|
||||
private boolean isTopViewOut = true;
|
||||
|
||||
public void startTopInAnim(){
|
||||
Logger.d("TopViewAnimHelper", "startTopInAnim=====");
|
||||
if(isTopViewOut) {
|
||||
constraintSet.clone(topMotionLayout);
|
||||
|
||||
constraintSet.getConstraint(R.id.module_entrance_id_top_container).layout.bottomToTop = -1;
|
||||
constraintSet.getConstraint(R.id.module_entrance_id_top_container).layout.topToTop =
|
||||
R.id.module_entrance_id_top_motion_layout;
|
||||
|
||||
TransitionManager.beginDelayedTransition(topMotionLayout, transition);
|
||||
constraintSet.applyTo(topMotionLayout);
|
||||
if(naviGroup.getVisibility() == View.VISIBLE) {
|
||||
remainDistanceGroup.setVisibility(View.GONE);
|
||||
remainTimeGroup.setVisibility(View.GONE);
|
||||
arriveTimeGroup.setVisibility(View.GONE);
|
||||
}
|
||||
naviBg.getLayoutParams().height =
|
||||
(int) topMotionLayout.getContext().getResources().getDimension(R.dimen.module_ext_navi_info_panel_small_height);
|
||||
isTopViewOut = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void startTopOutAnim(){
|
||||
Logger.d("TopViewAnimHelper", "startTopOutAnim=====");
|
||||
if(!isTopViewOut) {
|
||||
constraintSet.clone(topMotionLayout);
|
||||
|
||||
constraintSet.getConstraint(R.id.module_entrance_id_top_container).layout.bottomToTop =
|
||||
R.id.module_entrance_id_top_motion_layout;
|
||||
constraintSet.getConstraint(R.id.module_entrance_id_top_container).layout.topToTop = -1;
|
||||
TransitionManager.beginDelayedTransition(topMotionLayout, transition);
|
||||
constraintSet.applyTo(topMotionLayout);
|
||||
if(naviGroup.getVisibility() == View.VISIBLE) {
|
||||
remainDistanceGroup.setVisibility(View.VISIBLE);
|
||||
remainTimeGroup.setVisibility(View.VISIBLE);
|
||||
arriveTimeGroup.setVisibility(View.VISIBLE);
|
||||
}
|
||||
naviBg.getLayoutParams().height =
|
||||
(int) topMotionLayout.getContext().getResources().getDimension(R.dimen.module_ext_navi_info_panel_height);
|
||||
isTopViewOut = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void showNaviView(){
|
||||
Logger.d("TopViewAnimHelper", "showNaviView=====");
|
||||
naviGroup.setVisibility(View.VISIBLE);
|
||||
if (isTopViewOut) {
|
||||
remainDistanceGroup.setVisibility(View.VISIBLE);
|
||||
remainTimeGroup.setVisibility(View.VISIBLE);
|
||||
arriveTimeGroup.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
remainDistanceGroup.setVisibility(View.GONE);
|
||||
remainTimeGroup.setVisibility(View.GONE);
|
||||
arriveTimeGroup.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void hideNaviView(){
|
||||
Logger.d("TopViewAnimHelper", "hideNaviView=====");
|
||||
naviGroup.setVisibility(View.GONE);
|
||||
remainDistanceGroup.setVisibility(View.GONE);
|
||||
remainTimeGroup.setVisibility(View.GONE);
|
||||
arriveTimeGroup.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user