Skip to content
Snippets Groups Projects
Commit 17fb15ab authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Fix crash in History on Android 4

parent 13d62e01
No related branches found
No related tags found
No related merge requests found
Pipeline #8577 canceled with stage
/*****************************************************************************
* HistoryFragment.java
* HistoryFragment.kt
*
* Copyright © 2012-2015 VLC authors and VideoLAN
* Copyright © 2012-2019 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -153,7 +153,7 @@ class HistoryFragment : MediaBrowserFragment<HistoryModel>(), IRefreshable, IHis
override fun clearHistory() {
mediaLibrary.clearHistory()
viewModel.clear()
viewModel.clearHistory()
}
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
......
......@@ -80,7 +80,7 @@ class MRLPanelFragment : Fragment(), View.OnKeyListener, TextView.OnEditorAction
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewModel = ViewModelProviders.of(requireActivity(), StreamsModel.Factory(requireContext())).get<StreamsModel>(StreamsModel::class.java)
viewModel = ViewModelProviders.of(requireActivity(), StreamsModel.Factory(requireContext())).get(StreamsModel::class.java)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
......
/*****************************************************************************
* HistoryModel.kt
*****************************************************************************
* Copyright © 2018 VLC authors and VideoLAN
* Copyright © 2018-2019 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -42,11 +42,11 @@ class HistoryModel(context: Context) : MedialibraryModel<AbstractMediaWrapper>(c
}
}
fun clear() {
fun clearHistory() {
dataset.value = mutableListOf()
}
class Factory(private val context: Context): ViewModelProvider.NewInstanceFactory() {
class Factory(private val context: Context) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
@Suppress("UNCHECKED_CAST")
return HistoryModel(context.applicationContext) as T
......
......@@ -38,4 +38,4 @@ abstract class MedialibraryModel<T : MediaLibraryItem>(context: Context) : BaseM
releaseCallbacks()
super.onCleared()
}
}
\ No newline at end of file
}
/*******************************************************************************
* MRLPanelModel.kt
* StreamsModel.kt
* ****************************************************************************
* Copyright © 2018 VLC authors and VideoLAN
* Copyright © 2018-2019 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -48,7 +48,7 @@ class StreamsModel(context: Context) : MedialibraryModel<AbstractMediaWrapper>(c
refresh()
}
class Factory(private val context: Context) : ViewModelProvider.NewInstanceFactory() {
class Factory(private val context: Context) : ViewModelProvider.Factory() {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
@Suppress("UNCHECKED_CAST")
return StreamsModel(context.applicationContext) as T
......
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