extend interface of marker invisible
This commit is contained in:
@@ -83,7 +83,7 @@ public interface IMogoMarkerManager {
|
||||
* 隐藏除了某些类别的所有marker {@link MogoMarkerOptions Owner}
|
||||
* @param owner
|
||||
*/
|
||||
void inVisibleWithoutMarkers(String owner); //todo 后续需要把Owner类别统一起来,基类下沉,此接口为临时方案,应该设计为隐藏某一类元素
|
||||
void inVisibleWithoutMarkers(String ...owner); //todo 后续需要把Owner类别统一起来,基类下沉,此接口为临时方案,应该设计为隐藏某一类元素
|
||||
|
||||
/**
|
||||
* 获取某种类型的全部marker。
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.listener.IMogoMapListenerRegister;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -28,9 +29,9 @@ public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarker
|
||||
private IMogoMarkerClickListener mDelegate;
|
||||
|
||||
public static MogoMarkersHandler getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MogoMarkersHandler.class ) {
|
||||
if ( sInstance == null ) {
|
||||
if (sInstance == null) {
|
||||
synchronized (MogoMarkersHandler.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MogoMarkersHandler();
|
||||
}
|
||||
}
|
||||
@@ -38,7 +39,7 @@ public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarker
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private final Map< String, List< IMogoMarker > > mServicesMarkers = new ConcurrentHashMap<>();
|
||||
private final Map<String, List<IMogoMarker>> mServicesMarkers = new ConcurrentHashMap<>();
|
||||
|
||||
private MogoMarkersHandler() {
|
||||
}
|
||||
@@ -48,38 +49,43 @@ public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarker
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public synchronized void visibleAll(){
|
||||
public synchronized void visibleAll() {
|
||||
mServicesMarkers.values().stream()
|
||||
.filter(mogoMarkerList -> mogoMarkerList != null && !mogoMarkerList.isEmpty())
|
||||
.forEach(mogoMarkerList -> mogoMarkerList.forEach(mogoMarker -> mogoMarker.setVisible(true)));
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public synchronized void inVisibleAll(){
|
||||
public synchronized void inVisibleAll() {
|
||||
mServicesMarkers.values().stream()
|
||||
.filter(mogoMarkerList -> mogoMarkerList != null && !mogoMarkerList.isEmpty())
|
||||
.forEach(mogoMarkerList -> mogoMarkerList.forEach(mogoMarker -> mogoMarker.setVisible(false)));
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public synchronized void inVisibleMarkers(String owner){
|
||||
public synchronized void inVisibleMarkers(String... owner) {
|
||||
mServicesMarkers.values().stream()
|
||||
.filter(mogoMarkerList -> mogoMarkerList != null && !mogoMarkerList.isEmpty())
|
||||
.forEach(mogoMarkerList -> mogoMarkerList.forEach(mogoMarker -> {
|
||||
if(TextUtils.isEmpty(mogoMarker.getOwner()) || !mogoMarker.getOwner().equals(owner)){
|
||||
if (TextUtils.isEmpty(mogoMarker.getOwner())) {
|
||||
mogoMarker.setVisible(false);
|
||||
}
|
||||
Arrays.stream(owner).forEach(own -> {
|
||||
if (!mogoMarker.getOwner().equals(own)) {
|
||||
mogoMarker.setVisible(false);
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
public synchronized void removeAll() {
|
||||
final Collection< List< IMogoMarker > > mogoMarkers = mServicesMarkers.values();
|
||||
for ( List< IMogoMarker > mogoMarkerList : mogoMarkers ) {
|
||||
if ( mogoMarkerList != null && !mogoMarkerList.isEmpty() ) {
|
||||
for ( IMogoMarker mogoMarker : mogoMarkerList ) {
|
||||
final Collection<List<IMogoMarker>> mogoMarkers = mServicesMarkers.values();
|
||||
for (List<IMogoMarker> mogoMarkerList : mogoMarkers) {
|
||||
if (mogoMarkerList != null && !mogoMarkerList.isEmpty()) {
|
||||
for (IMogoMarker mogoMarker : mogoMarkerList) {
|
||||
try {
|
||||
mogoMarker.destroy();
|
||||
} catch ( Exception e ) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -88,13 +94,13 @@ public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarker
|
||||
mServicesMarkers.clear();
|
||||
}
|
||||
|
||||
public synchronized void remove( String tag ) {
|
||||
List< IMogoMarker > mogoMarkerList = mServicesMarkers.remove( tag );
|
||||
if ( mogoMarkerList != null && !mogoMarkerList.isEmpty() ) {
|
||||
for ( IMogoMarker mogoMarker : mogoMarkerList ) {
|
||||
public synchronized void remove(String tag) {
|
||||
List<IMogoMarker> mogoMarkerList = mServicesMarkers.remove(tag);
|
||||
if (mogoMarkerList != null && !mogoMarkerList.isEmpty()) {
|
||||
for (IMogoMarker mogoMarker : mogoMarkerList) {
|
||||
try {
|
||||
mogoMarker.destroy();
|
||||
} catch ( Exception e ) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -102,38 +108,38 @@ public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarker
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized List< IMogoMarker > getMarkers( String tag ) {
|
||||
return mServicesMarkers.get( tag );
|
||||
public synchronized List<IMogoMarker> getMarkers(String tag) {
|
||||
return mServicesMarkers.get(tag);
|
||||
}
|
||||
|
||||
|
||||
public synchronized Map< String, List< IMogoMarker > > getAllMarkers() {
|
||||
public synchronized Map<String, List<IMogoMarker>> getAllMarkers() {
|
||||
return mServicesMarkers;
|
||||
}
|
||||
|
||||
|
||||
public synchronized void add( String tag, IMogoMarker marker ) {
|
||||
if ( marker == null ) {
|
||||
public synchronized void add(String tag, IMogoMarker marker) {
|
||||
if (marker == null) {
|
||||
return;
|
||||
}
|
||||
if ( mServicesMarkers.get( tag ) == null ) {
|
||||
mServicesMarkers.put( tag, new ArrayList< IMogoMarker >() );
|
||||
if (mServicesMarkers.get(tag) == null) {
|
||||
mServicesMarkers.put(tag, new ArrayList<IMogoMarker>());
|
||||
}
|
||||
mServicesMarkers.get( tag ).add( marker );
|
||||
mServicesMarkers.get(tag).add(marker);
|
||||
}
|
||||
|
||||
public synchronized void add( String tag, List< IMogoMarker > markers ) {
|
||||
if ( markers == null || markers.isEmpty() ) {
|
||||
public synchronized void add(String tag, List<IMogoMarker> markers) {
|
||||
if (markers == null || markers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if ( mServicesMarkers.get( tag ) == null ) {
|
||||
mServicesMarkers.put( tag, new ArrayList< IMogoMarker >() );
|
||||
if (mServicesMarkers.get(tag) == null) {
|
||||
mServicesMarkers.put(tag, new ArrayList<IMogoMarker>());
|
||||
}
|
||||
mServicesMarkers.get( tag ).addAll( markers );
|
||||
mServicesMarkers.get(tag).addAll(markers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMarkerClickListener( IMogoMarkerClickListener listener ) {
|
||||
public void registerMarkerClickListener(IMogoMarkerClickListener listener) {
|
||||
mDelegate = listener;
|
||||
}
|
||||
|
||||
@@ -143,17 +149,17 @@ public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarker
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMarkerClicked( IMogoMarker marker ) {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.onMarkerClicked( marker );
|
||||
public boolean onMarkerClicked(IMogoMarker marker) {
|
||||
if (mDelegate != null) {
|
||||
return mDelegate.onMarkerClicked(marker);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStaticMarkerClicked(IMogoMarker marker) {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.onStaticMarkerClicked( marker );
|
||||
if (mDelegate != null) {
|
||||
return mDelegate.onStaticMarkerClicked(marker);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -161,19 +167,19 @@ public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarker
|
||||
/**
|
||||
* @param tag 需要保留的类型
|
||||
*/
|
||||
public void deleteAllExcept( String tag ) {
|
||||
if ( TextUtils.isEmpty( tag ) ) {
|
||||
public void deleteAllExcept(String tag) {
|
||||
if (TextUtils.isEmpty(tag)) {
|
||||
return;
|
||||
}
|
||||
List< IMogoMarker > mogoMarkerList = mServicesMarkers.remove( tag );
|
||||
for ( List< IMogoMarker > value : mServicesMarkers.values() ) {
|
||||
if ( value != null && !value.isEmpty() ) {
|
||||
for ( IMogoMarker mogoMarker : value ) {
|
||||
List<IMogoMarker> mogoMarkerList = mServicesMarkers.remove(tag);
|
||||
for (List<IMogoMarker> value : mServicesMarkers.values()) {
|
||||
if (value != null && !value.isEmpty()) {
|
||||
for (IMogoMarker mogoMarker : value) {
|
||||
mogoMarker.destroy();
|
||||
}
|
||||
value.clear();
|
||||
}
|
||||
}
|
||||
mServicesMarkers.put( tag, mogoMarkerList );
|
||||
mServicesMarkers.put(tag, mogoMarkerList);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user