Skip to content

Commit 1665d7f

Browse files
chrisbobbegnprice
authored andcommitted
android [nfc]: Use Kotlin's .apply scope function for some simplification
https://kotlinlang.org/docs/scope-functions.html#apply
1 parent 6553734 commit 1665d7f

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

android/app/src/main/java/com/zulipmobile/notifications/NotificationsModule.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,18 @@ internal class NotificationsModule(reactContext: ReactApplicationContext) :
4343
// that's #3838.
4444
@ReactMethod
4545
fun googlePlayServicesAvailability(promise: Promise) {
46-
val result = Arguments.createMap()
4746
val googleApiAvailability = GoogleApiAvailability.getInstance()
4847

4948
// https://developers.google.com/android/reference/com/google/android/gms/common/GoogleApiAvailability#isGooglePlayServicesAvailable(android.content.Context)
5049
val connectionResult = ConnectionResult(
5150
googleApiAvailability.isGooglePlayServicesAvailable(reactApplicationContext))
52-
result.putInt("errorCode", connectionResult.errorCode)
53-
result.putString("errorMessage", connectionResult.errorMessage)
54-
result.putBoolean("hasResolution", connectionResult.hasResolution())
55-
result.putBoolean("isSuccess", connectionResult.isSuccess)
56-
57-
// Keep return value in sync with the Flow type on the JS side.
58-
promise.resolve(result)
51+
promise.resolve(Arguments.createMap().apply {
52+
// Keep return value in sync with the Flow type on the JS side.
53+
putInt("errorCode", connectionResult.errorCode)
54+
putString("errorMessage", connectionResult.errorMessage)
55+
putBoolean("hasResolution", connectionResult.hasResolution())
56+
putBoolean("isSuccess", connectionResult.isSuccess)
57+
})
5958
}
6059

6160
/**

0 commit comments

Comments
 (0)