Skip to content

Commit b8f6850

Browse files
committed
chore: apply ktlint formatting
1 parent 986c008 commit b8f6850

7 files changed

Lines changed: 107 additions & 40 deletions

File tree

android/src/main/java/com/rngooglemapsplus/MapLifecycleEventObserver.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ class MapLifecycleEventObserver(
5858

5959
private fun invokeEvent(event: Lifecycle.Event) {
6060
when (event) {
61-
Lifecycle.Event.ON_CREATE -> mapView?.onCreate(Bundle())
62-
Lifecycle.Event.ON_START -> mapView?.onStart()
61+
Lifecycle.Event.ON_CREATE -> {
62+
mapView?.onCreate(Bundle())
63+
}
64+
65+
Lifecycle.Event.ON_START -> {
66+
mapView?.onStart()
67+
}
68+
6369
Lifecycle.Event.ON_RESUME -> {
6470
locationHandler.start()
6571
mapView?.onResume()
@@ -70,8 +76,14 @@ class MapLifecycleEventObserver(
7076
locationHandler.stop()
7177
}
7278

73-
Lifecycle.Event.ON_STOP -> mapView?.onStop()
74-
Lifecycle.Event.ON_DESTROY -> mapView?.onDestroy()
79+
Lifecycle.Event.ON_STOP -> {
80+
mapView?.onStop()
81+
}
82+
83+
Lifecycle.Event.ON_DESTROY -> {
84+
mapView?.onDestroy()
85+
}
86+
7587
Lifecycle.Event.ON_ANY -> {}
7688
}
7789
currentState = event.targetState

android/src/main/java/com/rngooglemapsplus/MapMarkerBuilder.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ class MapMarkerBuilder(
116116
result
117117
}
118118

119-
else -> null
119+
else -> {
120+
null
121+
}
120122
}
121123
}.onFailure {
122124
mapsLog("external svg resolve failed")

android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class RNGoogleMapsPlusView(
150150
nextById.forEach { (id, next) ->
151151
val prev = prevById[id]
152152
when {
153-
prev == null ->
153+
prev == null -> {
154154
markerBuilder.buildIconAsync(next) { icon ->
155155
view.addMarker(
156156
id,
@@ -161,11 +161,13 @@ class RNGoogleMapsPlusView(
161161
),
162162
)
163163
}
164+
}
164165

165-
!prev.markerEquals(next) ->
166+
!prev.markerEquals(next) -> {
166167
view.updateMarker(id) { marker ->
167168
markerBuilder.update(prev, next, marker)
168169
}
170+
}
169171
}
170172
}
171173
}
@@ -183,13 +185,15 @@ class RNGoogleMapsPlusView(
183185
nextById.forEach { (id, next) ->
184186
val prev = prevById[id]
185187
when {
186-
prev == null ->
188+
prev == null -> {
187189
view.addPolyline(id, polylineBuilder.build(next))
190+
}
188191

189-
!prev.polylineEquals(next) ->
192+
!prev.polylineEquals(next) -> {
190193
view.updatePolyline(id) { polyline ->
191194
polylineBuilder.update(prev, next, polyline)
192195
}
196+
}
193197
}
194198
}
195199
}
@@ -208,13 +212,15 @@ class RNGoogleMapsPlusView(
208212
nextById.forEach { (id, next) ->
209213
val prev = prevById[id]
210214
when {
211-
prev == null ->
215+
prev == null -> {
212216
view.addPolygon(id, polygonBuilder.build(next))
217+
}
213218

214-
!prev.polygonEquals(next) ->
219+
!prev.polygonEquals(next) -> {
215220
view.updatePolygon(id) { polygon ->
216221
polygonBuilder.update(prev, next, polygon)
217222
}
223+
}
218224
}
219225
}
220226
}
@@ -233,13 +239,15 @@ class RNGoogleMapsPlusView(
233239
nextById.forEach { (id, next) ->
234240
val prev = prevById[id]
235241
when {
236-
prev == null ->
242+
prev == null -> {
237243
view.addCircle(id, circleBuilder.build(next))
244+
}
238245

239-
!prev.circleEquals(next) ->
246+
!prev.circleEquals(next) -> {
240247
view.updateCircle(id) { circle ->
241248
circleBuilder.update(prev, next, circle)
242249
}
250+
}
243251
}
244252
}
245253
}

android/src/main/java/com/rngooglemapsplus/extensions/IntExtension.kt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,31 @@ import com.rngooglemapsplus.RNMapErrorCode
55

66
fun Int.toRNMapErrorCodeOrNull(): RNMapErrorCode? =
77
when (this) {
8-
ConnectionResult.SERVICE_MISSING ->
8+
ConnectionResult.SERVICE_MISSING -> {
99
RNMapErrorCode.PLAY_SERVICES_MISSING
10+
}
1011

11-
ConnectionResult.SERVICE_INVALID ->
12+
ConnectionResult.SERVICE_INVALID -> {
1213
RNMapErrorCode.PLAY_SERVICES_INVALID
14+
}
1315

14-
ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED ->
16+
ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED -> {
1517
RNMapErrorCode.PLAY_SERVICES_OUTDATED
18+
}
1619

17-
ConnectionResult.SERVICE_UPDATING ->
20+
ConnectionResult.SERVICE_UPDATING -> {
1821
RNMapErrorCode.PLAY_SERVICE_UPDATING
22+
}
1923

20-
ConnectionResult.SERVICE_DISABLED ->
24+
ConnectionResult.SERVICE_DISABLED -> {
2125
RNMapErrorCode.PLAY_SERVICES_DISABLED
26+
}
2227

23-
ConnectionResult.SUCCESS ->
28+
ConnectionResult.SUCCESS -> {
2429
null
30+
}
2531

26-
else ->
32+
else -> {
2733
RNMapErrorCode.UNKNOWN
34+
}
2835
}

android/src/main/java/com/rngooglemapsplus/extensions/LocationExtension.kt

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,53 +20,73 @@ fun Location.toRnLocation(): RNLocation =
2020
elapsedRealtimeNanos = elapsedRealtimeNanos.toDouble(),
2121
bearingAccuracyDegrees =
2222
when {
23-
Build.VERSION.SDK_INT < Build.VERSION_CODES.O -> null
24-
else ->
23+
Build.VERSION.SDK_INT < Build.VERSION_CODES.O -> {
24+
null
25+
}
26+
27+
else -> {
2528
try {
2629
if (hasBearingAccuracy()) bearingAccuracyDegrees.toDouble() else null
2730
} catch (_: IllegalStateException) {
2831
null
2932
}
33+
}
3034
},
3135
speedAccuracyMetersPerSecond =
3236
when {
33-
Build.VERSION.SDK_INT < Build.VERSION_CODES.O -> null
34-
else ->
37+
Build.VERSION.SDK_INT < Build.VERSION_CODES.O -> {
38+
null
39+
}
40+
41+
else -> {
3542
try {
3643
if (hasSpeedAccuracy()) speedAccuracyMetersPerSecond.toDouble() else null
3744
} catch (_: IllegalStateException) {
3845
null
3946
}
47+
}
4048
},
4149
verticalAccuracyMeters =
4250
when {
43-
Build.VERSION.SDK_INT < Build.VERSION_CODES.O -> null
44-
else ->
51+
Build.VERSION.SDK_INT < Build.VERSION_CODES.O -> {
52+
null
53+
}
54+
55+
else -> {
4556
try {
4657
if (hasVerticalAccuracy()) verticalAccuracyMeters.toDouble() else null
4758
} catch (_: IllegalStateException) {
4859
null
4960
}
61+
}
5062
},
5163
mslAltitudeMeters =
5264
when {
53-
Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> null
54-
else ->
65+
Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> {
66+
null
67+
}
68+
69+
else -> {
5570
try {
5671
if (hasMslAltitude()) mslAltitudeMeters else null
5772
} catch (_: IllegalStateException) {
5873
null
5974
}
75+
}
6076
},
6177
mslAltitudeAccuracyMeters =
6278
when {
63-
Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> null
64-
else ->
79+
Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> {
80+
null
81+
}
82+
83+
else -> {
6584
try {
6685
if (hasMslAltitude()) mslAltitudeAccuracyMeters.toDouble() else null
6786
} catch (_: IllegalStateException) {
6887
null
6988
}
89+
}
7090
},
7191
isMock =
7292
when {

android/src/main/java/com/rngooglemapsplus/extensions/StringExtension.kt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,28 @@ private fun parseCssColor(input: String): Int {
2323
private fun normalizeHexColor(hex: String): String {
2424
val h = hex.removePrefix("#")
2525
return when (h.length) {
26-
3 ->
26+
3 -> {
2727
"#FF" +
2828
h
2929
.map { "$it$it" }
3030
.joinToString("")
31+
}
3132

32-
4 -> "#" + h[0] + h[0] + h[1] + h[1] + h[2] + h[2] + h[3] + h[3]
33-
6 -> "#FF$h"
34-
8 -> "#$h"
35-
else -> "#$h"
33+
4 -> {
34+
"#" + h[0] + h[0] + h[1] + h[1] + h[2] + h[2] + h[3] + h[3]
35+
}
36+
37+
6 -> {
38+
"#FF$h"
39+
}
40+
41+
8 -> {
42+
"#$h"
43+
}
44+
45+
else -> {
46+
"#$h"
47+
}
3648
}
3749
}
3850

android/src/main/java/com/rngooglemapsplus/extensions/ThrowableExtension.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,27 @@ import com.rngooglemapsplus.RNLocationErrorCode
1010

1111
fun Throwable.toLocationErrorCode(context: Context): RNLocationErrorCode {
1212
return when (this) {
13-
is SecurityException -> RNLocationErrorCode.PERMISSION_DENIED
13+
is SecurityException -> {
14+
RNLocationErrorCode.PERMISSION_DENIED
15+
}
1416

15-
is ApiException ->
17+
is ApiException -> {
1618
when (statusCode) {
17-
CommonStatusCodes.NETWORK_ERROR ->
19+
CommonStatusCodes.NETWORK_ERROR -> {
1820
RNLocationErrorCode.POSITION_UNAVAILABLE
21+
}
1922

2023
LocationSettingsStatusCodes.RESOLUTION_REQUIRED,
2124
LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE,
22-
->
25+
-> {
2326
RNLocationErrorCode.SETTINGS_NOT_SATISFIED
27+
}
2428

25-
else ->
29+
else -> {
2630
RNLocationErrorCode.INTERNAL_ERROR
31+
}
2732
}
33+
}
2834

2935
else -> {
3036
if (message?.contains("GoogleApi", ignoreCase = true) == true) {

0 commit comments

Comments
 (0)