Skip to content

Commit

Permalink
fix: currentStatus always READY (#135)
Browse files Browse the repository at this point in the history
* Fix currentStatus

* cleanup builder ctor

* More cleanup

* Update gradle plugin
  • Loading branch information
daytime-em committed Jun 13, 2024
1 parent 715c5aa commit 3931edd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ buildscript {
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.1.2' apply false
id 'com.android.library' version '8.1.2' apply false
id 'com.android.application' version '8.4.0' apply false
id 'com.android.library' version '8.4.0' apply false
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
id 'com.mux.gradle.android.mux-android-distribution' version '1.1.2' apply false
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Jan 19 16:04:49 PST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
15 changes: 4 additions & 11 deletions library/src/main/java/com/mux/video/upload/api/MuxUpload.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import java.io.File
class MuxUpload private constructor(
private var uploadInfo: UploadInfo,
private val autoManage: Boolean = true,
initialStatus: UploadStatus = UploadStatus.Ready
) {

/**
Expand All @@ -60,7 +59,7 @@ class MuxUpload private constructor(
* To be notified of status updates (including upload progress), use [setStatusListener]
*/
@Suppress("MemberVisibilityCanBePrivate")
val uploadStatus: UploadStatus
val uploadStatus: UploadStatus get() = uploadInfo.statusFlow?.value ?: currentStatus

/**
* True when the upload is running, false if it's paused, failed, or canceled
Expand Down Expand Up @@ -307,10 +306,6 @@ class MuxUpload private constructor(
observerJob = newObserveProgressJob(uploadInfo)
}

init {
uploadStatus = initialStatus
}

/**
* The current progress of an upload, in terms of time elapsed and data transmitted
*/
Expand Down Expand Up @@ -345,7 +340,7 @@ class MuxUpload private constructor(
* @param videoFile a File that represents the video file you want to upload
*/
@Suppress("MemberVisibilityCanBePrivate")
class Builder constructor(val uploadUri: Uri, val videoFile: File) {
class Builder(val uploadUri: Uri, val videoFile: File) {

/**
* Create a new Builder with the specified input file and upload URL
Expand All @@ -354,8 +349,7 @@ class MuxUpload private constructor(
* @param videoFile a File that represents the video file you want to upload
*/
@Suppress("unused")
constructor(uploadUri: String, videoFile: File)
: this(Uri.parse(uploadUri), videoFile)
constructor(uploadUri: String, videoFile: File): this(Uri.parse(uploadUri), videoFile)

private var manageTask: Boolean = true
private var uploadInfo: UploadInfo = UploadInfo(
Expand Down Expand Up @@ -446,7 +440,6 @@ class MuxUpload private constructor(
* [MuxUploadManager]
*/
@JvmSynthetic
internal fun create(uploadInfo: UploadInfo, initialStatus: UploadStatus = UploadStatus.Ready)
= MuxUpload(uploadInfo = uploadInfo, initialStatus = initialStatus)
internal fun create(uploadInfo: UploadInfo) = MuxUpload(uploadInfo = uploadInfo)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package com.mux.video.upload.api
*
* Kotlin callers can use the [Result] API as normal
*/
@Suppress("unused")
class UploadResult {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ sealed class UploadStatus {
/**
* This upload hos not been started. It is ready to start by calling [MuxUpload.start]
*/
object Ready: UploadStatus()
data object Ready: UploadStatus()

/**
* This upload has been started via [MuxUpload.start] but has not yet started processing anything
*/
object Started: UploadStatus()
data object Started: UploadStatus()

/**
* This upload is being prepared. If standardization is required, it is done during this step
*
* @see MuxUpload.Builder.standardizationRequested
*/
object Preparing: UploadStatus()
data object Preparing: UploadStatus()

/**
* The upload is currently being sent to Mux Video. The progress is available
Expand Down

0 comments on commit 3931edd

Please sign in to comment.