Moving base use case interface into core package

This commit is contained in:
Maxime Naturel 2022-02-24 15:47:57 +01:00
parent cdb1a96664
commit 4c09fb747b
2 changed files with 5 additions and 5 deletions

View File

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
package im.vector.app.features.media.domain.usecase package im.vector.app.core.usecase
// TODO move into Core packages interface VectorBaseInOutUseCase<T, R> {
interface VectorInOutUseCase<T, R> {
suspend fun execute(input: T): Result<R> suspend fun execute(input: T): Result<R>
} }

View File

@ -20,6 +20,7 @@ import android.content.Context
import androidx.core.net.toUri import androidx.core.net.toUri
import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.android.qualifiers.ApplicationContext
import im.vector.app.core.intent.getMimeTypeFromUri 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.core.utils.saveMedia
import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.notifications.NotificationUtils
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -30,13 +31,13 @@ import javax.inject.Inject
class DownloadMediaUseCase @Inject constructor( class DownloadMediaUseCase @Inject constructor(
@ApplicationContext private val appContext: Context, @ApplicationContext private val appContext: Context,
private val notificationUtils: NotificationUtils private val notificationUtils: NotificationUtils
) : VectorInOutUseCase<File, Unit> { ) : VectorBaseInOutUseCase<File, Unit> {
/* ========================================================================================== /* ==========================================================================================
* Public API * Public API
* ========================================================================================== */ * ========================================================================================== */
// TODO find a way to provide Dispatchers via Interface to be able to unit tests // 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(Dispatchers.IO) {
runCatching { runCatching {
saveMedia( saveMedia(