Extract AttachmentProviderFactory to its own file
This commit is contained in:
parent
510f8ae0f5
commit
bfcd4b8250
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2020 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.media
|
||||
|
||||
import im.vector.app.core.date.VectorDateFormatter
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.room.Room
|
||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
import javax.inject.Inject
|
||||
|
||||
class AttachmentProviderFactory @Inject constructor(
|
||||
private val imageContentRenderer: ImageContentRenderer,
|
||||
private val vectorDateFormatter: VectorDateFormatter,
|
||||
private val stringProvider: StringProvider,
|
||||
private val session: Session
|
||||
) {
|
||||
|
||||
fun createProvider(attachments: List<TimelineEvent>): RoomEventsAttachmentProvider {
|
||||
return RoomEventsAttachmentProvider(
|
||||
attachments,
|
||||
imageContentRenderer,
|
||||
vectorDateFormatter,
|
||||
session.fileService(),
|
||||
stringProvider
|
||||
)
|
||||
}
|
||||
|
||||
fun createProvider(attachments: List<AttachmentData>, room: Room?): DataAttachmentRoomProvider {
|
||||
return DataAttachmentRoomProvider(
|
||||
attachments,
|
||||
room,
|
||||
imageContentRenderer,
|
||||
vectorDateFormatter,
|
||||
session.fileService(),
|
||||
stringProvider
|
||||
)
|
||||
}
|
||||
}
|
@ -20,10 +20,8 @@ import im.vector.app.core.date.VectorDateFormatter
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.lib.attachmentviewer.AttachmentInfo
|
||||
import org.matrix.android.sdk.api.MatrixCallback
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.file.FileService
|
||||
import org.matrix.android.sdk.api.session.room.Room
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageImageContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageVideoContent
|
||||
@ -32,7 +30,6 @@ import org.matrix.android.sdk.api.session.room.model.message.getFileUrl
|
||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
class RoomEventsAttachmentProvider(
|
||||
private val attachments: List<TimelineEvent>,
|
||||
@ -152,31 +149,3 @@ class RoomEventsAttachmentProvider(
|
||||
}
|
||||
}
|
||||
|
||||
class AttachmentProviderFactory @Inject constructor(
|
||||
private val imageContentRenderer: ImageContentRenderer,
|
||||
private val vectorDateFormatter: VectorDateFormatter,
|
||||
private val stringProvider: StringProvider,
|
||||
private val session: Session
|
||||
) {
|
||||
|
||||
fun createProvider(attachments: List<TimelineEvent>): RoomEventsAttachmentProvider {
|
||||
return RoomEventsAttachmentProvider(
|
||||
attachments,
|
||||
imageContentRenderer,
|
||||
vectorDateFormatter,
|
||||
session.fileService(),
|
||||
stringProvider
|
||||
)
|
||||
}
|
||||
|
||||
fun createProvider(attachments: List<AttachmentData>, room: Room?): DataAttachmentRoomProvider {
|
||||
return DataAttachmentRoomProvider(
|
||||
attachments,
|
||||
room,
|
||||
imageContentRenderer,
|
||||
vectorDateFormatter,
|
||||
session.fileService(),
|
||||
stringProvider
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user