-
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.
- Loading branch information
1 parent
1ce3fcd
commit ef996bc
Showing
15 changed files
with
116 additions
and
51 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
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
shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/ImageUtils.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.kevinschildhorn.fotopresenter.data | ||
|
||
val supportedImageTypes = listOf<String>( | ||
"png", | ||
"jpg", | ||
"jpeg", | ||
"bmp" | ||
) |
19 changes: 4 additions & 15 deletions
19
shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/PlaylistDetails.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,31 +1,20 @@ | ||
package com.kevinschildhorn.fotopresenter.data | ||
|
||
import com.kevinschildhorn.fotopresenter.PlaylistImage | ||
import com.kevinschildhorn.fotopresenter.PlaylistItems | ||
import com.kevinschildhorn.fotopresenter.data.network.DefaultNetworkDirectoryDetails | ||
import com.kevinschildhorn.fotopresenter.extension.isImagePath | ||
|
||
data class PlaylistDetails( | ||
val id: Long, | ||
val name: String, | ||
val images: List<PlaylistImage> = emptyList(), | ||
val items: List<PlaylistItems> = emptyList(), | ||
){ | ||
val asImageSlideshowDetails:ImageSlideshowDetails | ||
get() = ImageSlideshowDetails( | ||
directories = images.map { | ||
ImageDirectory( | ||
DefaultNetworkDirectoryDetails( | ||
id = it.directory_id.toInt(), | ||
fullPath = it.directory_path | ||
) | ||
) | ||
} | ||
) | ||
|
||
override fun toString(): String { | ||
return """ | ||
Playlist Details: | ||
id: $id | ||
name: $name | ||
images: ${images.count()} | ||
images: ${items.count()} | ||
""" | ||
} | ||
} |
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
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
41 changes: 41 additions & 0 deletions
41
...in/com/kevinschildhorn/fotopresenter/domain/image/RetrieveSlideshowFromPlaylistUseCase.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,41 @@ | ||
package com.kevinschildhorn.fotopresenter.domain.image | ||
|
||
import co.touchlab.kermit.Logger | ||
import com.kevinschildhorn.fotopresenter.data.ImageDirectory | ||
import com.kevinschildhorn.fotopresenter.data.ImageSlideshowDetails | ||
import com.kevinschildhorn.fotopresenter.data.PlaylistDetails | ||
import com.kevinschildhorn.fotopresenter.data.network.DefaultNetworkDirectoryDetails | ||
import com.kevinschildhorn.fotopresenter.extension.isImagePath | ||
import org.koin.core.component.KoinComponent | ||
import org.koin.core.component.inject | ||
|
||
/** | ||
Retrieving Slideshow Details From Playlist Details | ||
**/ | ||
class RetrieveSlideshowFromPlaylistUseCase( | ||
private val logger: Logger, | ||
) : KoinComponent { | ||
suspend operator fun invoke( | ||
playlistDetails: PlaylistDetails, | ||
): ImageSlideshowDetails { | ||
logger.i { "Starting to get details from playlist ${playlistDetails.name}" } | ||
val retrieveDirectoryUseCase: RetrieveImageDirectoriesUseCase by inject() | ||
|
||
val directories: List<ImageDirectory> = playlistDetails.items.map { item -> | ||
val directoryDetails = DefaultNetworkDirectoryDetails( | ||
id = item.directory_id.toInt(), | ||
fullPath = item.directory_path | ||
) | ||
if (item.directory_path.isImagePath) { | ||
listOf(ImageDirectory(directoryDetails)) | ||
} else { | ||
retrieveDirectoryUseCase( | ||
directoryDetails = directoryDetails, | ||
recursively = true, | ||
) | ||
} | ||
}.flatten() | ||
|
||
return ImageSlideshowDetails(directories) | ||
} | ||
} |
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
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
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
12 changes: 6 additions & 6 deletions
12
...childhorn/fotopresenter/ImageDirectory.sq → ...schildhorn/fotopresenter/PlaylistItems.sq
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,30 +1,30 @@ | ||
CREATE TABLE PlaylistImage ( | ||
CREATE TABLE PlaylistItems ( | ||
id INTEGER PRIMARY KEY NOT NULL, | ||
playlist_id INTEGER NOT NULL, | ||
directory_path TEXT NOT NULL, | ||
directory_id INTEGER NOT NULL | ||
); | ||
|
||
insertPlaylistImage: | ||
INSERT INTO PlaylistImage(playlist_id, directory_path, directory_id) | ||
INSERT INTO PlaylistItems(playlist_id, directory_path, directory_id) | ||
VALUES (?, ?, ?); | ||
|
||
selectPlaylistImages: | ||
SELECT * | ||
FROM PlaylistImage | ||
FROM PlaylistItems | ||
WHERE playlist_id = ?; | ||
|
||
selectPlaylistImage: | ||
SELECT * | ||
FROM PlaylistImage | ||
FROM PlaylistItems | ||
WHERE playlist_id = ? AND directory_path = ?; | ||
|
||
deletePlaylistImage: | ||
DELETE | ||
FROM PlaylistImage | ||
FROM PlaylistItems | ||
WHERE directory_path = ?; | ||
|
||
deletePlaylist: | ||
DELETE | ||
FROM PlaylistImage | ||
FROM PlaylistItems | ||
WHERE playlist_id = ?; |