Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DisplayPreferencesScreen not saving the preferences #824

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,28 @@ package org.jellyfin.androidtv.ui.browsing

import org.jellyfin.androidtv.R
import org.jellyfin.androidtv.TvApp
import org.jellyfin.androidtv.ui.preference.dsl.*
import org.jellyfin.androidtv.ui.preference.dsl.OptionsFragment
import org.jellyfin.androidtv.ui.preference.dsl.checkbox
import org.jellyfin.androidtv.ui.preference.dsl.lazyOptionsScreen
import org.jellyfin.androidtv.ui.preference.dsl.list
import timber.log.Timber

class DisplayPreferencesScreen : OptionsFragment() {
private val preferencesId by lazy {
requireArguments().getString(ARG_PREFERENCES_ID)
}

// Requires the caller of this view to pre-cache the display preferences
private val displayPreferences by lazy {
val id = requireArguments().getString(ARG_PREFERENCES_ID)
TvApp.getApplication().getCachedDisplayPrefs(id)
Timber.d("Loading cached display preferences with id $preferencesId")
TvApp.getApplication().getCachedDisplayPrefs(preferencesId)
}

override fun onStop() {
super.onStop()

Timber.d("Saving cached display preferences with id $preferencesId")
TvApp.getApplication().updateDisplayPrefs(displayPreferences)
}

override val screen by lazyOptionsScreen {
Expand Down