Skip to content

Commit

Permalink
chore: reformat kotlin code with new formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
jokerttu committed Nov 6, 2024
1 parent b02ca0c commit ab3a06d
Show file tree
Hide file tree
Showing 24 changed files with 392 additions and 485 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ object Convert {
position.bearing.toDouble(),
LatLngDto(position.target.latitude, position.target.longitude),
position.tilt.toDouble(),
position.zoom.toDouble()
position.zoom.toDouble(),
)
}

Expand All @@ -166,7 +166,7 @@ object Convert {
convertLatLngFromDto(position.target),
position.zoom.toFloat(),
position.tilt.toFloat(),
position.bearing.toFloat()
position.bearing.toFloat(),
)
}

Expand All @@ -184,7 +184,7 @@ object Convert {
focus =
Point(
convertLogicalToScreenPixel(dx, density).toInt(),
convertLogicalToScreenPixel(dy, density).toInt()
convertLogicalToScreenPixel(dy, density).toInt(),
)
}
return focus
Expand Down Expand Up @@ -313,7 +313,7 @@ object Convert {
convertLatLngToDto(waypoint.position),
waypoint.placeId,
waypoint.preferSameSideOfRoad,
waypoint.preferredHeading.takeIf { it != -1 }?.toLong()
waypoint.preferredHeading.takeIf { it != -1 }?.toLong(),
)
}

Expand All @@ -326,7 +326,7 @@ object Convert {
fun convertTimeAndDistanceToDto(timeAndDistance: TimeAndDistance): NavigationTimeAndDistanceDto {
return NavigationTimeAndDistanceDto(
timeAndDistance.seconds.toDouble(),
timeAndDistance.meters.toDouble()
timeAndDistance.meters.toDouble(),
)
}

Expand Down Expand Up @@ -516,11 +516,11 @@ object Convert {
.setSeverityUpgradeDurationSeconds(options.severityUpgradeDurationSeconds)
.setSpeedAlertThresholdPercentage(
SpeedAlertSeverity.MINOR,
options.minorSpeedAlertThresholdPercentage.toFloat()
options.minorSpeedAlertThresholdPercentage.toFloat(),
)
.setSpeedAlertThresholdPercentage(
SpeedAlertSeverity.MAJOR,
options.majorSpeedAlertThresholdPercentage.toFloat()
options.majorSpeedAlertThresholdPercentage.toFloat(),
)
.build()
}
Expand All @@ -533,7 +533,7 @@ object Convert {
fun sinkMarkerOptions(
markerOptions: MarkerOptionsDto,
sink: MarkerOptionsSink,
imageRegistry: ImageRegistry
imageRegistry: ImageRegistry,
) {
sink.setAlpha(markerOptions.alpha.toFloat())
sink.setAnchor(markerOptions.anchor.u.toFloat(), markerOptions.anchor.v.toFloat())
Expand All @@ -542,7 +542,7 @@ object Convert {
sink.setConsumeTapEvents(markerOptions.consumeTapEvents)
sink.setInfoWindowAnchor(
markerOptions.infoWindow.anchor.u.toFloat(),
markerOptions.infoWindow.anchor.v.toFloat()
markerOptions.infoWindow.anchor.v.toFloat(),
)
sink.setPosition(LatLng(markerOptions.position.latitude, markerOptions.position.longitude))
sink.setRotation(markerOptions.rotation.toFloat())
Expand Down Expand Up @@ -584,16 +584,16 @@ object Convert {
// Should never happen, added to suppress compiler warning.
throw FlutterError(
"nullTrafficDataRoadStretchRenderingDataListStyle",
"Traffic data road stretch rendering data list style is null"
"Traffic data road stretch rendering data list style is null",
)
}
}
RouteSegmentTrafficDataRoadStretchRenderingDataDto(
style,
it.lengthMeters.toLong(),
it.offsetMeters.toLong()
it.offsetMeters.toLong(),
)
}
},
)
}

Expand All @@ -602,7 +602,7 @@ object Convert {
convertRouteSegmentTrafficDataToDto(segment.trafficData),
LatLngDto(segment.destinationLatLng.latitude, segment.destinationLatLng.longitude),
segment.latLngs.map { LatLngDto(it.latitude, it.longitude) },
convertWaypointToDto(segment.destinationWaypoint)
convertWaypointToDto(segment.destinationWaypoint),
)
}

Expand All @@ -614,7 +614,7 @@ object Convert {
fun sinkPolygonOptions(
polygonOptions: PolygonOptionsDto,
sink: PolygonOptionsSink,
density: Float
density: Float,
) {
sink.setPoints(polygonOptions.points.filterNotNull().map { LatLng(it.latitude, it.longitude) })
sink.setHoles(
Expand Down Expand Up @@ -650,7 +650,7 @@ object Convert {
strokeWidth = convertScreenToLogicalPixel(polygon.strokeWidth.toDouble(), density),
strokeColor = polygon.strokeColor.toLong(),
visible = polygon.isVisible,
zIndex = polygon.zIndex.toDouble()
zIndex = polygon.zIndex.toDouble(),
)
}

Expand All @@ -677,12 +677,12 @@ object Convert {
marker.snippet,
MarkerAnchorDto(
markerController.infoWindowAnchorU.toDouble(),
markerController.infoWindowAnchorV.toDouble()
)
markerController.infoWindowAnchorV.toDouble(),
),
),
visible = marker.isVisible,
zIndex = marker.zIndex.toDouble(),
icon = registeredImageToImageDescriptorDto(markerController.registeredImage)
icon = registeredImageToImageDescriptorDto(markerController.registeredImage),
)
}

Expand All @@ -700,7 +700,7 @@ object Convert {
return StyleSpan(
StrokeStyle.gradientBuilder(span.style.fromColor.toInt(), span.style.toColor.toInt())
.build(),
span.length
span.length,
)
}
return null
Expand Down Expand Up @@ -785,7 +785,7 @@ object Convert {
timeToCurrentStepSeconds = navInfo.timeToCurrentStepSeconds?.toLong(),
timeToNextDestinationSeconds = navInfo.timeToNextDestinationSeconds?.toLong(),
timeToFinalDestinationSeconds = navInfo.timeToFinalDestinationSeconds?.toLong(),
navState = convertNavState(navInfo.navState)
navState = convertNavState(navInfo.navState),
)
}

Expand Down Expand Up @@ -936,7 +936,7 @@ object Convert {
fun sinkPolylineOptions(
polylineOptions: PolylineOptionsDto,
sink: PolylineOptionsSink,
density: Float
density: Float,
) {
if (polylineOptions.points != null) {
sink.setPoints(
Expand Down Expand Up @@ -993,7 +993,7 @@ object Convert {
strokePattern = polyline.pattern?.map { convertPatternItem(it) },
visible = polyline.isVisible,
zIndex = polyline.zIndex.toDouble(),
spans = polyline.spans.map { convertStyleSpan(it) }
spans = polyline.spans.map { convertStyleSpan(it) },
)
}

Expand Down Expand Up @@ -1031,7 +1031,7 @@ object Convert {
fillColor = circle.fillColor.toLong(),
zIndex = circle.zIndex.toDouble(),
visible = circle.isVisible,
clickable = circle.isClickable
clickable = circle.isClickable,
)
}

Expand All @@ -1048,7 +1048,7 @@ object Convert {
registeredImage.imageId,
registeredImage.imagePixelRatio,
registeredImage.width,
registeredImage.height
registeredImage.height,
)
} else {
// For default marker icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal constructor(
viewId: Int,
viewEventApi: ViewEventApi,
private val viewRegistry: GoogleMapsViewRegistry,
imageRegistry: ImageRegistry
imageRegistry: ImageRegistry,
) : PlatformView, GoogleMapsBaseMapView(viewId, mapOptions, viewEventApi, imageRegistry) {
private val _mapView: MapView = MapView(context, mapOptions)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class GoogleMapsBaseMapView(
protected val viewId: Int,
mapOptions: GoogleMapOptions,
protected val viewEventApi: ViewEventApi,
private val imageRegistry: ImageRegistry
private val imageRegistry: ImageRegistry,
) {
companion object {
const val INVALIDATION_FRAME_SKIP_AMOUNT = 4 // Amount of skip frames before invalidation
Expand Down Expand Up @@ -105,16 +105,10 @@ abstract class GoogleMapsBaseMapView(

protected open fun initListeners() {
getMap().setOnMapClickListener {
viewEventApi.onMapClickEvent(
viewId.toLong(),
LatLngDto(it.latitude, it.longitude),
) {}
viewEventApi.onMapClickEvent(viewId.toLong(), LatLngDto(it.latitude, it.longitude)) {}
}
getMap().setOnMapLongClickListener {
viewEventApi.onMapLongClickEvent(
viewId.toLong(),
LatLngDto(it.latitude, it.longitude),
) {}
viewEventApi.onMapLongClickEvent(viewId.toLong(), LatLngDto(it.latitude, it.longitude)) {}
}
getMap().setOnMarkerClickListener { marker ->
val markerId = findMarkerId(marker)
Expand Down Expand Up @@ -189,15 +183,15 @@ abstract class GoogleMapsBaseMapView(
viewEventApi.onCameraChanged(
viewId.toLong(),
CameraEventTypeDto.ONCAMERASTARTEDFOLLOWINGLOCATION,
Convert.convertCameraPositionToDto(getMap().cameraPosition)
Convert.convertCameraPositionToDto(getMap().cameraPosition),
) {}
}

override fun onCameraStoppedFollowingLocation() {
viewEventApi.onCameraChanged(
viewId.toLong(),
CameraEventTypeDto.ONCAMERASTOPPEDFOLLOWINGLOCATION,
Convert.convertCameraPositionToDto(getMap().cameraPosition)
Convert.convertCameraPositionToDto(getMap().cameraPosition),
) {}
}
}
Expand Down Expand Up @@ -284,7 +278,7 @@ abstract class GoogleMapsBaseMapView(
viewId.toLong(),
markerId,
eventType,
LatLngDto(marker.position.latitude, marker.position.longitude)
LatLngDto(marker.position.latitude, marker.position.longitude),
) {}
}

Expand Down Expand Up @@ -332,7 +326,7 @@ abstract class GoogleMapsBaseMapView(
if (minZoomPreference > (_maxZoomLevelPreference ?: getMap().maxZoomLevel)) {
throw FlutterError(
"minZoomGreaterThanMaxZoom",
"Minimum zoom level cannot be greater than maximum zoom level"
"Minimum zoom level cannot be greater than maximum zoom level",
)
}

Expand All @@ -345,7 +339,7 @@ abstract class GoogleMapsBaseMapView(
if (maxZoomPreference < (_minZoomLevelPreference ?: getMap().minZoomLevel)) {
throw FlutterError(
"maxZoomLessThanMinZoom",
"Maximum zoom level cannot be less than minimum zoom level"
"Maximum zoom level cannot be less than minimum zoom level",
)
}

Expand Down Expand Up @@ -427,7 +421,8 @@ abstract class GoogleMapsBaseMapView(
// library for geolocation or implement separate method under
// [GoogleMapsNavigationSessionManager] to fetch the location
// using the [FusedLocationProviderApi].
@Suppress("DEPRECATION") return getMap().myLocation
@Suppress("DEPRECATION")
return getMap().myLocation
}

fun getCameraPosition(): CameraPosition {
Expand All @@ -453,7 +448,7 @@ abstract class GoogleMapsBaseMapView(
private fun animateCamera(
cameraUpdate: CameraUpdate,
duration: Long?,
callback: (Result<Boolean>) -> Unit
callback: (Result<Boolean>) -> Unit,
) {
// Native animateCamera() doesn't allow setting null duration so need to do two calls
if (duration == null) {
Expand All @@ -466,7 +461,7 @@ abstract class GoogleMapsBaseMapView(
fun animateCameraToCameraPosition(
cameraPosition: CameraPosition,
duration: Long?,
callback: (Result<Boolean>) -> Unit
callback: (Result<Boolean>) -> Unit,
) {
animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), duration, callback)
}
Expand All @@ -479,7 +474,7 @@ abstract class GoogleMapsBaseMapView(
bounds: LatLngBounds,
padding: Double,
duration: Long?,
callback: (Result<Boolean>) -> Unit
callback: (Result<Boolean>) -> Unit,
) {
animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding.toInt()), duration, callback)
}
Expand All @@ -488,7 +483,7 @@ abstract class GoogleMapsBaseMapView(
point: LatLng,
zoom: Double,
duration: Long?,
callback: (Result<Boolean>) -> Unit
callback: (Result<Boolean>) -> Unit,
) {
animateCamera(CameraUpdateFactory.newLatLngZoom(point, zoom.toFloat()), duration, callback)
}
Expand All @@ -497,20 +492,20 @@ abstract class GoogleMapsBaseMapView(
scrollByDx: Double,
scrollByDy: Double,
duration: Long?,
callback: (Result<Boolean>) -> Unit
callback: (Result<Boolean>) -> Unit,
) {
animateCamera(
CameraUpdateFactory.scrollBy(scrollByDx.toFloat(), scrollByDy.toFloat()),
duration,
callback
callback,
)
}

fun animateCameraByZoom(
zoomBy: Double,
focus: Point?,
duration: Long?,
callback: (Result<Boolean>) -> Unit
callback: (Result<Boolean>) -> Unit,
) {
// Native animateCamera() doesn't allow setting null duration or focus so need to split to
// multiple calls
Expand Down Expand Up @@ -599,7 +594,7 @@ abstract class GoogleMapsBaseMapView(
Result.failure(
FlutterError(
"mapReadyCallbackAlreadyPending",
"A callback is already pending and cannot be overridden."
"A callback is already pending and cannot be overridden.",
)
)
)
Expand Down Expand Up @@ -640,7 +635,7 @@ abstract class GoogleMapsBaseMapView(
it.options.anchor.v.toFloat(),
it.options.infoWindow.anchor.u.toFloat(),
it.options.infoWindow.anchor.v.toFloat(),
registeredImage
registeredImage,
)
_markers.add(controller)
result.add(it)
Expand Down Expand Up @@ -709,9 +704,7 @@ abstract class GoogleMapsBaseMapView(
}
}

fun addPolygons(
polygons: List<PolygonDto>,
): List<PolygonDto> {
fun addPolygons(polygons: List<PolygonDto>): List<PolygonDto> {
val density = Resources.getSystem().displayMetrics.density
invalidateViewAfterMapLoad()
val result = mutableListOf<PolygonDto>()
Expand Down Expand Up @@ -778,9 +771,7 @@ abstract class GoogleMapsBaseMapView(
}
}

fun addPolylines(
polylines: List<PolylineDto>,
): List<PolylineDto> {
fun addPolylines(polylines: List<PolylineDto>): List<PolylineDto> {
val density = Resources.getSystem().displayMetrics.density
invalidateViewAfterMapLoad()
val result = mutableListOf<PolylineDto>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class GoogleMapsImageRegistryMessageHandler(private val imageRegistry: ImageRegi
bytes: ByteArray,
imagePixelRatio: Double,
width: Double?,
height: Double?
height: Double?,
): ImageDescriptorDto {
return imageRegistry.registerBitmapImage(imageId, bytes, imagePixelRatio, width, height)
}
Expand Down
Loading

0 comments on commit ab3a06d

Please sign in to comment.