-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
253a138
commit 9b9482d
Showing
11 changed files
with
126 additions
and
3 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
storage-api/src/main/java/com/omh/android/storage/api/OmhStorageClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.omh.android.storage.api | ||
|
||
import android.content.Context | ||
|
||
interface OmhStorageClient { | ||
|
||
interface Builder { | ||
fun build(context: Context): OmhStorageClient | ||
} | ||
|
||
fun setupAccessToken(token: String) | ||
} |
7 changes: 7 additions & 0 deletions
7
storage-api/src/main/java/com/omh/android/storage/api/OmhStorageFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.omh.android.storage.api | ||
|
||
import android.content.Context | ||
|
||
interface OmhStorageFactory { | ||
fun getStorageClient(context: Context): OmhStorageClient | ||
} |
16 changes: 16 additions & 0 deletions
16
storage-api/src/main/java/com/omh/android/storage/api/OmhStorageProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.omh.android.storage.api | ||
|
||
import android.content.Context | ||
import kotlin.reflect.KClass | ||
|
||
object OmhStorageProvider { | ||
|
||
private const val NGMS_ADDRESS = "com.omh.android.storage.api.drive.nongms.OmhStorageFactoryImpl" | ||
|
||
@SuppressWarnings("SwallowedException") | ||
fun provideStorageClient(context: Context): OmhStorageClient { | ||
val clazz: KClass<out Any> = Class.forName(NGMS_ADDRESS).kotlin | ||
val omhStorageFactory = clazz.objectInstance as OmhStorageFactory | ||
return omhStorageFactory.getStorageClient(context) | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...java/com/omh/android/storage/api/data/datasource/network/FilesFoldersNetworkDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package com.omh.android.storage.api.data.datasource.network | ||
|
||
import com.omh.android.storage.api.data.model.RemoteFileOrFolder | ||
|
||
interface FilesFoldersNetworkDataSource { | ||
fun getAll() | ||
fun getAll(): List<RemoteFileOrFolder> | ||
} |
31 changes: 31 additions & 0 deletions
31
storage-api/src/main/java/com/omh/android/storage/api/data/mapper/DataMappers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,32 @@ | ||
package com.omh.android.storage.api.data.mapper | ||
|
||
import com.omh.android.storage.api.data.model.RemoteFile | ||
import com.omh.android.storage.api.data.model.RemoteFileOrFolder | ||
import com.omh.android.storage.api.data.model.RemoteFolder | ||
import com.omh.android.storage.api.domain.model.File | ||
import com.omh.android.storage.api.domain.model.FileOrFolder | ||
import com.omh.android.storage.api.domain.model.Folder | ||
|
||
fun fromFilesFoldersRemoteListToDomain(inputList: List<RemoteFileOrFolder>): List<FileOrFolder> { | ||
val outputList = mutableListOf<FileOrFolder>() | ||
if (inputList.isEmpty()) { | ||
return outputList | ||
} | ||
for (gDriveFileOrFolder in inputList) { | ||
outputList.add( | ||
if (gDriveFileOrFolder is RemoteFile) { | ||
File( | ||
gDriveFileOrFolder.name, | ||
gDriveFileOrFolder.ext, | ||
gDriveFileOrFolder.lastModDate | ||
) | ||
} else { | ||
Folder( | ||
(gDriveFileOrFolder as RemoteFolder).name, | ||
gDriveFileOrFolder.lastModDate | ||
) | ||
} | ||
) | ||
} | ||
return outputList | ||
} |
13 changes: 13 additions & 0 deletions
13
storage-api/src/main/java/com/omh/android/storage/api/data/model/DataModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
package com.omh.android.storage.api.data.model | ||
|
||
interface RemoteFileOrFolder | ||
|
||
data class RemoteFile( | ||
val name: String = "", | ||
val ext: String = "", | ||
val lastModDate: Long = 0L | ||
) : RemoteFileOrFolder | ||
|
||
data class RemoteFolder( | ||
val name: String = "", | ||
val lastModDate: Long = 0L | ||
) : RemoteFileOrFolder |
13 changes: 13 additions & 0 deletions
13
...i/src/main/java/com/omh/android/storage/api/data/repository/FilesFoldersDataRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.omh.android.storage.api.data.repository | ||
|
||
import com.omh.android.storage.api.data.datasource.network.FilesFoldersNetworkDataSource | ||
import com.omh.android.storage.api.data.mapper.fromFilesFoldersRemoteListToDomain | ||
import com.omh.android.storage.api.domain.abstraction.FilesFoldersRepository | ||
|
||
class FilesFoldersDataRepository( | ||
private val networkDataSource: FilesFoldersNetworkDataSource | ||
) : FilesFoldersRepository { | ||
override fun getAll() = fromFilesFoldersRemoteListToDomain( | ||
networkDataSource.getAll() | ||
) | ||
} |
4 changes: 3 additions & 1 deletion
4
...pi/src/main/java/com/omh/android/storage/api/domain/abstraction/FilesFoldersRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package com.omh.android.storage.api.domain.abstraction | ||
|
||
import com.omh.android.storage.api.domain.model.FileOrFolder | ||
|
||
interface FilesFoldersRepository { | ||
fun getAll() | ||
fun getAll(): List<FileOrFolder> | ||
} |
16 changes: 16 additions & 0 deletions
16
storage-api/src/main/java/com/omh/android/storage/api/domain/model/DomainModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
package com.omh.android.storage.api.domain.model | ||
|
||
interface FileOrFolder { | ||
val name: String | ||
val modificationDate: Long | ||
} | ||
|
||
data class File( | ||
override val name: String, | ||
val extension: String, | ||
override val modificationDate: Long | ||
) : FileOrFolder | ||
|
||
data class Folder( | ||
override val name: String, | ||
override val modificationDate: Long | ||
) : FileOrFolder |
4 changes: 3 additions & 1 deletion
4
...age-api/src/main/java/com/omh/android/storage/api/domain/usecase/GetAllFilesAndFolders.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package com.omh.android.storage.api.domain.usecase | ||
|
||
import com.omh.android.storage.api.domain.model.FileOrFolder | ||
|
||
interface GetAllFilesAndFolders { | ||
fun execute() | ||
fun execute(): List<FileOrFolder> | ||
} |
9 changes: 9 additions & 0 deletions
9
.../src/main/java/com/omh/android/storage/api/domain/usecase/GetAllFilesAndFoldersUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.omh.android.storage.api.domain.usecase | ||
|
||
import com.omh.android.storage.api.domain.abstraction.FilesFoldersRepository | ||
|
||
class GetAllFilesAndFoldersUseCase( | ||
private val repository: FilesFoldersRepository | ||
) : GetAllFilesAndFolders { | ||
override fun execute() = repository.getAll() | ||
} |