This commit is contained in:
wangcongtao
2020-01-09 19:28:20 +08:00
6 changed files with 120 additions and 67 deletions

View File

@@ -28,7 +28,7 @@ public class MogoApplication extends AbsMogoApplication {
DebugConfig.setNetMode( DebugConfig.NET_MODE_QA );
MogoModulePaths.addModule(new MogoModule(OnLineCarConstants.TAG, "CARD_TYPE_ROAD_ONLINECAR"));
MogoModulePaths.addModule( new MogoModule( TanluConstants.TAG, "CARD_TYPE_ROAD_CODITION" ) );
MogoModulePaths.addModule(new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME));
// MogoModulePaths.addModule(new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME));
}
@Override

View File

@@ -199,7 +199,9 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
@Override
public boolean onMarkerClicked( IMogoMarker marker ) {
switch2( marker.getOwner() );
mMogoModuleHandler.onMarkerReceive(marker.getOwner(),marker);
if (mMogoModuleHandler != null) {
mMogoModuleHandler.onMarkerReceive(marker);
}
return false;
}

View File

@@ -77,8 +77,7 @@ public interface MogoModulesHandler extends IMogoMapListener,
/**
* 卡片接收到Marker传入数据
* @param cardType
* @param marker
* @param marker marker
*/
void onMarkerReceive(String cardType, IMogoMarker marker);
void onMarkerReceive(IMogoMarker marker);
}

View File

@@ -349,8 +349,8 @@ public class MogoModulesManager implements MogoModulesHandler,
}
@Override
public void onMarkerReceive( String cardType, IMogoMarker marker ) {
IMogoMarkerClickListener listener = MogoRegisterCenterHandler.getInstance().getMarkerListener( cardType );
public void onMarkerReceive( IMogoMarker marker ) {
IMogoMarkerClickListener listener = MogoRegisterCenterHandler.getInstance().getMarkerListener( marker.getOwner() );
if ( listener != null ) {
listener.onMarkerClicked( marker );
}

View File

@@ -16,6 +16,7 @@ import com.mogo.module.service.entity.MarkerLocation;
import com.mogo.module.service.entity.MarkerOnlineCar;
import com.mogo.module.service.entity.MarkerResponse;
import com.mogo.module.service.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;
@@ -26,7 +27,6 @@ import com.mogo.service.map.IMogoMapService;
import com.mogo.utils.TipToast;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -76,55 +76,7 @@ public class MarkerServiceHandler {
@Override
public void onMsgReceived(MarkerResponse response) {
Logger.e(TAG, "===" + response);
getMarkerManager().removeMarkers();
// 解析不同的Marker类型然后对应的进行绘制
if (response != null && response.getResult() != null) {
MarkerCardResult markerCardResult = response.getResult();
List<MarkerCarChat> carChat = markerCardResult.getCarChat();
List<MarkerOnlineCar> onlineCar = markerCardResult.getOnlineCar();
List<MarkerExploreWay> exploreWay = markerCardResult.getExploreWay();
List<MarkerShareMusic> shareMusic = markerCardResult.getShareMusic();
ArrayList<MogoMarkerOptions> optionsList = new ArrayList<>();
if (carChat != null) {
for (MarkerCarChat markerCarChat : carChat) {
MarkerLocation markerLocation = markerCarChat.getLocation();
drawMapMarker(markerCarChat.getType(), markerLocation, optionsList);
}
}
if (onlineCar != null) {
for (MarkerOnlineCar markerOnlineCar : onlineCar) {
MarkerLocation markerLocation = markerOnlineCar.getLocation();
drawMapMarker(markerOnlineCar.getType(), markerLocation, optionsList);
}
}
if (exploreWay != null) {
for (MarkerExploreWay markerExploreWay : exploreWay) {
MarkerLocation markerLocation = markerExploreWay.getLocation();
drawMapMarker(markerExploreWay.getType(), markerLocation, optionsList);
}
}
if (shareMusic != null) {
for (MarkerShareMusic markerShareMusic : shareMusic) {
MarkerLocation markerLocation = markerShareMusic.getLocation();
drawMapMarker(markerShareMusic.getType(), markerLocation, optionsList);
}
}
List<IMogoMarker> iMogoMarkers = getMarkerManager().addMarkers(TAG, optionsList, true);
for (IMogoMarker iMogoMarker : iMogoMarkers) {
iMogoMarker.setInfoWindowAdapter(markerInfoWindowAdapter);
iMogoMarker.setOnMarkerClickListener(mogoMarkerClickListener);
}
}
drawMapMarker(response);
}
});
}
@@ -168,27 +120,107 @@ public class MarkerServiceHandler {
}
/**
* 绘制Marker
*/
public static void drawMapMarker(MarkerResponse response) {
getMarkerManager().removeMarkers();
// 解析不同的Marker类型然后对应的进行绘制
if (response != null && response.getResult() != null) {
MarkerCardResult markerCardResult = response.getResult();
List<MarkerCarChat> carChat = markerCardResult.getCarChat();
List<MarkerOnlineCar> onlineCar = markerCardResult.getOnlineCar();
List<MarkerExploreWay> exploreWay = markerCardResult.getExploreWay();
List<MarkerShareMusic> shareMusic = markerCardResult.getShareMusic();
if (carChat != null) {
for (MarkerCarChat markerCarChat : carChat) {
MarkerLocation markerLocation = markerCarChat.getLocation();
drawMapMarker(
markerCarChat.getType(),
markerCarChat,
markerLocation);
}
}
if (onlineCar != null) {
for (MarkerOnlineCar markerOnlineCar : onlineCar) {
MarkerLocation markerLocation = markerOnlineCar.getLocation();
drawMapMarker(
markerOnlineCar.getType(),
markerOnlineCar,
markerLocation);
}
}
if (exploreWay != null) {
for (MarkerExploreWay markerExploreWay : exploreWay) {
MarkerLocation markerLocation = markerExploreWay.getLocation();
drawMapMarker(
markerExploreWay.getType(),
markerExploreWay,
markerLocation);
}
}
if (shareMusic != null) {
for (MarkerShareMusic markerShareMusic : shareMusic) {
MarkerLocation markerLocation = markerShareMusic.getLocation();
drawMapMarker(
markerShareMusic.getType(),
markerShareMusic,
markerLocation);
}
}
}
getMapUIController().changeZoom(10);
}
/**
* 绘制Marker
*
* @param markerTag Marker类型
* http://gitlab.zhidaoauto.com/ecos/yycp-service/CarLauncher-Docs/blob/master/%E5%8D%A1%E7%89%87%E7%B1%BB%E5%9E%8B%E5%AE%9A%E4%B9%89.md
* @param markerLocation 要绘制Marker的位置信息
* @param optionsList 要加入的Marker集合
*/
public static void drawMapMarker(String markerTag, MarkerLocation markerLocation,
ArrayList<MogoMarkerOptions> optionsList) {
Logger.e(markerTag, "绘制Marker====markerTag" + markerTag);
public static void drawMapMarker(String markerTag,
Object bindObject,
MarkerLocation markerLocation) {
Logger.e(TAG, "绘制Marker====markerTag" + markerTag);
MapMarkerView mapMarkerView = new MapMarkerView(mContext);
MapMarkerInfoView mapMarkerInfoView = new MapMarkerInfoView(mContext);
MogoMarkerOptions options = new MogoMarkerOptions()
.icon(mapMarkerView)
.owner(markerTag)
.latitude(markerLocation.getLat())
.longitude(markerLocation.getLon());
optionsList.add(options);
switch (markerTag) {
case ServiceConst.CARD_TYPE_CARS_CHATTING:
options.icon(mapMarkerView);
break;
case ServiceConst.CARD_TYPE_ROAD_CODITION:
options.icon(mapMarkerView);
break;
case ServiceConst.CARD_TYPE_SHARE_MUSIC:
options.icon(mapMarkerView);
break;
case ServiceConst.CARD_TYPE_USER_DATA:
options.icon(mapMarkerInfoView);
break;
default:
options.icon(mapMarkerView);
break;
}
IMogoMarker marker = getMarkerManager().addMarker(markerTag, options);
marker.setInfoWindowAdapter(markerInfoWindowAdapter);
marker.setOnMarkerClickListener(mogoMarkerClickListener);
marker.setObject(bindObject);
}
@@ -203,13 +235,11 @@ public class MarkerServiceHandler {
.owner("CARD_TYPE_USER_DATA")
.latitude(39.574525d + new Random().nextDouble())
.longitude(116.21733d + new Random().nextDouble());
IMogoMarker marker = getMarkerManager().addMarker(TAG, options);
IMogoMarker marker = getMarkerManager().addMarker("CARD_TYPE_USER_DATA", options);
marker.setInfoWindowAdapter(markerInfoWindowAdapter);
marker.setOnMarkerClickListener(mogoMarkerClickListener);
getMapUIController().changeZoom(false);
marker.setObject("我是Marker上面绑定的数据");
getMapUIController().changeZoom(10);
}
}

View File

@@ -26,4 +26,26 @@ public class ServiceConst {
* 倒计时间隔
*/
public static final int DECREASE_INTERVAL = 1_000;
/**
* 卡片 车聊聊
*/
public static final String CARD_TYPE_CARS_CHATTING = "CARD_TYPE_CARS_CHATTING";
/**
* 卡片 探路数据
*/
public static final String CARD_TYPE_ROAD_CODITION = "CARD_TYPE_ROAD_CODITION";
/**
* 卡片 分享音乐
*/
public static final String CARD_TYPE_SHARE_MUSIC = "CARD_TYPE_SHARE_MUSIC";
/**
* 卡片 用户数据
*/
public static final String CARD_TYPE_USER_DATA = "CARD_TYPE_USER_DATA";
}