mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Simple combine resume & next up
This commit is contained in:
parent
b40db0074f
commit
fc56a2c631
5 changed files with 43 additions and 47 deletions
|
|
@ -164,6 +164,18 @@ sealed interface AppPreference<T> {
|
||||||
summarizer = { value -> value?.toString() },
|
summarizer = { value -> value?.toString() },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val CombineContinueNext =
|
||||||
|
AppSwitchPreference(
|
||||||
|
title = R.string.combine_continue_next,
|
||||||
|
defaultValue = false,
|
||||||
|
getter = { it.homePagePreferences.combineContinueNext },
|
||||||
|
setter = { prefs, value ->
|
||||||
|
prefs.updateHomePagePreferences { combineContinueNext = value }
|
||||||
|
},
|
||||||
|
summaryOn = R.string.enabled,
|
||||||
|
summaryOff = R.string.disabled,
|
||||||
|
)
|
||||||
|
|
||||||
val RewatchNextUp =
|
val RewatchNextUp =
|
||||||
AppSwitchPreference(
|
AppSwitchPreference(
|
||||||
title = R.string.rewatch_next_up,
|
title = R.string.rewatch_next_up,
|
||||||
|
|
@ -457,6 +469,7 @@ val basicPreferences =
|
||||||
listOf(
|
listOf(
|
||||||
AppPreference.HomePageItems,
|
AppPreference.HomePageItems,
|
||||||
AppPreference.RewatchNextUp,
|
AppPreference.RewatchNextUp,
|
||||||
|
AppPreference.CombineContinueNext,
|
||||||
AppPreference.PlayThemeMusic,
|
AppPreference.PlayThemeMusic,
|
||||||
AppPreference.RememberSelectedTab,
|
AppPreference.RememberSelectedTab,
|
||||||
AppPreference.ThemeColors,
|
AppPreference.ThemeColors,
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ class AppPreferencesSerializer
|
||||||
.apply {
|
.apply {
|
||||||
maxItemsPerRow = AppPreference.HomePageItems.defaultValue.toInt()
|
maxItemsPerRow = AppPreference.HomePageItems.defaultValue.toInt()
|
||||||
enableRewatchingNextUp = AppPreference.RewatchNextUp.defaultValue
|
enableRewatchingNextUp = AppPreference.RewatchNextUp.defaultValue
|
||||||
|
combineContinueNext = AppPreference.CombineContinueNext.defaultValue
|
||||||
}.build()
|
}.build()
|
||||||
interfacePreferences =
|
interfacePreferences =
|
||||||
InterfacePreferences
|
InterfacePreferences
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ class HomeViewModel
|
||||||
val homeRows = MutableLiveData<List<HomeRow>>()
|
val homeRows = MutableLiveData<List<HomeRow>>()
|
||||||
|
|
||||||
fun init(preferences: UserPreferences) {
|
fun init(preferences: UserPreferences) {
|
||||||
val limit = preferences.appPreferences.homePagePreferences.maxItemsPerRow
|
val prefs = preferences.appPreferences.homePagePreferences
|
||||||
|
val limit = prefs.maxItemsPerRow
|
||||||
viewModelScope.launch(
|
viewModelScope.launch(
|
||||||
Dispatchers.IO +
|
Dispatchers.IO +
|
||||||
LoadingExceptionHandler(
|
LoadingExceptionHandler(
|
||||||
|
|
@ -78,53 +79,32 @@ class HomeViewModel
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// TODO data is fetched all together which may be slow for large servers
|
// TODO data is fetched all together which may be slow for large servers
|
||||||
|
val resume = getResume(user.id, limit)
|
||||||
|
val nextUp = getNextUp(user.id, limit, prefs.enableRewatchingNextUp)
|
||||||
|
val latest = getLatest(user, limit)
|
||||||
|
|
||||||
val homeRows =
|
val homeRows =
|
||||||
homeSections
|
if (prefs.combineContinueNext) {
|
||||||
.mapNotNull { section ->
|
listOf(
|
||||||
Timber.Forest.v("Loading section: %s", section.name)
|
HomeRow(
|
||||||
when (section) {
|
section = HomeSection.NEXT_UP,
|
||||||
HomeSection.LATEST_MEDIA -> {
|
items = resume + nextUp,
|
||||||
getLatest(user, limit)
|
),
|
||||||
}
|
*latest.toTypedArray(),
|
||||||
|
)
|
||||||
HomeSection.RESUME -> {
|
} else {
|
||||||
val items = getResume(user.id, limit)
|
listOf(
|
||||||
listOf(
|
HomeRow(
|
||||||
HomeRow(
|
section = HomeSection.RESUME,
|
||||||
section = section,
|
items = resume,
|
||||||
items = items,
|
),
|
||||||
),
|
HomeRow(
|
||||||
)
|
section = HomeSection.NEXT_UP,
|
||||||
}
|
items = nextUp,
|
||||||
|
),
|
||||||
HomeSection.NEXT_UP -> {
|
*latest.toTypedArray(),
|
||||||
val nextUp =
|
)
|
||||||
getNextUp(
|
}
|
||||||
user.id,
|
|
||||||
limit,
|
|
||||||
preferences.appPreferences.homePagePreferences.enableRewatchingNextUp,
|
|
||||||
)
|
|
||||||
listOf(
|
|
||||||
HomeRow(
|
|
||||||
section = section,
|
|
||||||
items = nextUp,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
HomeSection.LIVE_TV -> null
|
|
||||||
HomeSection.ACTIVE_RECORDINGS -> null
|
|
||||||
|
|
||||||
// TODO Not supported?
|
|
||||||
HomeSection.LIBRARY_TILES_SMALL -> null
|
|
||||||
HomeSection.LIBRARY_BUTTONS -> null
|
|
||||||
HomeSection.RESUME_AUDIO -> null
|
|
||||||
HomeSection.RESUME_BOOK -> null
|
|
||||||
HomeSection.NONE -> null
|
|
||||||
}
|
|
||||||
}.flatten()
|
|
||||||
.filter { it.items.isNotEmpty() }
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
this@HomeViewModel.homeRows.value = homeRows
|
this@HomeViewModel.homeRows.value = homeRows
|
||||||
loadingState.value = LoadingState.Success
|
loadingState.value = LoadingState.Success
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ message PlaybackPreferences {
|
||||||
message HomePagePreferences{
|
message HomePagePreferences{
|
||||||
int32 max_items_per_row = 1;
|
int32 max_items_per_row = 1;
|
||||||
bool enable_rewatching_next_up = 2;
|
bool enable_rewatching_next_up = 2;
|
||||||
|
bool combine_continue_next = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ThemeSongVolume {
|
enum ThemeSongVolume {
|
||||||
|
|
|
||||||
|
|
@ -76,5 +76,6 @@
|
||||||
<string name="no_update_available">No update available</string>
|
<string name="no_update_available">No update available</string>
|
||||||
<string name="clear_image_cache">Clear image cache</string>
|
<string name="clear_image_cache">Clear image cache</string>
|
||||||
<string name="shuffle">Shuffle</string>
|
<string name="shuffle">Shuffle</string>
|
||||||
|
<string name="combine_continue_next"><![CDATA[Combine Continue Watching & Next Up]]></string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue