opt
This commit is contained in:
@@ -322,7 +322,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
carPoints.add( new MogoLatLng( markerLocation.getLat(), markerLocation.getLon() ) );
|
||||
}
|
||||
|
||||
String sn = getCarSnFromEntity( markerOnlineCar );
|
||||
String sn = getPrimaryKeyFromEntity( markerOnlineCar );
|
||||
IMogoMarker mogoMarker = existCarMap.get( sn );
|
||||
if ( mogoMarker == null ) {
|
||||
mogoMarker = drawMapMarker( markerShowEntity, ServiceConst.MARKER_Z_INDEX_LOW );
|
||||
@@ -361,7 +361,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
markerShowEntity.setMarkerType( markerExploreWay.getType() );
|
||||
markerShowEntity.setTextContent( markerExploreWay.getAddr() );
|
||||
|
||||
String sn = getCarSnFromEntity( markerExploreWay );
|
||||
String sn = getPrimaryKeyFromEntity( markerExploreWay );
|
||||
IMogoMarker mogoMarker = existCarMap.get( sn );
|
||||
if ( mogoMarker == null ) {
|
||||
Logger.d( TAG, "draw road condition, sn = %s", sn );
|
||||
@@ -371,70 +371,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 共享音乐
|
||||
*
|
||||
* @param shareMusicList
|
||||
*/
|
||||
private void drawShareMusicMarker( List< MarkerShareMusic > shareMusicList, int maxAmount ) {
|
||||
if ( shareMusicList == null || shareMusicList.isEmpty() ) {
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_SHARE_MUSIC );
|
||||
return;
|
||||
}
|
||||
int size = getAppropriateSize( maxAmount, shareMusicList );
|
||||
Map< String, IMogoMarker > existCarMap = purgeMarkerData( shareMusicList, ModuleNames.CARD_TYPE_SHARE_MUSIC );
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
MarkerShareMusic markerShareMusic = shareMusicList.get( i );
|
||||
MarkerLocation markerLocation = markerShareMusic.getLocation();
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj( markerShareMusic );
|
||||
markerShowEntity.setMarkerLocation( markerLocation );
|
||||
markerShowEntity.setMarkerType( markerShareMusic.getType() );
|
||||
markerShowEntity.setTextContent( markerShareMusic.getMediaName() );
|
||||
markerShowEntity.setIconUrl( markerShareMusic.getMediaImg() );
|
||||
|
||||
String sn = getCarSnFromEntity( markerShareMusic );
|
||||
IMogoMarker mogoMarker = existCarMap.get( sn );
|
||||
if ( mogoMarker == null ) {
|
||||
drawMapMarker( markerShowEntity, ServiceConst.MARKER_Z_INDEX_HIGH );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新鲜事
|
||||
*
|
||||
* @param noveltyInfoList
|
||||
*/
|
||||
private void drawNoveltyMarker( List< MarkerNoveltyInfo > noveltyInfoList, int maxAmount ) {
|
||||
if ( noveltyInfoList == null || noveltyInfoList.isEmpty() ) {
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers( ModuleNames.CARD_TYPE_NOVELTY );
|
||||
return;
|
||||
}
|
||||
int size = getAppropriateSize( maxAmount, noveltyInfoList );
|
||||
Map< String, IMogoMarker > existCarMap = purgeMarkerData( noveltyInfoList, ModuleNames.CARD_TYPE_NOVELTY );
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
MarkerNoveltyInfo noveltyInfo = noveltyInfoList.get( i );
|
||||
MarkerLocation markerLocation = noveltyInfo.getLocation();
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj( noveltyInfo );
|
||||
markerShowEntity.setMarkerLocation( markerLocation );
|
||||
markerShowEntity.setMarkerType( noveltyInfo.getType() );
|
||||
String address = noveltyInfo.getLocation().getAddress();
|
||||
if ( !TextUtils.isEmpty( address ) ) {
|
||||
markerShowEntity.setTextContent( address );
|
||||
} else {
|
||||
markerShowEntity.setTextContent( noveltyInfo.getContentData().getTitle() );
|
||||
}
|
||||
String sn = getCarSnFromEntity( noveltyInfo );
|
||||
IMogoMarker mogoMarker = existCarMap.get( sn );
|
||||
if ( mogoMarker == null ) {
|
||||
drawMapMarker( markerShowEntity, ServiceConst.MARKER_Z_INDEX_HIGH );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* S = (A ∩ B) ∪ B
|
||||
* (A ∩ B)作为旧列表需要保留的部分
|
||||
@@ -456,11 +392,11 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
Map< String, IMogoMarker > allMap = new HashMap<>();
|
||||
for ( IMogoMarker marker : allCarsList ) {
|
||||
String sn = getCarSnFromMarker( marker );
|
||||
String sn = getPrimaryKeyFromMarker( marker );
|
||||
allMap.put( sn, marker );
|
||||
}
|
||||
for ( Object entity : newList ) {
|
||||
String sn = getCarSnFromEntity( entity );
|
||||
String sn = getPrimaryKeyFromEntity( entity );
|
||||
if ( allMap.containsKey( sn ) ) {
|
||||
existMap.put( sn, allMap.get( sn ) );
|
||||
}
|
||||
@@ -477,6 +413,26 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
return existMap;
|
||||
}
|
||||
|
||||
private String getPrimaryKeyFromEntity( Object entity ) {
|
||||
if ( entity instanceof MarkerExploreWay ) {
|
||||
String id = ( ( MarkerExploreWay ) entity ).getInfoId();
|
||||
if ( !TextUtils.isEmpty( id ) ) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
return getCarSnFromEntity( entity );
|
||||
}
|
||||
|
||||
private String getPrimaryKeyFromMarker( IMogoMarker marker ) {
|
||||
if ( marker == null || marker.getObject() == null || marker.isDestroyed() ) {
|
||||
return null;
|
||||
}
|
||||
if ( !( marker.getObject() instanceof MarkerShowEntity ) ) {
|
||||
return null;
|
||||
}
|
||||
return getPrimaryKeyFromEntity( ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() );
|
||||
}
|
||||
|
||||
private String getCarSnFromEntity( Object entity ) {
|
||||
try {
|
||||
if ( entity instanceof MarkerOnlineCar ) {
|
||||
|
||||
Reference in New Issue
Block a user