Skip to content
Snippets Groups Projects
Commit 4f97794f authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Hide the history section if the playback history setting is unchecked

Fixes #2035
parent 9f2131bc
No related branches found
No related tags found
1 merge request!992Various UI fixes
......@@ -98,6 +98,7 @@ class MoreFragment : BaseFragment(), IRefreshable, IHistory, IDialogManager,
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
historyEntry = view.findViewById(R.id.history_entry)
if (!Settings.getInstance(requireActivity()).getBoolean(PLAYBACK_HISTORY, true)) historyEntry.setGone()
viewModel = ViewModelProvider(requireActivity(), HistoryModel.Factory(requireContext())).get(HistoryModel::class.java)
viewModel.dataset.observe(viewLifecycleOwner, { list ->
list?.let {
......
......@@ -29,12 +29,15 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.tools.CoroutineContextProvider
import org.videolan.tools.PLAYBACK_HISTORY
import org.videolan.tools.Settings
class HistoryModel(context: Context, coroutineContextProvider: CoroutineContextProvider = CoroutineContextProvider()) : MedialibraryModel<MediaWrapper>(context, coroutineContextProvider) {
override fun canSortByName() = false
override suspend fun updateList() {
if (!Settings.getInstance(context).getBoolean(PLAYBACK_HISTORY, true)) return
dataset.value = withContext(coroutineContextProvider.Default) { medialibrary.lastMediaPlayed().toMutableList() }
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment