-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## New * feat: Add `UploadResult` class for java users to interpret Result (#73) ## Fixes * Fix: Some methods on MuxUpload.Builder don't return Builder (#74) * Fix: the application context shouldn't be visible (#76) * Fix: Transcoding errors handled incorrectly (#79) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Emily Dixon <edixon@mux.com> Co-authored-by: Tomislav Kordic <32546640+tomkordic@users.noreply.github.com> Co-authored-by: GitHub <noreply@github.com>
- Loading branch information
1 parent
6510676
commit 9bd7e8a
Showing
6 changed files
with
142 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
library/src/main/java/com/mux/video/upload/api/UploadResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.mux.video.upload.api | ||
|
||
/** | ||
* Helper class for parsing [Result] objects from [MuxUpload] in Java. | ||
* | ||
* Kotlin callers can use the [Result] API as normal | ||
*/ | ||
class UploadResult { | ||
|
||
companion object { | ||
/** | ||
* Returns true of the upload was successful, | ||
* Returns false if the upload wasn't successful, or if the passed object wasn't a [Result] | ||
*/ | ||
@Suppress("unused") | ||
@JvmStatic | ||
fun isSuccessful(result: Result<MuxUpload.Progress>): Boolean { | ||
@Suppress("USELESS_IS_CHECK") // java interprets inline classes like Result as Object | ||
return if (result is Result) { | ||
result.isSuccess | ||
} else { | ||
false | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Returns the final Progress update from [MuxUpload]'s [Result] if if was successful | ||
* Returns `null` if the upload was not successful, or if the passed object wasn't a result | ||
*/ | ||
@Suppress("unused") | ||
@JvmStatic | ||
fun getFinalProgress(result: Result<MuxUpload.Progress>): MuxUpload.Progress? { | ||
@Suppress("USELESS_IS_CHECK") // java interprets inline classes like Result as Object | ||
return if (result is Result) { | ||
result.getOrNull() | ||
} else { | ||
null | ||
} | ||
} | ||
|
||
/** | ||
* If the Result was not successful, returns the Exception that caused the failure | ||
*/ | ||
@Suppress("unused") | ||
@JvmStatic | ||
fun getError(result: Result<MuxUpload.Progress>): Throwable? { | ||
@Suppress("USELESS_IS_CHECK") // java interprets inline classes like Result as Object | ||
return if (result is Result) { | ||
result.exceptionOrNull() | ||
} else { | ||
null | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters