bugfix: UI-727, UI-726
This commit is contained in:
@@ -85,7 +85,9 @@ public class AMapWrapper implements IMogoMap {
|
||||
return null;
|
||||
}
|
||||
final IMogoMarker mogoMarker = new AMapMarkerWrapper( mAMap.addMarker( markerOptions ), options );
|
||||
MogoMarkersHandler.getInstance().add( tag, mogoMarker );
|
||||
if ( options.isAutoManager() ) {
|
||||
MogoMarkersHandler.getInstance().add( tag, mogoMarker );
|
||||
}
|
||||
return mogoMarker;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,11 @@ public class MogoMarkerOptions extends Observable {
|
||||
|
||||
private Object mObject;
|
||||
|
||||
/**
|
||||
* 是否加入marker管理
|
||||
*/
|
||||
private boolean mAutoManager = true;
|
||||
|
||||
public MogoMarkerOptions position( MogoLatLng latLng ){
|
||||
if ( latLng != null ) {
|
||||
latitude( latLng.lat );
|
||||
@@ -294,4 +299,13 @@ public class MogoMarkerOptions extends Observable {
|
||||
public Object getObject() {
|
||||
return mObject;
|
||||
}
|
||||
|
||||
public boolean isAutoManager() {
|
||||
return mAutoManager;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions autoManager( boolean autoManager ) {
|
||||
this.mAutoManager = autoManager;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,6 +326,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
mCardManager = MarkerServiceHandler.getMogoCardManager();
|
||||
|
||||
mFragmentManager.addMainFragmentStackTransactionListener( this );
|
||||
|
||||
CarIconDisplayStrategy.getInstance().changeCarIconStatus( mStatusManager.isSeekHelping() );
|
||||
}
|
||||
|
||||
private void initWorkThread() {
|
||||
@@ -696,7 +698,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
break;
|
||||
case SEEK_HELPING:
|
||||
CarIconDisplayStrategy.getInstance().changeCarIconStatus( mUiController, isTrue );
|
||||
CarIconDisplayStrategy.getInstance().changeCarIconStatus( isTrue );
|
||||
notifySeekHelpingStatusChanged( isTrue );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public interface IMarkerView {
|
||||
|
||||
View getView();
|
||||
|
||||
default Bitmap getBitmap(){
|
||||
default Bitmap getBitmap(int type){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,23 +21,23 @@ import java.util.Map;
|
||||
*/
|
||||
public class OnlineCarMarkerView implements IMarkerView {
|
||||
|
||||
private static Map< String, SoftReference< Bitmap > > sRef = new HashMap<>();
|
||||
private static Map< Integer, SoftReference< Bitmap > > sRef = new HashMap<>();
|
||||
|
||||
private OnlineCarMarkerView(){
|
||||
private OnlineCarMarkerView() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder{
|
||||
private static final OnlineCarMarkerView INSTANCE = new OnlineCarMarkerView();
|
||||
private static final class InstanceHolder {
|
||||
private static final OnlineCarMarkerView INSTANCE = new OnlineCarMarkerView();
|
||||
}
|
||||
|
||||
public static OnlineCarMarkerView getInstance(){
|
||||
return InstanceHolder.INSTANCE;
|
||||
public static OnlineCarMarkerView getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Object readResolve(){
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,12 +46,18 @@ public class OnlineCarMarkerView implements IMarkerView {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap getBitmap() {
|
||||
if ( sRef.get( ModuleNames.CARD_TYPE_USER_DATA ) == null || sRef.get( ModuleNames.CARD_TYPE_USER_DATA ).get() == null
|
||||
|| sRef.get( ModuleNames.CARD_TYPE_USER_DATA ).get().isRecycled() ) {
|
||||
sRef.put( ModuleNames.CARD_TYPE_USER_DATA, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_gray ) ) );
|
||||
public Bitmap getBitmap( int vehicleType ) {
|
||||
if ( sRef.get( vehicleType ) == null || sRef.get( vehicleType ).get() == null
|
||||
|| sRef.get( vehicleType ).get().isRecycled() ) {
|
||||
switch ( vehicleType ) {
|
||||
case 2:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_type2 ) ) );
|
||||
break;
|
||||
default:
|
||||
sRef.put( vehicleType, new SoftReference<>( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_gray ) ) );
|
||||
}
|
||||
}
|
||||
return sRef.get( ModuleNames.CARD_TYPE_USER_DATA ).get();
|
||||
return sRef.get( vehicleType ).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
package com.mogo.module.service.strategy;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.uicontroller.CarCursorOption;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -18,7 +26,10 @@ import com.mogo.utils.WorkThreadHandler;
|
||||
*/
|
||||
public class CarIconDisplayStrategy {
|
||||
|
||||
private static final String TAG = "CarIconDisplayStrategy";
|
||||
|
||||
public static final int MSG_SEEK_HELPING_ANIM = 2000;
|
||||
public static final int MSG_STOP_SEEK_HELPING_ANIM = 2001;
|
||||
|
||||
// F 系列才有这个帧动画
|
||||
public static final int[] sFrame = {
|
||||
@@ -90,7 +101,9 @@ public class CarIconDisplayStrategy {
|
||||
};
|
||||
|
||||
private static volatile CarIconDisplayStrategy sInstance;
|
||||
private IMogoMapUIController mController;
|
||||
|
||||
private IMogoMarker mSeekHelpingMarker;
|
||||
private ArrayList< Bitmap > mBitmapFrames = new ArrayList<>();
|
||||
|
||||
private CarIconDisplayStrategy() {
|
||||
mOption = new CarCursorOption.Builder().carCursorRes( R.drawable.module_service_ic_seek_helping ).build();
|
||||
@@ -112,12 +125,9 @@ public class CarIconDisplayStrategy {
|
||||
}
|
||||
|
||||
private Handler mSeekHelpingHandler;
|
||||
private int mCounter = 0;
|
||||
private boolean mStopStatus = true;
|
||||
private CarCursorOption mOption;
|
||||
|
||||
public void changeCarIconStatus( IMogoMapUIController controller, boolean seekHelpingStatus ) {
|
||||
mController = controller;
|
||||
public void changeCarIconStatus( boolean seekHelpingStatus ) {
|
||||
if ( CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X ) {
|
||||
if ( seekHelpingStatus ) {
|
||||
playSeekHelpingAnim();
|
||||
@@ -126,20 +136,18 @@ public class CarIconDisplayStrategy {
|
||||
}
|
||||
} else {
|
||||
if ( seekHelpingStatus ) {
|
||||
controller.setCarCursorOption( mOption );
|
||||
MarkerServiceHandler.getMapUIController().setCarCursorOption( mOption );
|
||||
} else {
|
||||
controller.setCarCursorOption( null );
|
||||
MarkerServiceHandler.getMapUIController().setCarCursorOption( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void playSeekHelpingAnim() {
|
||||
initHandler();
|
||||
mStopStatus = false;
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_SEEK_HELPING_ANIM;
|
||||
msg.arg1 = mCounter++;
|
||||
mSeekHelpingHandler.sendMessageDelayed( msg, 100 );
|
||||
mSeekHelpingHandler.sendMessageDelayed( msg, 0 );
|
||||
}
|
||||
|
||||
private void initHandler() {
|
||||
@@ -150,17 +158,20 @@ public class CarIconDisplayStrategy {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( mStopStatus ) {
|
||||
mSeekHelpingHandler.removeMessages( MSG_SEEK_HELPING_ANIM );
|
||||
mCounter = 0;
|
||||
mController.setCarCursorOption( null );
|
||||
return;
|
||||
}
|
||||
switch ( msg.what ) {
|
||||
case MSG_SEEK_HELPING_ANIM:
|
||||
mOption.setCarCursorRes( sFrame[msg.arg1 % sFrame.length] );
|
||||
mController.setCarCursorOption( mOption );
|
||||
playSeekHelpingAnim();
|
||||
try {
|
||||
playAnim();
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case MSG_STOP_SEEK_HELPING_ANIM:
|
||||
try {
|
||||
stopAnim();
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -168,12 +179,39 @@ public class CarIconDisplayStrategy {
|
||||
}
|
||||
|
||||
private void stopSeekHelpingAnim() {
|
||||
mStopStatus = true;
|
||||
if ( mSeekHelpingHandler == null ) {
|
||||
return;
|
||||
initHandler();
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_STOP_SEEK_HELPING_ANIM;
|
||||
mSeekHelpingHandler.sendMessageDelayed( msg, 0 );
|
||||
}
|
||||
|
||||
private void playAnim() {
|
||||
for ( int i : sFrame ) {
|
||||
mBitmapFrames.add( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), i ) );
|
||||
}
|
||||
mCounter = 0;
|
||||
mSeekHelpingHandler.removeMessages( MSG_SEEK_HELPING_ANIM );
|
||||
mController.setCarCursorOption( null );
|
||||
mSeekHelpingMarker = MarkerServiceHandler.getMarkerManager().addMarker( TAG, new MogoMarkerOptions()
|
||||
.icons( mBitmapFrames )
|
||||
.period( 1 )
|
||||
.zIndex( 1000 )
|
||||
.autoManager( false )
|
||||
.anchor( 0.5f, 0.5f )
|
||||
.position( MarkerServiceHandler.getMapService().getNavi( AbsMogoApplication.getApp() ).getCarLocation2() ) );
|
||||
MarkerServiceHandler.getMapUIController().showMyLocation( false );
|
||||
}
|
||||
|
||||
private void stopAnim() {
|
||||
if ( mSeekHelpingMarker != null ) {
|
||||
mSeekHelpingMarker.destroy();
|
||||
mSeekHelpingMarker = null;
|
||||
}
|
||||
if ( !mBitmapFrames.isEmpty() ) {
|
||||
for ( Bitmap bitmapFrame : mBitmapFrames ) {
|
||||
if ( bitmapFrame != null && !bitmapFrame.isRecycled() ) {
|
||||
bitmapFrame.recycle();
|
||||
}
|
||||
}
|
||||
mBitmapFrames.clear();
|
||||
}
|
||||
MarkerServiceHandler.getMapUIController().showMyLocation( true );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user