Merge remote-tracking branch 'origin/dev_merge_shunyi_vr_map' into dev_merge_shunyi_vr_map
This commit is contained in:
@@ -60,10 +60,14 @@ class MarkerDrawer {
|
||||
}
|
||||
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, IMogoMarkerClickListener listener ) {
|
||||
return drawMapMarkerImpl(markerShowEntity, zIndex, 0, listener);
|
||||
}
|
||||
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, int icon3DRes, IMogoMarkerClickListener listener ) {
|
||||
if ( markerShowEntity == null || markerShowEntity.getMarkerLocation() == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoMarkerOptions options = new MogoMarkerOptions().owner( markerShowEntity.getMarkerType() ).zIndex( zIndex ).object( markerShowEntity ).latitude( markerShowEntity.getMarkerLocation().getLat() ).longitude( markerShowEntity.getMarkerLocation().getLon() );
|
||||
MogoMarkerOptions options = new MogoMarkerOptions().icon3DRes( icon3DRes ).owner( markerShowEntity.getMarkerType() ).zIndex( zIndex ).object( markerShowEntity ).latitude( markerShowEntity.getMarkerLocation().getLat() ).longitude( markerShowEntity.getMarkerLocation().getLon() );
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView( AbsMogoApplication.getApp(), markerShowEntity, options );
|
||||
if ( markerView instanceof OnlineCarMarkerView ) {
|
||||
try {
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.entity.MarkerCarPois;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.MarkerOnlineCar;
|
||||
@@ -104,7 +105,7 @@ class OnlineCarDrawer {
|
||||
String sn = MarkerDrawer.getInstance().getPrimaryKeyFromEntity( markerOnlineCar );
|
||||
IMogoMarker mogoMarker = existCarMap.get( sn );
|
||||
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_LOW, listener );
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_LOW, R.raw.taxi, listener );
|
||||
}
|
||||
if ( mogoMarker != null ) {
|
||||
mogoMarker.setVisible( true );
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.anim.OnMarkerAnimationListener;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.drawer.marker.RoadConditionInfoWindow3DAdapter;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
@@ -84,10 +85,16 @@ class RoadConditionDrawer {
|
||||
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
|
||||
Logger.d( TAG, "draw road condition, sn = %s", sn );
|
||||
try {
|
||||
if ( DebugConfig.isRoadEventAnimated() ) {
|
||||
post2AddAndStartAnimation( markerShowEntity, i * 100L, listener );
|
||||
} else {
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
|
||||
mogoMarker.setInfoWindowAdapter( new RoadConditionInfoWindow3DAdapter( markerShowEntity, AbsMogoApplication.getApp(), mogoMarker.getMogoMarkerOptions() ) );
|
||||
mogoMarker.showInfoWindow();
|
||||
} else {
|
||||
if ( DebugConfig.isRoadEventAnimated() ) {
|
||||
post2AddAndStartAnimation( markerShowEntity, i * 100L, listener );
|
||||
} else {
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
|
||||
}
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.mogo.module.common.drawer.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/16
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class EmptyMarkerView extends View implements IMarkerView {
|
||||
|
||||
public EmptyMarkerView( Context context ) {
|
||||
this( context, null );
|
||||
}
|
||||
|
||||
public EmptyMarkerView( Context context, @Nullable AttributeSet attrs ) {
|
||||
this( context, attrs, 0 );
|
||||
}
|
||||
|
||||
public EmptyMarkerView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarker( IMogoMarker marker ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure( int widthMeasureSpec, int heightMeasureSpec ) {
|
||||
setMeasuredDimension( 1, 1 );
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
|
||||
/**
|
||||
@@ -23,17 +24,36 @@ public class MapMarkerAdapter {
|
||||
* @param markerShowEntity 要填充的数据
|
||||
* @return MarkerView
|
||||
*/
|
||||
public static IMarkerView getMarkerView(Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options) {
|
||||
public static IMarkerView getMarkerView( Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options ) {
|
||||
|
||||
if ( TextUtils.equals( markerShowEntity.getMarkerType(), ModuleNames.CARD_TYPE_USER_DATA ) ) {
|
||||
return OnlineCarMarkerView.getInstance();
|
||||
} else {
|
||||
if (markerShowEntity.isChecked()) {
|
||||
return new MapMarkerInfoView(context, markerShowEntity, options);
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
return new EmptyMarkerView( context );
|
||||
} else {
|
||||
return new MapMarkerView(context, markerShowEntity, options);
|
||||
if ( markerShowEntity.isChecked() ) {
|
||||
return new MapMarkerInfoView( context, markerShowEntity, options );
|
||||
} else {
|
||||
return new MapMarkerView( context, markerShowEntity, options );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 MarkerShowEntity 填充好的 MarkerView
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param markerShowEntity 要填充的数据
|
||||
* @return MarkerView
|
||||
*/
|
||||
public static IMarkerView getMarkerInfoWindowView( Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options ) {
|
||||
if ( markerShowEntity.isChecked() ) {
|
||||
return new MapMarkerInfoView( context, markerShowEntity, options );
|
||||
} else {
|
||||
return new MapMarkerView( context, markerShowEntity, options );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerShareMusic;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
@@ -71,7 +72,11 @@ public class MapMarkerInfoView extends MapMarkerBaseView {
|
||||
|
||||
Object bindObj = markerShowEntity.getBindObj();
|
||||
|
||||
ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow );
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow_vr );
|
||||
} else {
|
||||
ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow );
|
||||
}
|
||||
clMarkerContent.setBackgroundResource( R.drawable.bg_map_marker_yellow_info );
|
||||
ivReverseTriangle.setImageResource( R.drawable.bg_shape_reverse_yellow );
|
||||
switch ( markerShowEntity.getMarkerType() ) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.mogo.module.common.drawer.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.map.marker.IMogoInfoWindowAdapter;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/15
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class RoadConditionInfoWindow3DAdapter implements IMogoInfoWindowAdapter {
|
||||
|
||||
private MarkerShowEntity mEntity;
|
||||
private Context mContext;
|
||||
private MogoMarkerOptions mOptions;
|
||||
|
||||
public RoadConditionInfoWindow3DAdapter( MarkerShowEntity entity,
|
||||
Context context,
|
||||
MogoMarkerOptions options ) {
|
||||
this.mEntity = entity;
|
||||
this.mContext = context;
|
||||
this.mOptions = options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getInfoWindow( IMogoMarker marker ) {
|
||||
IMarkerView creator = MapMarkerAdapter.getMarkerInfoWindowView( mContext, mEntity, mOptions );
|
||||
return creator.getView();
|
||||
}
|
||||
}
|
||||
BIN
modules/mogo-module-common/src/main/res/raw/taxi.n3d
Normal file
BIN
modules/mogo-module-common/src/main/res/raw/taxi.n3d
Normal file
Binary file not shown.
@@ -432,17 +432,13 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
tvEnterVrMode = findViewById(R.id.module_ext_enter_vr_mode);
|
||||
tvEnterVrMode.setOnClickListener((v)->{
|
||||
// 进入vr模式
|
||||
enterVrMode();
|
||||
mApis.getStatusManagerApi().setVrMode(TAG, true);
|
||||
// mApis.getMapFrameControllerApi().changeToVRMode();
|
||||
mMApUIController.changeMapMode( EnumMapUI.Type_VR );
|
||||
});
|
||||
|
||||
tvExitVrMode = findViewById(R.id.module_ext_exit_vr_mode);
|
||||
tvExitVrMode.setOnClickListener((v)->{
|
||||
// 退出vr模式
|
||||
exitVrMode();
|
||||
mApis.getStatusManagerApi().setVrMode(TAG, false);
|
||||
// mApis.getMapFrameControllerApi().changeTo2dMode();
|
||||
mMApUIController.changeMapMode( EnumMapUI.CarUp_2D );
|
||||
});
|
||||
|
||||
dealWeatherContainer();
|
||||
@@ -497,8 +493,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
mCameraLiveNoticeHelper.enterVrMode();
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoLocationListener(TAG,this);
|
||||
|
||||
mMApUIController.changeMapMode( EnumMapUI.Type_VR );
|
||||
}
|
||||
|
||||
private void exitVrMode(){
|
||||
@@ -518,8 +512,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
mCameraLiveNoticeHelper.exitVrMode();
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
|
||||
|
||||
mMApUIController.changeMapMode( EnumMapUI.CarUp_2D );
|
||||
}
|
||||
|
||||
private void debugCrashWarn(){
|
||||
|
||||
@@ -89,7 +89,9 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
|
||||
mMogoMarker = ExtensionServiceManager.getMapService().getMarkerManager(mContext)
|
||||
.addMarker(PushDataType.TYPE_PUSH_CAMERA_DATA, options);
|
||||
|
||||
mMogoMarker.setOwner(PushDataType.TYPE_PUSH_CAMERA_DATA);
|
||||
if (mMogoMarker != null) {
|
||||
mMogoMarker.setOwner(PushDataType.TYPE_PUSH_CAMERA_DATA);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeCameraMarker() {
|
||||
@@ -117,13 +119,13 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
|
||||
*/
|
||||
@Override
|
||||
public void onMsgReceived(MogoSnapshotSetData obj) {
|
||||
// Logger.d(TAG, "onMsgReceived cameralive : " + obj);
|
||||
Logger.d(TAG, "onMsgReceived cameralive : " + obj);
|
||||
if (obj != null) { //如果多个点,如何处理,点击的时候
|
||||
mCloudRoadData = obj.getCamera();
|
||||
if (mCloudRoadData != null) {
|
||||
Log.d(TAG, "onMsgReceived getRtmpUrl = " + mCloudRoadData.getRtmpUrl());
|
||||
// Log.d(TAG, "mCurrentlat = " + mCurrentlat + "--mCurrentlon = " +mCurrentlon);
|
||||
// Log.d(TAG, "mCloudRoadData.getLat() = " + mCloudRoadData.getLat() + "--mCloudRoadData.getLon() = " + mCloudRoadData.getLon());
|
||||
Log.d(TAG, "mCurrentlat = " + mCurrentlat + "--mCurrentlon = " +mCurrentlon);
|
||||
Log.d(TAG, "mCloudRoadData.getLat() = " + mCloudRoadData.getLat() + "--mCloudRoadData.getLon() = " + mCloudRoadData.getLon());
|
||||
if (mCurrentlat == mCloudRoadData.getLat() && mCurrentlon == mCloudRoadData.getLon()) {
|
||||
//TODO
|
||||
} else {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 14 KiB |
@@ -33,6 +33,7 @@ import com.mogo.map.navi.MogoCongestionInfo;
|
||||
import com.mogo.map.navi.MogoTraffic;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
@@ -938,9 +939,13 @@ public class MogoServices implements IMogoMapListener,
|
||||
@Override
|
||||
public void onMapModeChanged( EnumMapUI ui ) {
|
||||
if ( ui == EnumMapUI.Type_VR ) {
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode( TAG, true );
|
||||
MapCenterPointStrategy.resetByChangeMode();
|
||||
MapMarkerManager.getInstance().redrawMarkerByStyleChanged();
|
||||
} else {
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().setVrMode( TAG, false );
|
||||
MapCenterPointStrategy.resetByChangeMode();
|
||||
MapMarkerManager.getInstance().redrawMarkerByStyleChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
MarkerShowEntity markerShowEntity = ( MarkerShowEntity ) object;
|
||||
markerShowEntity.setChecked( true );
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView( mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions() );
|
||||
markerView.setMarker(mogoMarker);
|
||||
markerView.setMarker( mogoMarker );
|
||||
if ( markerView instanceof OnlineCarMarkerView ) {
|
||||
try {
|
||||
mogoMarker.setIcon( markerView.getBitmap( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getCarInfo().getVehicleType() ) );
|
||||
@@ -270,7 +270,12 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
mogoMarker.setIcon( markerView.getBitmap( 0 ) );
|
||||
}
|
||||
} else {
|
||||
mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) );
|
||||
if ( MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode() ) {
|
||||
mogoMarker.hideInfoWindow();
|
||||
mogoMarker.showInfoWindow();
|
||||
} else {
|
||||
mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) );
|
||||
}
|
||||
}
|
||||
mogoMarker.setToTop();
|
||||
}
|
||||
@@ -309,7 +314,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
MarkerShowEntity markerShowEntity = ( MarkerShowEntity ) object;
|
||||
markerShowEntity.setChecked( false );
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView( mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions() );
|
||||
markerView.setMarker(mogoMarker);
|
||||
markerView.setMarker( mogoMarker );
|
||||
if ( markerView instanceof OnlineCarMarkerView ) {
|
||||
try {
|
||||
mogoMarker.setIcon( markerView.getBitmap( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getCarInfo().getVehicleType() ) );
|
||||
@@ -317,7 +322,12 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
mogoMarker.setIcon( markerView.getBitmap( 0 ) );
|
||||
}
|
||||
} else {
|
||||
mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) );
|
||||
if ( MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode() ) {
|
||||
mogoMarker.hideInfoWindow();
|
||||
mogoMarker.showInfoWindow();
|
||||
} else {
|
||||
mogoMarker.setIcon( ViewUtils.fromView( markerView.getView() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -693,19 +703,23 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
// if ( !AppUtils.isAppForeground( mContext ) ) {
|
||||
// return;
|
||||
// }
|
||||
if ( mLastDataResult != null ) {
|
||||
runOnTargetThread( () -> {
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION );
|
||||
drawMarkerByCurrentType( mLastDataResult );
|
||||
mLastCheckMarker = null;
|
||||
} );
|
||||
}
|
||||
redrawMarkerByStyleChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void onCloseCurrentSelectedMarker(){
|
||||
if ( mLastCheckMarker != null && !mLastCheckMarker.isDestroyed()) {
|
||||
public void redrawMarkerByStyleChanged() {
|
||||
if ( mLastDataResult != null ) {
|
||||
runOnTargetThread( () -> {
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_ROAD_CONDITION );
|
||||
drawMarkerByCurrentType( mLastDataResult );
|
||||
mLastCheckMarker = null;
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
public void onCloseCurrentSelectedMarker() {
|
||||
if ( mLastCheckMarker != null && !mLastCheckMarker.isDestroyed() ) {
|
||||
closeMarker( mLastCheckMarker );
|
||||
mLastCheckMarker = null;
|
||||
}
|
||||
|
||||
@@ -3,14 +3,13 @@ package com.mogo.module.small.map;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.common.view.RoundLayout;
|
||||
import com.mogo.module.small.map.animation.DirectionRotateAnimation;
|
||||
|
||||
/**
|
||||
* 小地图的方向View
|
||||
@@ -21,6 +20,8 @@ import com.mogo.module.common.view.RoundLayout;
|
||||
public class SmallMapDirectionView extends RoundLayout {
|
||||
|
||||
private ImageView mIvMapBorder;
|
||||
private DirectionRotateAnimation mRotateAnimation;
|
||||
private int lastAngle = 0;
|
||||
|
||||
public SmallMapDirectionView(Context context) {
|
||||
this(context, null);
|
||||
@@ -38,6 +39,7 @@ public class SmallMapDirectionView extends RoundLayout {
|
||||
private void initView(Context context) {
|
||||
LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
|
||||
mIvMapBorder = findViewById(R.id.ivMapBorder);
|
||||
mRotateAnimation = new DirectionRotateAnimation(context, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,18 +49,25 @@ public class SmallMapDirectionView extends RoundLayout {
|
||||
* @param angle 角度 0 - 359度旋转,相对于自身中心位置
|
||||
*/
|
||||
public void changeAngle(int angle) {
|
||||
Animation mRotateAnimation = new RotateAnimation(
|
||||
0, angle,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
int tempAngle = angle;
|
||||
if (angle <= 180) {
|
||||
tempAngle = angle;
|
||||
} else {
|
||||
tempAngle = -(360 - tempAngle);
|
||||
}
|
||||
|
||||
mRotateAnimation.setFromDegrees(lastAngle);
|
||||
mRotateAnimation.setToDegrees(tempAngle);
|
||||
|
||||
//设置线性插值,可以解决旋转一圈后卡顿问题
|
||||
mRotateAnimation.setInterpolator(new DecelerateInterpolator());
|
||||
mRotateAnimation.setInterpolator(new LinearInterpolator());
|
||||
//设置旋转一圈时间
|
||||
mRotateAnimation.setDuration(1000);
|
||||
mRotateAnimation.setDuration(300);
|
||||
//控件动画结束时是否保持动画最后的状态
|
||||
mRotateAnimation.setFillAfter(true);
|
||||
|
||||
mIvMapBorder.startAnimation(mRotateAnimation);
|
||||
// 刷新最后一次角度
|
||||
lastAngle = tempAngle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ import com.mogo.module.common.machinevision.IMachineVisionInterface;
|
||||
import com.mogo.module.common.wm.WindowManagerView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 12/10/20 1:35 PM
|
||||
@@ -90,7 +92,8 @@ public class SmallMapService extends Service {
|
||||
mSmallMapDirectionView.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mSmallMapDirectionView.changeAngle(-60);
|
||||
Random random = new Random();
|
||||
mSmallMapDirectionView.changeAngle(random.nextInt(360));
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.mogo.module.small.map.animation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
/**
|
||||
* 方向罗盘旋转动画
|
||||
* @author donghongyu
|
||||
* @date 12/14/20 7:46 PM
|
||||
*/
|
||||
public class DirectionRotateAnimation extends Animation {
|
||||
private float mFromDegrees;
|
||||
private float mToDegrees;
|
||||
|
||||
private int mPivotXType = Animation.RELATIVE_TO_SELF;
|
||||
private int mPivotYType = Animation.RELATIVE_TO_SELF;
|
||||
private float mPivotXValue = 0.5f;
|
||||
private float mPivotYValue = 0.5f;
|
||||
|
||||
private float mPivotX;
|
||||
private float mPivotY;
|
||||
|
||||
|
||||
public DirectionRotateAnimation(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initializePivotPoint();
|
||||
}
|
||||
|
||||
public void setFromDegrees(float fromDegrees) {
|
||||
mFromDegrees = fromDegrees;
|
||||
}
|
||||
|
||||
public void setToDegrees(float toDegrees) {
|
||||
mToDegrees = toDegrees;
|
||||
}
|
||||
|
||||
private void initializePivotPoint() {
|
||||
if (mPivotXType == ABSOLUTE) {
|
||||
mPivotX = mPivotXValue;
|
||||
}
|
||||
if (mPivotYType == ABSOLUTE) {
|
||||
mPivotY = mPivotYValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
float degrees = mFromDegrees + ((mToDegrees - mFromDegrees) * interpolatedTime);
|
||||
float scale = getScaleFactor();
|
||||
|
||||
if (mPivotX == 0.0f && mPivotY == 0.0f) {
|
||||
t.getMatrix().setRotate(degrees);
|
||||
} else {
|
||||
t.getMatrix().setRotate(degrees, mPivotX * scale, mPivotY * scale);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(int width, int height, int parentWidth, int parentHeight) {
|
||||
super.initialize(width, height, parentWidth, parentHeight);
|
||||
mPivotX = resolveSize(mPivotXType, mPivotXValue, width, parentWidth);
|
||||
mPivotY = resolveSize(mPivotYType, mPivotYValue, height, parentHeight);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user