Merge branch 'feature/v1.0.4-opt-moving-marker' into feature/v1.0.5
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.mogo.module.service.marker;
|
package com.mogo.module.service.marker;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.mogo.map.marker.IMogoMarker;
|
import com.mogo.map.marker.IMogoMarker;
|
||||||
@@ -14,5 +15,9 @@ public interface IMarkerView {
|
|||||||
|
|
||||||
View getView();
|
View getView();
|
||||||
|
|
||||||
|
default Bitmap getBitmap(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
void setMarker( IMogoMarker marker );
|
void setMarker( IMogoMarker marker );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
package com.mogo.module.service.marker;
|
package com.mogo.module.service.marker;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.mogo.commons.AbsMogoApplication;
|
||||||
|
import com.mogo.map.marker.IMogoMarker;
|
||||||
import com.mogo.map.marker.MogoMarkerOptions;
|
import com.mogo.map.marker.MogoMarkerOptions;
|
||||||
|
import com.mogo.module.common.ModuleNames;
|
||||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||||
|
import com.mogo.module.service.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* author : donghongyu
|
* author : donghongyu
|
||||||
@@ -23,10 +30,16 @@ public class MapMarkerAdapter {
|
|||||||
* @return MarkerView
|
* @return MarkerView
|
||||||
*/
|
*/
|
||||||
public static IMarkerView getMarkerView(Context context, MarkerShowEntity markerShowEntity, MogoMarkerOptions options) {
|
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 {
|
} else {
|
||||||
return new MapMarkerView(context, markerShowEntity, options);
|
if (markerShowEntity.isChecked()) {
|
||||||
|
return new MapMarkerInfoView(context, markerShowEntity, options);
|
||||||
|
} else {
|
||||||
|
return new MapMarkerView(context, markerShowEntity, options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -773,14 +773,15 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
|||||||
if (markerShowEntity == null || markerShowEntity.getMarkerLocation() == null) {
|
if (markerShowEntity == null || markerShowEntity.getMarkerLocation() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
MogoMarkerOptions options =
|
MogoMarkerOptions options = new MogoMarkerOptions().owner(markerShowEntity.getMarkerType()).object(markerShowEntity).latitude(markerShowEntity.getMarkerLocation().getLat()).longitude(markerShowEntity.getMarkerLocation().getLon());
|
||||||
new MogoMarkerOptions().owner(markerShowEntity.getMarkerType()).object(markerShowEntity).latitude(markerShowEntity.getMarkerLocation().getLat()).longitude(markerShowEntity.getMarkerLocation().getLon());
|
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
|
||||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity,
|
if ( markerView.getView() == null ) {
|
||||||
options);
|
options.icon(markerView.getBitmap());
|
||||||
options.icon(markerView.getView());
|
} else {
|
||||||
|
options.icon(markerView.getView());
|
||||||
|
}
|
||||||
|
|
||||||
IMogoMarker marker =
|
IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
|
||||||
MarkerServiceHandler.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
|
|
||||||
marker.setOwner(markerShowEntity.getMarkerType());
|
marker.setOwner(markerShowEntity.getMarkerType());
|
||||||
markerView.setMarker(marker);
|
markerView.setMarker(marker);
|
||||||
marker.setOnMarkerClickListener(this);
|
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