Removing base use case interface

This commit is contained in:
Maxime Naturel 2022-02-25 14:11:26 +01:00
parent 6230dfc641
commit cb27608c75
2 changed files with 3 additions and 29 deletions

View file

@ -1,21 +0,0 @@
/*
* Copyright (c) 2022 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.core.usecase
interface VectorBaseInOutUseCase<T, R> {
suspend fun execute(input: T): Result<R>
}

View file

@ -20,7 +20,6 @@ import android.content.Context
import androidx.core.net.toUri
import dagger.hilt.android.qualifiers.ApplicationContext
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.withContext
@ -32,14 +31,10 @@ class DownloadMediaUseCase @Inject constructor(
@ApplicationContext private val appContext: Context,
private val coroutineDispatchers: MatrixCoroutineDispatchers,
private val notificationUtils: NotificationUtils
) : VectorBaseInOutUseCase<File, Unit> {
) {
// TODO
// what about UseCase Interface enforcing single type input? => no interface
// add unit tests
// PR to template structure of a class for discussion
override suspend fun execute(input: File): Result<Unit> = withContext(coroutineDispatchers.io) {
// TODO add unit tests: https://github.com/vector-im/element-android/tree/develop/vector/src/test/java/im/vector/app/test
suspend fun execute(input: File): Result<Unit> = withContext(coroutineDispatchers.io) {
runCatching {
saveMedia(
context = appContext,