This commit is contained in:
Benoit Marty 2020-10-01 15:05:42 +02:00
parent 6e81467808
commit ae346646e4
1 changed files with 5 additions and 7 deletions

View File

@ -23,23 +23,21 @@ import com.airbnb.mvrx.args
import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState import com.airbnb.mvrx.withState
import com.google.android.material.tabs.TabLayoutMediator import com.google.android.material.tabs.TabLayoutMediator
import org.matrix.android.sdk.api.util.toMatrixItem
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.extensions.exhaustive import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.intent.getMimeTypeFromUri import im.vector.app.core.intent.getMimeTypeFromUri
import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.utils.saveMedia import im.vector.app.core.utils.saveMedia
import im.vector.app.core.utils.shareMedia import im.vector.app.core.utils.shareMedia
import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.notifications.NotificationUtils
import im.vector.app.features.roomprofile.RoomProfileArgs import im.vector.app.features.roomprofile.RoomProfileArgs
import kotlinx.android.synthetic.main.fragment_room_uploads.* import kotlinx.android.synthetic.main.fragment_room_uploads.*
import org.matrix.android.sdk.api.util.toMatrixItem
import javax.inject.Inject import javax.inject.Inject
class RoomUploadsFragment @Inject constructor( class RoomUploadsFragment @Inject constructor(
private val viewModelFactory: RoomUploadsViewModel.Factory, private val viewModelFactory: RoomUploadsViewModel.Factory,
private val stringProvider: StringProvider,
private val avatarRenderer: AvatarRenderer, private val avatarRenderer: AvatarRenderer,
private val notificationUtils: NotificationUtils private val notificationUtils: NotificationUtils
) : VectorBaseFragment(), RoomUploadsViewModel.Factory by viewModelFactory { ) : VectorBaseFragment(), RoomUploadsViewModel.Factory by viewModelFactory {
@ -58,8 +56,8 @@ class RoomUploadsFragment @Inject constructor(
TabLayoutMediator(roomUploadsTabs, roomUploadsViewPager) { tab, position -> TabLayoutMediator(roomUploadsTabs, roomUploadsViewPager) { tab, position ->
when (position) { when (position) {
0 -> tab.text = stringProvider.getString(R.string.uploads_media_title) 0 -> tab.text = getString(R.string.uploads_media_title)
1 -> tab.text = stringProvider.getString(R.string.uploads_files_title) 1 -> tab.text = getString(R.string.uploads_files_title)
} }
}.attach() }.attach()
@ -70,7 +68,7 @@ class RoomUploadsFragment @Inject constructor(
is RoomUploadsViewEvents.FileReadyForSharing -> { is RoomUploadsViewEvents.FileReadyForSharing -> {
shareMedia(requireContext(), it.file, getMimeTypeFromUri(requireContext(), it.file.toUri())) shareMedia(requireContext(), it.file, getMimeTypeFromUri(requireContext(), it.file.toUri()))
} }
is RoomUploadsViewEvents.FileReadyForSaving -> { is RoomUploadsViewEvents.FileReadyForSaving -> {
saveMedia( saveMedia(
context = requireContext(), context = requireContext(),
file = it.file, file = it.file,
@ -79,7 +77,7 @@ class RoomUploadsFragment @Inject constructor(
notificationUtils = notificationUtils notificationUtils = notificationUtils
) )
} }
is RoomUploadsViewEvents.Failure -> showFailure(it.throwable) is RoomUploadsViewEvents.Failure -> showFailure(it.throwable)
}.exhaustive }.exhaustive
} }
} }