准备进行marker的样式替换抽离操作
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package com.mogo.module.common.entity;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-1015:47
|
||||
* desc : 用来跟Marker View 绑定使用,内容、状态等设置
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MarkerShowEntity {
|
||||
|
||||
// false - 没选中,true - 选中
|
||||
private boolean isChecked;
|
||||
// icon 地址,例如:头像,唱片图片,探路缩略
|
||||
private String iconUrl;
|
||||
// 要展示的文本
|
||||
private String textContent;
|
||||
// Marker 类型
|
||||
private String markerType;
|
||||
|
||||
// 绑定 MarkerView 的数据
|
||||
private Object bindObj;
|
||||
|
||||
public boolean isChecked() {
|
||||
return isChecked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
isChecked = checked;
|
||||
}
|
||||
|
||||
public String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
|
||||
public void setIconUrl(String iconUrl) {
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
public String getTextContent() {
|
||||
return textContent;
|
||||
}
|
||||
|
||||
public void setTextContent(String textContent) {
|
||||
this.textContent = textContent;
|
||||
}
|
||||
|
||||
public String getMarkerType() {
|
||||
return markerType;
|
||||
}
|
||||
|
||||
public void setMarkerType(String markerType) {
|
||||
this.markerType = markerType;
|
||||
}
|
||||
|
||||
|
||||
public Object getBindObj() {
|
||||
return bindObj;
|
||||
}
|
||||
|
||||
public void setBindObj(Object bindObj) {
|
||||
this.bindObj = bindObj;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<resources>
|
||||
<dimen name="card_common_margin_left">@dimen/dp_15</dimen>
|
||||
<dimen name="dp_m_60">-30.0000px</dimen>
|
||||
<dimen name="dp_m_30">-15.0000px</dimen>
|
||||
<dimen name="dp_m_20">-10.0000px</dimen>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- Your custom size defind by references, can be writted in anywhere, any module, any values/*.xml, for example: -->
|
||||
<dimen name="card_common_margin_left">@dimen/dp_15</dimen>
|
||||
|
||||
<!-- dp and sp values, must be defind in this file! -->
|
||||
<!-- view size,you can add if there is no one -->
|
||||
<dimen name="dp_m_60">-60px</dimen>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- Your custom size defind by references, can be writted in anywhere, any module, any values/*.xml, for example: -->
|
||||
<dimen name="card_common_margin_left">@dimen/dp_15</dimen>
|
||||
|
||||
<!-- dp and sp values, must be defind in this file! -->
|
||||
<!-- view size,you can add if there is no one -->
|
||||
<dimen name="dp_m_60">-60px</dimen>
|
||||
|
||||
@@ -18,13 +18,12 @@ import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.common.entity.MarkerShareMusic;
|
||||
import com.mogo.module.service.marker.MapMarkerInfoView;
|
||||
import com.mogo.module.service.marker.MapMarkerView;
|
||||
import com.mogo.module.service.marker.MarkerInfoWindowAdapter;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.imageloader.IMogoImageloader;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.List;
|
||||
@@ -47,10 +46,9 @@ public class MarkerServiceHandler {
|
||||
private static IMogoNavi mNavi;
|
||||
private static IMogoMapUIController mMapUIController;
|
||||
|
||||
private static IMogoRegisterCenter mMogoRegisterCenter;
|
||||
private static IMogoStatusManager mMogoStatusManager;
|
||||
private static IMogoImageloader mImageloader;
|
||||
private static IMogoSocketManager mMogoSocketManager;
|
||||
private static MarkerInfoWindowAdapter markerInfoWindowAdapter;
|
||||
|
||||
private static Context mContext;
|
||||
|
||||
@@ -58,10 +56,9 @@ public class MarkerServiceHandler {
|
||||
mContext = context;
|
||||
mMapService = (IMogoMapService) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_MAP).navigation(context);
|
||||
mImageloader = (IMogoImageloader) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_IMAGE_LOADER).navigation(context);
|
||||
mMogoRegisterCenter = (IMogoRegisterCenter) ARouter.getInstance().build(MogoServicePaths.PATH_REGISTER_CENTER).navigation(context);
|
||||
mMogoStatusManager = (IMogoStatusManager) ARouter.getInstance().build(MogoServicePaths.PATH_STATUS_MANAGER).navigation(context);
|
||||
mMarkerManager = mMapService.getMarkerManager(context);
|
||||
mNavi = mMapService.getNavi(context);
|
||||
markerInfoWindowAdapter = new MarkerInfoWindowAdapter(context, getNavi(), getImageloader());
|
||||
mMapUIController = mMapService.getMapUIController();
|
||||
|
||||
mogoMarkerClickListener = new MoGoMarkerClickListener();
|
||||
@@ -78,7 +75,9 @@ public class MarkerServiceHandler {
|
||||
@Override
|
||||
public void onMsgReceived(MarkerResponse response) {
|
||||
Logger.e(TAG, "===" + response);
|
||||
drawMapMarker(response);
|
||||
if (!getMogoStatusManager().isSearchUIShow()) {
|
||||
drawMapMarker(response);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -107,6 +106,10 @@ public class MarkerServiceHandler {
|
||||
return mMogoSocketManager;
|
||||
}
|
||||
|
||||
public static IMogoStatusManager getMogoStatusManager() {
|
||||
return mMogoStatusManager;
|
||||
}
|
||||
|
||||
|
||||
private static IMogoMarker lastMarker;
|
||||
|
||||
@@ -119,6 +122,7 @@ public class MarkerServiceHandler {
|
||||
public boolean onMarkerClicked(IMogoMarker marker) {
|
||||
Logger.e(TAG, "点击了大而全中的Marker");
|
||||
if (lastMarker != null) {
|
||||
// 重置为默认状态
|
||||
MapMarkerView mapMarkerView = new MapMarkerView(mContext);
|
||||
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
@@ -128,7 +132,6 @@ public class MarkerServiceHandler {
|
||||
.longitude(lastMarker.getPosition().getLng());
|
||||
|
||||
IMogoMarker newMarker = getMarkerManager().addMarker(lastMarker.getOwner(), options);
|
||||
newMarker.setInfoWindowAdapter(markerInfoWindowAdapter);
|
||||
newMarker.setOnMarkerClickListener(mogoMarkerClickListener);
|
||||
newMarker.setObject(lastMarker.getObject());
|
||||
|
||||
@@ -136,7 +139,7 @@ public class MarkerServiceHandler {
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 绘制选中的状态
|
||||
MapMarkerInfoView mapMarkerInfoView = new MapMarkerInfoView(mContext);
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.icon(mapMarkerInfoView)
|
||||
@@ -145,7 +148,6 @@ public class MarkerServiceHandler {
|
||||
.longitude(marker.getPosition().getLng());
|
||||
|
||||
IMogoMarker newMarker = getMarkerManager().addMarker(marker.getOwner(), options);
|
||||
newMarker.setInfoWindowAdapter(markerInfoWindowAdapter);
|
||||
newMarker.setOnMarkerClickListener(mogoMarkerClickListener);
|
||||
newMarker.setObject(marker.getObject());
|
||||
|
||||
@@ -236,7 +238,6 @@ public class MarkerServiceHandler {
|
||||
options.icon(mapMarkerView);
|
||||
|
||||
IMogoMarker marker = getMarkerManager().addMarker(markerTag, options);
|
||||
marker.setInfoWindowAdapter(markerInfoWindowAdapter);
|
||||
marker.setOnMarkerClickListener(mogoMarkerClickListener);
|
||||
marker.setObject(bindObject);
|
||||
}
|
||||
@@ -254,7 +255,6 @@ public class MarkerServiceHandler {
|
||||
.latitude(39.574525d + new Random().nextDouble())
|
||||
.longitude(116.21733d + new Random().nextDouble());
|
||||
IMogoMarker marker = getMarkerManager().addMarker("CARD_TYPE_USER_DATA", options);
|
||||
marker.setInfoWindowAdapter(markerInfoWindowAdapter);
|
||||
marker.setOnMarkerClickListener(mogoMarkerClickListener);
|
||||
marker.setObject("我是Marker上面绑定的数据");
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-1015:55
|
||||
* desc : 地图Marker的适配器
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MapMarkerAdapter {
|
||||
|
||||
/**
|
||||
* 获取 MarkerShowEntity 填充好的 MarkerView
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param markerShowEntity 要填充的数据
|
||||
* @return MarkerView
|
||||
*/
|
||||
public static View getMarkerView(Context context, MarkerShowEntity markerShowEntity) {
|
||||
|
||||
if (markerShowEntity.isChecked()) {
|
||||
return new MapMarkerView(context);
|
||||
} else {
|
||||
return new MapMarkerInfoView(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.mogo.module.service.marker;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
@@ -18,6 +17,8 @@ import com.mogo.module.service.R;
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MapMarkerInfoView extends ConstraintLayout {
|
||||
private Context mContext;
|
||||
|
||||
public MapMarkerInfoView(Context context) {
|
||||
super(context);
|
||||
initView(context);
|
||||
@@ -35,9 +36,8 @@ public class MapMarkerInfoView extends ConstraintLayout {
|
||||
|
||||
|
||||
private void initView(Context context) {
|
||||
|
||||
mContext = context;
|
||||
LayoutInflater.from(context).inflate(R.layout.view_map_marker_info, this);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import com.mogo.module.service.R;
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MapMarkerView extends ConstraintLayout {
|
||||
private Context mContext;
|
||||
|
||||
public MapMarkerView(Context context) {
|
||||
super(context);
|
||||
initView(context);
|
||||
@@ -34,9 +36,8 @@ public class MapMarkerView extends ConstraintLayout {
|
||||
|
||||
|
||||
private void initView(Context context) {
|
||||
|
||||
mContext = context;
|
||||
LayoutInflater.from(context).inflate(R.layout.view_map_marker, this);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.mogo.module.service.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.navi.IMogoNavi;
|
||||
import com.mogo.service.imageloader.IMogoImageloader;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-0818:11
|
||||
* desc :
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MarkerInfoWindowAdapter implements IMogoInfoWindowAdapter {
|
||||
|
||||
private static final String TAG = "MarkerInfoWindowAdapter";
|
||||
|
||||
private Context mContext;
|
||||
private IMogoNavi mNavi;
|
||||
private IMogoImageloader mImageloader;
|
||||
|
||||
public MarkerInfoWindowAdapter(Context mContext, IMogoNavi mNavi, IMogoImageloader iMogoImageloader) {
|
||||
this.mContext = mContext;
|
||||
this.mNavi = mNavi;
|
||||
this.mImageloader = iMogoImageloader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getInfoWindow(IMogoMarker marker) {
|
||||
Logger.e(TAG,"getInfoWindow====");
|
||||
MapMarkerInfoView mapMarkerInfoView = new MapMarkerInfoView(mContext);
|
||||
return mapMarkerInfoView;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user