diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt index 78308d2c4..95d7232c1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/MediaSaverToDisk.kt @@ -55,25 +55,25 @@ object MediaSaverToDisk { onSuccess: () -> Any?, onError: (Throwable) -> Any?, ) { - videoUri?.let { theVideoUri -> - if (!theVideoUri.startsWith("file")) { - downloadAndSave( - url = theVideoUri, - mimeType = mimeType, - context = localContext, - forceProxy = forceProxy, - onSuccess = onSuccess, - onError = onError, - ) - } else { + when { + videoUri.isNullOrBlank() -> return + videoUri.startsWith("file") -> save( - localFile = theVideoUri.toUri().toFile(), + localFile = videoUri.toUri().toFile(), mimeType = mimeType, context = localContext, onSuccess = onSuccess, onError = onError, ) - } + else -> + downloadAndSave( + url = videoUri, + mimeType = mimeType, + forceProxy = forceProxy, + context = localContext, + onSuccess = onSuccess, + onError = onError, + ) } }