opt online car marker icon
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
@@ -14,5 +15,9 @@ public interface IMarkerView {
|
||||
|
||||
View getView();
|
||||
|
||||
default Bitmap getBitmap(){
|
||||
return null;
|
||||
}
|
||||
|
||||
void setMarker( IMogoMarker marker );
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.service.R;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
@@ -23,10 +30,16 @@ public class MapMarkerAdapter {
|
||||
* @return MarkerView
|
||||
*/
|
||||
public static IMarkerView getMarkerView(Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options) {
|
||||
if (markerShowEntity.isChecked()) {
|
||||
return new MapMarkerInfoView(context, markerShowEntity, options);
|
||||
|
||||
if ( TextUtils.equals( markerShowEntity.getMarkerType(), ModuleNames.CARD_TYPE_USER_DATA ) ) {
|
||||
return OnlineCarMarkerView.getInstance();
|
||||
} else {
|
||||
return new MapMarkerView(context, markerShowEntity, options);
|
||||
if (markerShowEntity.isChecked()) {
|
||||
return new MapMarkerInfoView(context, markerShowEntity, options);
|
||||
} else {
|
||||
return new MapMarkerView(context, markerShowEntity, options);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -776,14 +776,15 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
if (markerShowEntity == null || markerShowEntity.getMarkerLocation() == null) {
|
||||
return null;
|
||||
}
|
||||
MogoMarkerOptions options =
|
||||
new MogoMarkerOptions().owner(markerShowEntity.getMarkerType()).object(markerShowEntity).latitude(markerShowEntity.getMarkerLocation().getLat()).longitude(markerShowEntity.getMarkerLocation().getLon());
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity,
|
||||
options);
|
||||
options.icon(markerView.getView());
|
||||
MogoMarkerOptions options = new MogoMarkerOptions().owner(markerShowEntity.getMarkerType()).object(markerShowEntity).latitude(markerShowEntity.getMarkerLocation().getLat()).longitude(markerShowEntity.getMarkerLocation().getLon());
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
|
||||
if ( markerView.getView() == null ) {
|
||||
options.icon(markerView.getBitmap());
|
||||
} else {
|
||||
options.icon(markerView.getView());
|
||||
}
|
||||
|
||||
IMogoMarker marker =
|
||||
MarkerServiceHandler.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
|
||||
IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
|
||||
marker.setOwner(markerShowEntity.getMarkerType());
|
||||
markerView.setMarker(marker);
|
||||
marker.setOnMarkerClickListener(this);
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.service.R;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class OnlineCarMarkerView implements IMarkerView {
|
||||
|
||||
private static Map< String, SoftReference< Bitmap > > sRef = new HashMap<>();
|
||||
|
||||
private OnlineCarMarkerView(){
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder{
|
||||
private static final OnlineCarMarkerView INSTANCE = new OnlineCarMarkerView();
|
||||
}
|
||||
|
||||
public static OnlineCarMarkerView getInstance(){
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Object readResolve(){
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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 ) ) );
|
||||
}
|
||||
return sRef.get( ModuleNames.CARD_TYPE_USER_DATA ).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarker( IMogoMarker marker ) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user