From 0204bade8b090e7b7554e33270591b468ac64e13 Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 12 Jun 2019 10:54:26 +0200 Subject: [PATCH] Content: hide some internal methods --- .../api/session/content/ContentUploadStateTracker.kt | 6 ------ .../android/internal/session/content/ContentModule.kt | 6 +++++- .../content/DefaultContentUploadStateTracker.kt | 6 +++--- .../internal/session/content/UploadContentWorker.kt | 11 +++-------- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/content/ContentUploadStateTracker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/content/ContentUploadStateTracker.kt index a08060e6..9211371d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/content/ContentUploadStateTracker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/content/ContentUploadStateTracker.kt @@ -22,12 +22,6 @@ interface ContentUploadStateTracker { fun untrack(key: String, updateListener: UpdateListener) - fun setFailure(key: String) - - fun setSuccess(key: String) - - fun setProgress(key: String, current: Long, total: Long) - interface UpdateListener { fun onUpdate(state: State) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/ContentModule.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/ContentModule.kt index 67ff2d7b..7fb9b757 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/ContentModule.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/ContentModule.kt @@ -27,7 +27,11 @@ internal class ContentModule { val definition = module(override = true) { scope(DefaultSession.SCOPE) { - DefaultContentUploadStateTracker() as ContentUploadStateTracker + DefaultContentUploadStateTracker() + } + + scope(DefaultSession.SCOPE) { + get() as ContentUploadStateTracker } scope(DefaultSession.SCOPE) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/DefaultContentUploadStateTracker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/DefaultContentUploadStateTracker.kt index 66bd5a82..a5dd16fb 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/DefaultContentUploadStateTracker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/DefaultContentUploadStateTracker.kt @@ -40,17 +40,17 @@ internal class DefaultContentUploadStateTracker : ContentUploadStateTracker { } } - override fun setFailure(key: String) { + internal fun setFailure(key: String) { val failure = ContentUploadStateTracker.State.Failure updateState(key, failure) } - override fun setSuccess(key: String) { + internal fun setSuccess(key: String) { val success = ContentUploadStateTracker.State.Success updateState(key, success) } - override fun setProgress(key: String, current: Long, total: Long) { + internal fun setProgress(key: String, current: Long, total: Long) { val progressData = ContentUploadStateTracker.State.ProgressData(current, total) updateState(key, progressData) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt index 4eeb124d..0182eb6c 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt @@ -21,15 +21,10 @@ import androidx.work.CoroutineWorker import androidx.work.WorkerParameters import com.squareup.moshi.JsonClass import im.vector.matrix.android.api.session.content.ContentAttachmentData -import im.vector.matrix.android.api.session.content.ContentUploadStateTracker import im.vector.matrix.android.api.session.events.model.Event import im.vector.matrix.android.api.session.events.model.toContent import im.vector.matrix.android.api.session.events.model.toModel -import im.vector.matrix.android.api.session.room.model.message.MessageAudioContent -import im.vector.matrix.android.api.session.room.model.message.MessageContent -import im.vector.matrix.android.api.session.room.model.message.MessageFileContent -import im.vector.matrix.android.api.session.room.model.message.MessageImageContent -import im.vector.matrix.android.api.session.room.model.message.MessageVideoContent +import im.vector.matrix.android.api.session.room.model.message.* import im.vector.matrix.android.internal.di.MatrixKoinComponent import im.vector.matrix.android.internal.network.ProgressRequestBody import im.vector.matrix.android.internal.session.room.send.SendEventWorker @@ -43,7 +38,7 @@ internal class UploadContentWorker(context: Context, params: WorkerParameters) : CoroutineWorker(context, params), MatrixKoinComponent { private val fileUploader by inject() - private val contentUploadProgressTracker by inject() + private val contentUploadProgressTracker by inject() @JsonClass(generateAdapter = true) internal data class Params( @@ -54,7 +49,7 @@ internal class UploadContentWorker(context: Context, params: WorkerParameters) override suspend fun doWork(): Result { val params = WorkerParamsFactory.fromData(inputData) - ?: return Result.failure() + ?: return Result.failure() val eventId = params.event.eventId ?: return Result.failure() val attachment = params.attachment