Removing section bloc comments

This commit is contained in:
Maxime Naturel 2022-02-25 12:01:06 +01:00
parent 4e4702cad8
commit 6230dfc641
4 changed files with 7 additions and 70 deletions

View File

@ -30,20 +30,12 @@ class AttachmentOverlayView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr), AttachmentEventListener { ) : ConstraintLayout(context, attrs, defStyleAttr), AttachmentEventListener {
/* ==========================================================================================
* Fields
* ========================================================================================== */
var interactionListener: AttachmentInteractionListener? = null var interactionListener: AttachmentInteractionListener? = null
val views: MergeImageAttachmentOverlayBinding val views: MergeImageAttachmentOverlayBinding
private var isPlaying = false private var isPlaying = false
private var suspendSeekBarUpdate = false private var suspendSeekBarUpdate = false
/* ==========================================================================================
* Init
* ========================================================================================== */
init { init {
inflate(context, R.layout.merge_image_attachment_overlay, this) inflate(context, R.layout.merge_image_attachment_overlay, this)
views = MergeImageAttachmentOverlayBinding.bind(this) views = MergeImageAttachmentOverlayBinding.bind(this)
@ -78,19 +70,11 @@ class AttachmentOverlayView @JvmOverloads constructor(
}) })
} }
/* ==========================================================================================
* Public API
* ========================================================================================== */
fun updateWith(counter: String, senderInfo: String) { fun updateWith(counter: String, senderInfo: String) {
views.overlayCounterText.text = counter views.overlayCounterText.text = counter
views.overlayInfoText.text = senderInfo views.overlayInfoText.text = senderInfo
} }
/* ==========================================================================================
* Specialization
* ========================================================================================== */
override fun onEvent(event: AttachmentEvents) { override fun onEvent(event: AttachmentEvents) {
when (event) { when (event) {
is AttachmentEvents.VideoEvent -> { is AttachmentEvents.VideoEvent -> {

View File

@ -59,10 +59,6 @@ import javax.inject.Inject
@AndroidEntryPoint @AndroidEntryPoint
class VectorAttachmentViewerActivity : AttachmentViewerActivity(), AttachmentInteractionListener { class VectorAttachmentViewerActivity : AttachmentViewerActivity(), AttachmentInteractionListener {
/* ==========================================================================================
* Arguments
* ========================================================================================== */
@Parcelize @Parcelize
data class Args( data class Args(
val roomId: String?, val roomId: String?,
@ -70,10 +66,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), AttachmentInt
val sharedTransitionName: String? val sharedTransitionName: String?
) : Parcelable ) : Parcelable
/* ==========================================================================================
* Dependencies
* ========================================================================================== */
@Inject @Inject
lateinit var sessionHolder: ActiveSessionHolder lateinit var sessionHolder: ActiveSessionHolder
@ -83,10 +75,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), AttachmentInt
@Inject @Inject
lateinit var imageContentRenderer: ImageContentRenderer lateinit var imageContentRenderer: ImageContentRenderer
/* ==========================================================================================
* Fields
* ========================================================================================== */
private val viewModel: VectorAttachmentViewerViewModel by viewModel() private val viewModel: VectorAttachmentViewerViewModel by viewModel()
private val errorFormatter by lazy(LazyThreadSafetyMode.NONE) { singletonEntryPoint().errorFormatter() } private val errorFormatter by lazy(LazyThreadSafetyMode.NONE) { singletonEntryPoint().errorFormatter() }
private var initialIndex = 0 private var initialIndex = 0
@ -103,10 +91,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), AttachmentInt
viewModel.pendingAction = null viewModel.pendingAction = null
} }
/* ==========================================================================================
* Lifecycle
* ========================================================================================== */
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
Timber.i("onCreate Activity ${javaClass.simpleName}") Timber.i("onCreate Activity ${javaClass.simpleName}")
@ -191,10 +175,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), AttachmentInt
super.onBackPressed() super.onBackPressed()
} }
/* ==========================================================================================
* Specialization
* ========================================================================================== */
override fun shouldAnimateDismiss(): Boolean { override fun shouldAnimateDismiss(): Boolean {
return currentPosition != initialIndex return currentPosition != initialIndex
} }
@ -209,10 +189,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), AttachmentInt
ActivityCompat.finishAfterTransition(this) ActivityCompat.finishAfterTransition(this)
} }
/* ==========================================================================================
* Private methods
* ========================================================================================== */
private fun getOtherThemes() = ActivityOtherThemes.VectorAttachmentsPreview private fun getOtherThemes() = ActivityOtherThemes.VectorAttachmentsPreview
/** /**
@ -284,10 +260,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), AttachmentInt
Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q || Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q ||
checkPermissions(PERMISSIONS_FOR_WRITING_FILES, this, downloadActionResultLauncher) checkPermissions(PERMISSIONS_FOR_WRITING_FILES, this, downloadActionResultLauncher)
/* ==========================================================================================
* Specialization AttachmentInteractionListener
* ========================================================================================== */
override fun onDismiss() { override fun onDismiss() {
animateClose() animateClose()
} }
@ -329,10 +301,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), AttachmentInt
} }
} }
/* ==========================================================================================
* COMPANION
* ========================================================================================== */
companion object { companion object {
private const val EXTRA_ARGS = "EXTRA_ARGS" private const val EXTRA_ARGS = "EXTRA_ARGS"
private const val EXTRA_IMAGE_DATA = "EXTRA_IMAGE_DATA" private const val EXTRA_IMAGE_DATA = "EXTRA_IMAGE_DATA"

View File

@ -35,10 +35,6 @@ class VectorAttachmentViewerViewModel @AssistedInject constructor(
private val downloadMediaUseCase: DownloadMediaUseCase private val downloadMediaUseCase: DownloadMediaUseCase
) : VectorViewModel<VectorDummyViewState, VectorAttachmentViewerAction, VectorAttachmentViewerViewEvents>(initialState) { ) : VectorViewModel<VectorDummyViewState, VectorAttachmentViewerAction, VectorAttachmentViewerViewEvents>(initialState) {
/* ==========================================================================================
* Factory
* ========================================================================================== */
@AssistedFactory @AssistedFactory
interface Factory : MavericksAssistedViewModelFactory<VectorAttachmentViewerViewModel, VectorDummyViewState> { interface Factory : MavericksAssistedViewModelFactory<VectorAttachmentViewerViewModel, VectorDummyViewState> {
override fun create(initialState: VectorDummyViewState): VectorAttachmentViewerViewModel override fun create(initialState: VectorDummyViewState): VectorAttachmentViewerViewModel
@ -46,26 +42,14 @@ class VectorAttachmentViewerViewModel @AssistedInject constructor(
companion object : MavericksViewModelFactory<VectorAttachmentViewerViewModel, VectorDummyViewState> by hiltMavericksViewModelFactory() companion object : MavericksViewModelFactory<VectorAttachmentViewerViewModel, VectorDummyViewState> by hiltMavericksViewModelFactory()
/* ==========================================================================================
* Public Api
* ========================================================================================== */
var pendingAction: VectorAttachmentViewerAction? = null var pendingAction: VectorAttachmentViewerAction? = null
/* ==========================================================================================
* Specialization
* ========================================================================================== */
override fun handle(action: VectorAttachmentViewerAction) { override fun handle(action: VectorAttachmentViewerAction) {
when (action) { when (action) {
is VectorAttachmentViewerAction.DownloadMedia -> handleDownloadAction(action) is VectorAttachmentViewerAction.DownloadMedia -> handleDownloadAction(action)
} }
} }
/* ==========================================================================================
* Private methods
* ========================================================================================== */
private fun handleDownloadAction(action: VectorAttachmentViewerAction.DownloadMedia) { private fun handleDownloadAction(action: VectorAttachmentViewerAction.DownloadMedia) {
// launch in the coroutine scope session to avoid binding the coroutine to the lifecycle of the VM // launch in the coroutine scope session to avoid binding the coroutine to the lifecycle of the VM
session.coroutineScope.launch { session.coroutineScope.launch {

View File

@ -23,22 +23,23 @@ import im.vector.app.core.intent.getMimeTypeFromUri
import im.vector.app.core.usecase.VectorBaseInOutUseCase import im.vector.app.core.usecase.VectorBaseInOutUseCase
import im.vector.app.core.utils.saveMedia import im.vector.app.core.utils.saveMedia
import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.notifications.NotificationUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import java.io.File import java.io.File
import javax.inject.Inject import javax.inject.Inject
class DownloadMediaUseCase @Inject constructor( class DownloadMediaUseCase @Inject constructor(
@ApplicationContext private val appContext: Context, @ApplicationContext private val appContext: Context,
private val coroutineDispatchers: MatrixCoroutineDispatchers,
private val notificationUtils: NotificationUtils private val notificationUtils: NotificationUtils
) : VectorBaseInOutUseCase<File, Unit> { ) : VectorBaseInOutUseCase<File, Unit> {
/* ========================================================================================== // TODO
* Public API // what about UseCase Interface enforcing single type input? => no interface
* ========================================================================================== */ // add unit tests
// PR to template structure of a class for discussion
// TODO declare Dispatcher via an Interface provider to be able to unit tests override suspend fun execute(input: File): Result<Unit> = withContext(coroutineDispatchers.io) {
override suspend fun execute(input: File): Result<Unit> = withContext(Dispatchers.IO) {
runCatching { runCatching {
saveMedia( saveMedia(
context = appContext, context = appContext,