Content: hide some internal methods

This commit is contained in:
ganfra 2019-06-12 10:54:26 +02:00
parent 481a25d4df
commit 0204bade8b
4 changed files with 11 additions and 18 deletions

View File

@ -22,12 +22,6 @@ interface ContentUploadStateTracker {
fun untrack(key: String, updateListener: UpdateListener) fun untrack(key: String, updateListener: UpdateListener)
fun setFailure(key: String)
fun setSuccess(key: String)
fun setProgress(key: String, current: Long, total: Long)
interface UpdateListener { interface UpdateListener {
fun onUpdate(state: State) fun onUpdate(state: State)
} }

View File

@ -27,7 +27,11 @@ internal class ContentModule {
val definition = module(override = true) { val definition = module(override = true) {
scope(DefaultSession.SCOPE) { scope(DefaultSession.SCOPE) {
DefaultContentUploadStateTracker() as ContentUploadStateTracker DefaultContentUploadStateTracker()
}
scope(DefaultSession.SCOPE) {
get<DefaultContentUploadStateTracker>() as ContentUploadStateTracker
} }
scope(DefaultSession.SCOPE) { scope(DefaultSession.SCOPE) {

View File

@ -40,17 +40,17 @@ internal class DefaultContentUploadStateTracker : ContentUploadStateTracker {
} }
} }
override fun setFailure(key: String) { internal fun setFailure(key: String) {
val failure = ContentUploadStateTracker.State.Failure val failure = ContentUploadStateTracker.State.Failure
updateState(key, failure) updateState(key, failure)
} }
override fun setSuccess(key: String) { internal fun setSuccess(key: String) {
val success = ContentUploadStateTracker.State.Success val success = ContentUploadStateTracker.State.Success
updateState(key, 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) val progressData = ContentUploadStateTracker.State.ProgressData(current, total)
updateState(key, progressData) updateState(key, progressData)
} }

View File

@ -21,15 +21,10 @@ import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import com.squareup.moshi.JsonClass import com.squareup.moshi.JsonClass
import im.vector.matrix.android.api.session.content.ContentAttachmentData 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.Event
import im.vector.matrix.android.api.session.events.model.toContent 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.events.model.toModel
import im.vector.matrix.android.api.session.room.model.message.MessageAudioContent import im.vector.matrix.android.api.session.room.model.message.*
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.internal.di.MatrixKoinComponent import im.vector.matrix.android.internal.di.MatrixKoinComponent
import im.vector.matrix.android.internal.network.ProgressRequestBody import im.vector.matrix.android.internal.network.ProgressRequestBody
import im.vector.matrix.android.internal.session.room.send.SendEventWorker 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 { : CoroutineWorker(context, params), MatrixKoinComponent {
private val fileUploader by inject<FileUploader>() private val fileUploader by inject<FileUploader>()
private val contentUploadProgressTracker by inject<ContentUploadStateTracker>() private val contentUploadProgressTracker by inject<DefaultContentUploadStateTracker>()
@JsonClass(generateAdapter = true) @JsonClass(generateAdapter = true)
internal data class Params( internal data class Params(
@ -54,7 +49,7 @@ internal class UploadContentWorker(context: Context, params: WorkerParameters)
override suspend fun doWork(): Result { override suspend fun doWork(): Result {
val params = WorkerParamsFactory.fromData<Params>(inputData) val params = WorkerParamsFactory.fromData<Params>(inputData)
?: return Result.failure() ?: return Result.failure()
val eventId = params.event.eventId ?: return Result.failure() val eventId = params.event.eventId ?: return Result.failure()
val attachment = params.attachment val attachment = params.attachment