Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing reason for cameraMoveStartedEvents() flow #169

Merged
merged 1 commit into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions app/src/main/java/com/google/maps/android/ktx/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,7 @@ import com.google.maps.android.collections.PolylineManager
import com.google.maps.android.data.Renderer.ImagesCache
import com.google.maps.android.data.geojson.GeoJsonLineStringStyle
import com.google.maps.android.data.geojson.GeoJsonPolygonStyle
import com.google.maps.android.ktx.CameraIdleEvent
import com.google.maps.android.ktx.CameraMoveCanceledEvent
import com.google.maps.android.ktx.CameraMoveEvent
import com.google.maps.android.ktx.CameraMoveStartedEvent
import com.google.maps.android.ktx.awaitAnimateCamera
import com.google.maps.android.ktx.awaitMap
import com.google.maps.android.ktx.awaitMapLoad
import com.google.maps.android.ktx.awaitSnapshot
import com.google.maps.android.ktx.cameraEvents
import com.google.maps.android.ktx.awaitMap
import com.google.maps.android.ktx.cameraIdleEvents
import com.google.maps.android.ktx.cameraMoveStartedEvents
import com.google.maps.android.ktx.*
import com.google.maps.android.ktx.demo.io.MyItemReader
import com.google.maps.android.ktx.demo.model.MyItem
import com.google.maps.android.ktx.model.cameraPosition
Expand Down Expand Up @@ -100,7 +89,7 @@ class MainActivity : AppCompatActivity() {
addButtonClickListener(googleMap)
launch {
googleMap.cameraMoveStartedEvents().collect {
Log.d(TAG, "Camera moved.")
Log.d(TAG, "Camera moved - reason $it")
}
}
launch {
Expand Down
28 changes: 4 additions & 24 deletions maps-ktx/src/main/java/com/google/maps/android/ktx/GoogleMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,9 @@ import androidx.annotation.IntDef
import com.google.android.gms.maps.CameraUpdate
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.GoogleMapOptions
import com.google.android.gms.maps.model.Circle
import com.google.android.gms.maps.model.CircleOptions
import com.google.android.gms.maps.model.GroundOverlay
import com.google.android.gms.maps.model.GroundOverlayOptions
import com.google.android.gms.maps.model.IndoorBuilding
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Marker
import com.google.android.gms.maps.model.MarkerOptions
import com.google.android.gms.maps.model.PointOfInterest
import com.google.android.gms.maps.model.Polygon
import com.google.android.gms.maps.model.PolygonOptions
import com.google.android.gms.maps.model.Polyline
import com.google.android.gms.maps.model.PolylineOptions
import com.google.android.gms.maps.model.TileOverlay
import com.google.android.gms.maps.model.TileOverlayOptions
import com.google.maps.android.ktx.model.circleOptions
import com.google.maps.android.ktx.model.groundOverlayOptions
import com.google.maps.android.ktx.model.markerOptions
import com.google.maps.android.ktx.model.polygonOptions
import com.google.maps.android.ktx.model.polylineOptions
import com.google.maps.android.ktx.model.tileOverlayOptions
import com.google.android.gms.maps.model.*
import com.google.maps.android.ktx.model.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
Expand Down Expand Up @@ -234,10 +214,10 @@ public suspend inline fun GoogleMap.awaitSnapshot(bitmap: Bitmap? = null): Bitma
* events will override an existing listener (if any) to [GoogleMap.setOnCameraMoveStartedListener].
*/
@ExperimentalCoroutinesApi
public fun GoogleMap.cameraMoveStartedEvents(): Flow<Unit> =
public fun GoogleMap.cameraMoveStartedEvents(): Flow<Int> =
callbackFlow {
setOnCameraMoveStartedListener {
trySend(Unit)
trySend(it)
}
awaitClose {
setOnCameraMoveStartedListener(null)
Expand Down