-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/BDBD-525' into stage/sandbox
# Conflicts: # presentation/src/main/res/navigation/nav_graph.xml
- Loading branch information
Showing
28 changed files
with
652 additions
and
267 deletions.
There are no files selected for viewing
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
38 changes: 38 additions & 0 deletions
38
data/src/main/java/com/fakedevelopers/data/repository/AlbumRepositoryImpl.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,38 @@ | ||
package com.fakedevelopers.data.repository | ||
|
||
import com.fakedevelopers.domain.model.AlbumInfo | ||
import com.fakedevelopers.domain.model.AlbumItem | ||
import com.fakedevelopers.domain.repository.AlbumRepository | ||
|
||
class AlbumRepositoryImpl : AlbumRepository { | ||
override fun getAlbumInfo( | ||
albumItems: List<AlbumItem>, | ||
allImagesTitle: String | ||
): List<AlbumInfo> { | ||
val albumInfo = mutableListOf<AlbumInfo>() | ||
albumInfo.add( | ||
AlbumInfo( | ||
path = "", | ||
firstImage = albumItems[0].uri, | ||
name = allImagesTitle, | ||
count = albumItems.size | ||
) | ||
) | ||
val countMap = mutableMapOf<String, Int>() | ||
albumItems.forEach { albumItem -> | ||
val relPath = albumItem.path.substringBeforeLast('/') | ||
countMap[relPath] = (countMap[relPath] ?: 0) + 1 | ||
} | ||
countMap.keys.forEach { relPath -> | ||
albumInfo.add( | ||
AlbumInfo( | ||
path = relPath, | ||
firstImage = albumItems.find { it.path.contains(relPath) }?.uri ?: "", | ||
name = relPath.substringAfterLast('/'), | ||
count = countMap[relPath] ?: 0 | ||
) | ||
) | ||
} | ||
return albumInfo | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
domain/src/main/java/com/fakedevelopers/domain/model/AlbumInfo.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,8 @@ | ||
package com.fakedevelopers.domain.model | ||
|
||
data class AlbumInfo( | ||
val path: String, | ||
val firstImage: String, | ||
val name: String, | ||
val count: Int | ||
) |
8 changes: 8 additions & 0 deletions
8
domain/src/main/java/com/fakedevelopers/domain/repository/AlbumRepository.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,8 @@ | ||
package com.fakedevelopers.domain.repository | ||
|
||
import com.fakedevelopers.domain.model.AlbumInfo | ||
import com.fakedevelopers.domain.model.AlbumItem | ||
|
||
interface AlbumRepository { | ||
fun getAlbumInfo(albumItems: List<AlbumItem>, allImagesTitle: String): List<AlbumInfo> | ||
} |
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
15 changes: 15 additions & 0 deletions
15
domain/src/main/java/com/fakedevelopers/domain/usecase/GetAlbumInfoUseCase.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,15 @@ | ||
package com.fakedevelopers.domain.usecase | ||
|
||
import com.fakedevelopers.domain.repository.AlbumRepository | ||
import javax.inject.Inject | ||
|
||
class GetAlbumInfoUseCase @Inject constructor( | ||
private val getImagesUseCase: GetImagesUseCase, | ||
private val albumRepository: AlbumRepository | ||
) { | ||
suspend operator fun invoke(allImagesTitle: String) = | ||
albumRepository.getAlbumInfo( | ||
albumItems = getImagesUseCase(), | ||
allImagesTitle = allImagesTitle | ||
) | ||
} |
5 changes: 3 additions & 2 deletions
5
...ers/domain/usecase/GetAllImagesUseCase.kt → ...domain/usecase/GetImageObserverUseCase.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,10 +1,11 @@ | ||
package com.fakedevelopers.domain.usecase | ||
|
||
import com.fakedevelopers.domain.repository.ImageRepository | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class GetAllImagesUseCase @Inject constructor( | ||
class GetImageObserverUseCase @Inject constructor( | ||
private val repository: ImageRepository | ||
) { | ||
suspend operator fun invoke() = repository.getAllImages() | ||
operator fun invoke(): Flow<String> = repository.getImageObserver() | ||
} |
12 changes: 12 additions & 0 deletions
12
domain/src/main/java/com/fakedevelopers/domain/usecase/GetImagesUseCase.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.fakedevelopers.domain.usecase | ||
|
||
import com.fakedevelopers.domain.model.AlbumItem | ||
import com.fakedevelopers.domain.repository.ImageRepository | ||
import javax.inject.Inject | ||
|
||
class GetImagesUseCase @Inject constructor( | ||
private val repository: ImageRepository | ||
) { | ||
suspend operator fun invoke(path: String? = null): List<AlbumItem> = | ||
repository.getImages(path) | ||
} |
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
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
Oops, something went wrong.