This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] - move shape annotation click handling to core
- Loading branch information
Showing
10 changed files
with
129 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
.../MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotationContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.mapbox.mapboxsdk.maps; | ||
|
||
import android.graphics.RectF; | ||
import android.support.v4.util.LongSparseArray; | ||
|
||
import com.mapbox.mapboxsdk.annotations.Annotation; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
class ShapeAnnotationContainer implements ShapeAnnotations { | ||
|
||
private final NativeMapView nativeMapView; | ||
private final LongSparseArray<Annotation> annotations; | ||
|
||
ShapeAnnotationContainer(NativeMapView nativeMapView, LongSparseArray<Annotation> annotations) { | ||
this.nativeMapView = nativeMapView; | ||
this.annotations = annotations; | ||
} | ||
|
||
@Override | ||
public List<Annotation> obtainAllIn(RectF rectangle) { | ||
RectF rect = nativeMapView.getDensityDependantRectangle(rectangle); | ||
long[] annotationIds = nativeMapView.queryShapeAnnotations(rect); | ||
return getAnnotationsFromIds(annotationIds); | ||
} | ||
|
||
private List<Annotation> getAnnotationsFromIds(long[] annotationIds) { | ||
List<Annotation> shapeAnnotations = new ArrayList<>(); | ||
for (long annotationId : annotationIds) { | ||
Annotation annotation = annotations.get(annotationId); | ||
if (annotation != null) { | ||
shapeAnnotations.add(annotation); | ||
} | ||
} | ||
return shapeAnnotations; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.mapbox.mapboxsdk.maps; | ||
|
||
import android.graphics.RectF; | ||
|
||
import com.mapbox.mapboxsdk.annotations.Annotation; | ||
|
||
import java.util.List; | ||
|
||
interface ShapeAnnotations { | ||
|
||
List<Annotation> obtainAllIn(RectF rectF); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters