From bcd384c31c5cb6250ed13c0ff281a2c741203629 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 10 Nov 2020 14:46:19 +0100 Subject: [PATCH] Small cleanup --- .../vector/app/features/media/BaseAttachmentProvider.kt | 5 ++++- .../app/features/media/DataAttachmentRoomProvider.kt | 1 - .../app/features/media/RoomEventsAttachmentProvider.kt | 9 ++++----- .../app/features/media/VectorAttachmentViewerActivity.kt | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/media/BaseAttachmentProvider.kt b/vector/src/main/java/im/vector/app/features/media/BaseAttachmentProvider.kt index 3846e56ecf..f99ed2e324 100644 --- a/vector/src/main/java/im/vector/app/features/media/BaseAttachmentProvider.kt +++ b/vector/src/main/java/im/vector/app/features/media/BaseAttachmentProvider.kt @@ -30,7 +30,10 @@ import org.matrix.android.sdk.api.MatrixCallback import org.matrix.android.sdk.api.session.file.FileService import java.io.File -abstract class BaseAttachmentProvider(val imageContentRenderer: ImageContentRenderer, val fileService: FileService) : AttachmentSourceProvider { +abstract class BaseAttachmentProvider( + private val imageContentRenderer: ImageContentRenderer, + protected val fileService: FileService +) : AttachmentSourceProvider { interface InteractionListener { fun onDismissTapped() diff --git a/vector/src/main/java/im/vector/app/features/media/DataAttachmentRoomProvider.kt b/vector/src/main/java/im/vector/app/features/media/DataAttachmentRoomProvider.kt index 085153a721..70305f2fd8 100644 --- a/vector/src/main/java/im/vector/app/features/media/DataAttachmentRoomProvider.kt +++ b/vector/src/main/java/im/vector/app/features/media/DataAttachmentRoomProvider.kt @@ -31,7 +31,6 @@ import java.io.File class DataAttachmentRoomProvider( private val attachments: List, private val room: Room?, - private val initialIndex: Int, imageContentRenderer: ImageContentRenderer, private val dateFormatter: VectorDateFormatter, fileService: FileService) : BaseAttachmentProvider(imageContentRenderer, fileService) { diff --git a/vector/src/main/java/im/vector/app/features/media/RoomEventsAttachmentProvider.kt b/vector/src/main/java/im/vector/app/features/media/RoomEventsAttachmentProvider.kt index 5c0c33d078..574751ec36 100644 --- a/vector/src/main/java/im/vector/app/features/media/RoomEventsAttachmentProvider.kt +++ b/vector/src/main/java/im/vector/app/features/media/RoomEventsAttachmentProvider.kt @@ -40,7 +40,6 @@ import javax.inject.Inject class RoomEventsAttachmentProvider( private val attachments: List, - private val initialIndex: Int, imageContentRenderer: ImageContentRenderer, private val dateFormatter: VectorDateFormatter, fileService: FileService @@ -167,11 +166,11 @@ class AttachmentProviderFactory @Inject constructor( private val session: Session ) { - fun createProvider(attachments: List, initialIndex: Int): RoomEventsAttachmentProvider { - return RoomEventsAttachmentProvider(attachments, initialIndex, imageContentRenderer, vectorDateFormatter, session.fileService()) + fun createProvider(attachments: List): RoomEventsAttachmentProvider { + return RoomEventsAttachmentProvider(attachments, imageContentRenderer, vectorDateFormatter, session.fileService()) } - fun createProvider(attachments: List, room: Room?, initialIndex: Int): DataAttachmentRoomProvider { - return DataAttachmentRoomProvider(attachments, room, initialIndex, imageContentRenderer, vectorDateFormatter, session.fileService()) + fun createProvider(attachments: List, room: Room?): DataAttachmentRoomProvider { + return DataAttachmentRoomProvider(attachments, room, imageContentRenderer, vectorDateFormatter, session.fileService()) } } diff --git a/vector/src/main/java/im/vector/app/features/media/VectorAttachmentViewerActivity.kt b/vector/src/main/java/im/vector/app/features/media/VectorAttachmentViewerActivity.kt index 9302be502d..92b0e0c14c 100644 --- a/vector/src/main/java/im/vector/app/features/media/VectorAttachmentViewerActivity.kt +++ b/vector/src/main/java/im/vector/app/features/media/VectorAttachmentViewerActivity.kt @@ -118,7 +118,7 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), BaseAttachmen val inMemoryData = intent.getParcelableArrayListExtra(EXTRA_IN_MEMORY_DATA) if (inMemoryData != null) { - val sourceProvider = dataSourceFactory.createProvider(inMemoryData, room, initialIndex) + val sourceProvider = dataSourceFactory.createProvider(inMemoryData, room) val index = inMemoryData.indexOfFirst { it.eventId == args.eventId } initialIndex = index sourceProvider.interactionListener = this @@ -137,7 +137,7 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), BaseAttachmen val index = events.indexOfFirst { it.eventId == args.eventId } initialIndex = index - val sourceProvider = dataSourceFactory.createProvider(events, index) + val sourceProvider = dataSourceFactory.createProvider(events) sourceProvider.interactionListener = this setSourceProvider(sourceProvider) this.currentSourceProvider = sourceProvider