-
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 pull request #46 from KevinSchildhorn/StartingPlaylists
Starting playlists
- Loading branch information
Showing
15 changed files
with
134 additions
and
56 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
Oops, something went wrong.