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

View file

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

View file

@ -35,10 +35,6 @@ class VectorAttachmentViewerViewModel @AssistedInject constructor(
private val downloadMediaUseCase: DownloadMediaUseCase
) : VectorViewModel<VectorDummyViewState, VectorAttachmentViewerAction, VectorAttachmentViewerViewEvents>(initialState) {
/* ==========================================================================================
* Factory
* ========================================================================================== */
@AssistedFactory
interface Factory : MavericksAssistedViewModelFactory<VectorAttachmentViewerViewModel, VectorDummyViewState> {
override fun create(initialState: VectorDummyViewState): VectorAttachmentViewerViewModel
@ -46,26 +42,14 @@ class VectorAttachmentViewerViewModel @AssistedInject constructor(
companion object : MavericksViewModelFactory<VectorAttachmentViewerViewModel, VectorDummyViewState> by hiltMavericksViewModelFactory()
/* ==========================================================================================
* Public Api
* ========================================================================================== */
var pendingAction: VectorAttachmentViewerAction? = null
/* ==========================================================================================
* Specialization
* ========================================================================================== */
override fun handle(action: VectorAttachmentViewerAction) {
when (action) {
is VectorAttachmentViewerAction.DownloadMedia -> handleDownloadAction(action)
}
}
/* ==========================================================================================
* Private methods
* ========================================================================================== */
private fun handleDownloadAction(action: VectorAttachmentViewerAction.DownloadMedia) {
// launch in the coroutine scope session to avoid binding the coroutine to the lifecycle of the VM
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.utils.saveMedia
import im.vector.app.features.notifications.NotificationUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import java.io.File
import javax.inject.Inject
class DownloadMediaUseCase @Inject constructor(
@ApplicationContext private val appContext: Context,
private val coroutineDispatchers: MatrixCoroutineDispatchers,
private val notificationUtils: NotificationUtils
) : VectorBaseInOutUseCase<File, Unit> {
/* ==========================================================================================
* Public API
* ========================================================================================== */
// TODO
// 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(Dispatchers.IO) {
override suspend fun execute(input: File): Result<Unit> = withContext(coroutineDispatchers.io) {
runCatching {
saveMedia(
context = appContext,