-
Notifications
You must be signed in to change notification settings - Fork 14
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
Apply ktlint formatting #279
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ package com.bitmovin.player.reactnative | |
import com.bitmovin.player.api.offline.options.OfflineOptionEntryState | ||
import com.bitmovin.player.reactnative.converter.JsonConverter | ||
import com.bitmovin.player.reactnative.extensions.toList | ||
import com.bitmovin.player.reactnative.offline.OfflineDownloadRequest | ||
import com.bitmovin.player.reactnative.offline.OfflineContentManagerBridge | ||
import com.bitmovin.player.reactnative.offline.OfflineDownloadRequest | ||
import com.facebook.react.bridge.* | ||
import com.facebook.react.module.annotations.ReactModule | ||
import com.facebook.react.uimanager.UIManagerModule | ||
|
@@ -69,7 +69,13 @@ class OfflineModule(private val context: ReactApplicationContext) : ReactContext | |
return@addUIBlock | ||
} | ||
|
||
offlineContentManagerBridges[nativeId] = OfflineContentManagerBridge(nativeId, context, identifier, sourceConfig, context.cacheDir.path) | ||
offlineContentManagerBridges[nativeId] = OfflineContentManagerBridge( | ||
nativeId, | ||
context, | ||
identifier, | ||
sourceConfig, | ||
context.cacheDir.path, | ||
) | ||
} | ||
promise.resolve(null) | ||
} | ||
|
@@ -117,7 +123,8 @@ class OfflineModule(private val context: ReactApplicationContext) : ReactContext | |
return@safeOfflineContentManager | ||
} | ||
OfflineOptionEntryState.Downloading, | ||
OfflineOptionEntryState.Failed -> { | ||
OfflineOptionEntryState.Failed, | ||
-> { | ||
promise.reject(IllegalStateException("Download already in progress")) | ||
return@safeOfflineContentManager | ||
} | ||
|
@@ -127,7 +134,7 @@ class OfflineModule(private val context: ReactApplicationContext) : ReactContext | |
} | ||
else -> {} | ||
} | ||
val minimumBitRate = if(request.hasKey("minimumBitrate")) request.getInt("minimumBitrate") else null | ||
val minimumBitRate = if (request.hasKey("minimumBitrate")) request.getInt("minimumBitrate") else null | ||
if (minimumBitRate != null && minimumBitRate < 0) { | ||
promise.reject(IllegalArgumentException("Invalid download request")) | ||
return@safeOfflineContentManager | ||
|
@@ -136,7 +143,9 @@ class OfflineModule(private val context: ReactApplicationContext) : ReactContext | |
val audioOptionIds = request.getArray("audioOptionIds")?.toList<String>()?.filterNotNull() | ||
val textOptionIds = request.getArray("textOptionIds")?.toList<String>()?.filterNotNull() | ||
|
||
getOfflineContentManagerBridge(nativeId)?.process(OfflineDownloadRequest(minimumBitRate, audioOptionIds, textOptionIds)) | ||
getOfflineContentManagerBridge(nativeId)?.process( | ||
OfflineDownloadRequest(minimumBitRate, audioOptionIds, textOptionIds), | ||
) | ||
promise.resolve(null) | ||
} catch (e: Exception) { | ||
promise.reject(e) | ||
|
@@ -260,20 +269,24 @@ class OfflineModule(private val context: ReactApplicationContext) : ReactContext | |
} | ||
} | ||
|
||
private fun safeOfflineContentManager(nativeId: NativeId, promise: Promise, runBlock: OfflineContentManagerBridge.() -> Unit) { | ||
private fun safeOfflineContentManager( | ||
nativeId: NativeId, | ||
promise: Promise, | ||
runBlock: OfflineContentManagerBridge.() -> Unit, | ||
) { | ||
getOfflineContentManagerBridge(nativeId)?.let(runBlock) | ||
?: promise.reject(IllegalArgumentException("Could not find the offline module instance")) | ||
?: promise.reject(IllegalArgumentException("Could not find the offline module instance")) | ||
} | ||
|
||
/** | ||
* Helper function that returns the initialized `DrmModule` instance. | ||
*/ | ||
private fun drmModule(): DrmModule? = | ||
context.getNativeModule(DrmModule::class.java) | ||
context.getNativeModule(DrmModule::class.java) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: Would fit into one line I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I missed that. |
||
|
||
/** | ||
* Helper function that returns the initialized `UIManager` instance. | ||
*/ | ||
private fun uiManager(): UIManagerModule? = | ||
context.getNativeModule(UIManagerModule::class.java) | ||
context.getNativeModule(UIManagerModule::class.java) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: Would fit into one line I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I missed that. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks odd 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I guess this is because of trailing commas rule: https://pinterest.github.io/ktlint/0.49.1/rules/configuration-ktlint/#trailing-comma-on-call-site
In the newest version of ktlint you either have the option to always have trailing commas or never. I decided to go with always, since it makes sense 99% of the time.
I'm not sure we can improve on that.