Skip to content

Commit

Permalink
Rename isPointOnLocationPuck to isLocatedAt, IsPointOnLocationPuckLis…
Browse files Browse the repository at this point in the history
…tener to LocatedAtValidationListener.
  • Loading branch information
pengdev committed Feb 24, 2021
1 parent e93db26 commit 635cb05
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ class LocationComponentActivity : AppCompatActivity() {
mapView.getGesturesPlugin().scrollEnabled = false
mapView.getGesturesPlugin().addOnMapClickListener { point ->
mapView.getLocationComponentPlugin()
.isPointOnLocationPuck(point) { isPointOnLocationPuck ->
if (isPointOnLocationPuck) {
.isLocatedAt(point) { isLocationRenderedAtPoint ->
if (isLocationRenderedAtPoint) {
Toast.makeText(this, "Clicked on location puck", Toast.LENGTH_SHORT).show()
}
}
true
}
mapView.getGesturesPlugin().addOnMapLongClickListener { point ->
mapView.getLocationComponentPlugin()
.isPointOnLocationPuck(point) { isPointOnLocationPuck ->
if (isPointOnLocationPuck) {
.isLocatedAt(point) { isLocationRenderedAtPoint ->
if (isLocationRenderedAtPoint) {
Toast.makeText(this, "Long-clicked on location puck", Toast.LENGTH_SHORT).show()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ class LocationComponentPluginImpl : LocationComponentPlugin, LocationConsumer,
}

/**
* Check is a given point is on the rendered location puck.
* Check whether the rendered location puck is on the given point.
*
* @param point the point to validate
* @param listener Listener that gets invoked when the validation finished.
*/
override fun isPointOnLocationPuck(point: Point, listener: IsPointOnLocationPuckListener) {
override fun isLocatedAt(point: Point, listener: LocatedAtValidationListener) {
delegateProvider.mapFeatureQueryDelegate.queryRenderedFeatures(
delegateProvider.mapProjectionDelegate.pixelForCoordinate(point),
RenderedQueryOptions(
Expand All @@ -106,9 +106,9 @@ class LocationComponentPluginImpl : LocationComponentPlugin, LocationConsumer,
) { expected ->
expected.value?.let {
if (it.isNotEmpty()) {
listener.isPointOnLocationPuck(true)
listener.onResult(true)
} else {
listener.isPointOnLocationPuck(false)
listener.onResult(false)
}
}
expected.error?.let {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mapbox.maps.plugin.locationcomponent

/**
* Listener that gets invoked when the is location puck rendered on point validation finished.
*/
fun interface LocatedAtValidationListener {
/**
* This method is called when the is location puck rendered on point validation finished.
*
* @param isLocationRenderedAtPoint true if the given point is on the rendered location puck, false otherwise.
*/
fun onResult(isLocationRenderedAtPoint: Boolean)
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ interface LocationComponentPlugin :
fun removeOnIndicatorBearingChangedListener(listener: OnIndicatorBearingChangedListener)

/**
* Check is a given point is on the rendered location puck.
* Check whether the rendered location puck is on the given point.
*
* @param point the point to validate
* @param listener Listener that gets invoked when the validation finished.
*/
fun isPointOnLocationPuck(point: Point, listener: IsPointOnLocationPuckListener)
fun isLocatedAt(point: Point, listener: LocatedAtValidationListener)
}

0 comments on commit 635cb05

Please sign in to comment.