Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename list files use case #31

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal interface GoogleStorageApiService {
}

@GET(FILES_PARTICLE)
fun getFilesListWithParentId(
fun getFilesList(
@Query(QUERY_Q) query: String,
@Query(QUERY_FIELDS) fields: String = FIELDS_VALUE
): Call<FileListRemoteResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ internal class NonGmsFileRepositoryImpl(
private val dataSource: OmhFileRemoteDataSource
) : FileRepository {

override fun getFilesListWithParentId(parentId: String) =
dataSource.getFilesListWithParentId(parentId)
override fun getFilesList(parentId: String) =
dataSource.getFilesList(parentId)

override fun createFile(name: String, mimeType: String, parentId: String?) =
dataSource.createFile(name, mimeType, parentId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import com.omh.android.storage.api.drive.nongms.data.source.mapper.toFileList
internal class NonGmsFileRemoteDataSourceImpl(private val retrofitImpl: GoogleRetrofitImpl) :
OmhFileRemoteDataSource {

override fun getFilesListWithParentId(parentId: String): List<OmhFile> {
override fun getFilesList(parentId: String): List<OmhFile> {
val response = retrofitImpl
.getGoogleStorageApiService()
.getFilesListWithParentId(
.getFilesList(
query = GoogleStorageApiService.getQueryValue(parentId)
)
.execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.omh.android.auth.api.OmhAuthClient
import com.omh.android.storage.api.domain.repository.FileRepository
import com.omh.android.storage.api.domain.usecase.CreateFileUseCase
import com.omh.android.storage.api.domain.usecase.DeleteFileUseCase
import com.omh.android.storage.api.domain.usecase.GetFilesListWithParentIdUseCase
import com.omh.android.storage.api.domain.usecase.GetFilesListUseCase

abstract class OmhStorageClient protected constructor(
protected val authClient: OmhAuthClient
Expand All @@ -23,7 +23,7 @@ abstract class OmhStorageClient protected constructor(
* and will not return an use case
*/
@SuppressWarnings("ForbiddenComment")
fun listFiles() = GetFilesListWithParentIdUseCase(getRepository())
fun listFiles() = GetFilesListUseCase(getRepository())

fun createFile() = CreateFileUseCase(getRepository())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.omh.android.storage.api.domain.model.OmhFile

interface OmhFileRemoteDataSource {

fun getFilesListWithParentId(parentId: String = "root"): List<OmhFile>
fun getFilesList(parentId: String = "root"): List<OmhFile>

fun createFile(name: String, mimeType: String, parentId: String?): OmhFile?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.omh.android.storage.api.domain.model.OmhFile

interface FileRepository {

fun getFilesListWithParentId(parentId: String = "root"): List<OmhFile>
fun getFilesList(parentId: String = "root"): List<OmhFile>

fun createFile(name: String, mimeType: String, parentId: String?): OmhFile?

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.omh.android.storage.api.domain.usecase

import com.omh.android.storage.api.domain.model.OmhFile
import com.omh.android.storage.api.domain.repository.FileRepository
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers

class GetFilesListUseCase(
private val repository: FileRepository,
dispatcher: CoroutineDispatcher = Dispatchers.Default
) : OmhSuspendUseCase<GetFilesListUseCaseParams, GetFilesListUseCaseResult>(dispatcher) {

override suspend fun execute(
parameters: GetFilesListUseCaseParams
) = GetFilesListUseCaseResult(
repository.getFilesList(parameters.parentId)
)
}

data class GetFilesListUseCaseParams(val parentId: String = "root")

data class GetFilesListUseCaseResult(val files: List<OmhFile>)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import com.omh.android.storage.api.OmhStorageClient
import com.omh.android.storage.api.domain.model.OmhFileType
import com.omh.android.storage.api.domain.usecase.CreateFileUseCase
import com.omh.android.storage.api.domain.usecase.CreateFileUseCaseParams
import com.omh.android.storage.api.domain.usecase.GetFilesListWithParentIdUseCase
import com.omh.android.storage.api.domain.usecase.GetFilesListWithParentIdUseCaseParams
import com.omh.android.storage.api.domain.usecase.GetFilesListUseCase
import com.omh.android.storage.api.domain.usecase.GetFilesListUseCaseParams
import com.omh.android.storage.api.domain.usecase.OmhResult
import com.omh.android.storage.sample.domain.model.FileType
import com.omh.android.storage.sample.presentation.BaseViewModel
Expand Down Expand Up @@ -54,10 +54,10 @@ class FileViewerViewModel @Inject constructor(
setState(FileViewerViewState.Loading)
val parentId = parentIdStack.peek()

val listFilesUseCase: GetFilesListWithParentIdUseCase = omhStorageClient.listFiles()
val listFilesUseCase: GetFilesListUseCase = omhStorageClient.listFiles()

when (
val result = listFilesUseCase(GetFilesListWithParentIdUseCaseParams(parentId))
val result = listFilesUseCase(GetFilesListUseCaseParams(parentId))
) {
is OmhResult.OmhSuccess -> {
setState(FileViewerViewState.Content(result.data.files))
Expand Down