[Android] BrowserFavoritesModel: Use a regular context
Geoffrey Métais
git at videolan.org
Thu May 7 12:17:06 CEST 2020
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon May 4 17:17:27 2020 +0200| [064b71b76bb32c302fba89e4f6ee45361ec8a543] | committer: Nicolas Pomepuy
BrowserFavoritesModel: Use a regular context
Avoid ClassCastException with Application
> https://code.videolan.org/videolan/vlc-android/commit/064b71b76bb32c302fba89e4f6ee45361ec8a543
---
.../src/org/videolan/vlc/viewmodels/browser/BrowserFavoritesModel.kt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/BrowserFavoritesModel.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/BrowserFavoritesModel.kt
index f4a2bed6b..9931eed9d 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/BrowserFavoritesModel.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/BrowserFavoritesModel.kt
@@ -28,6 +28,7 @@ import android.app.Application
import android.content.Context
import android.net.Uri
import androidx.lifecycle.AndroidViewModel
+import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -43,7 +44,7 @@ import org.videolan.vlc.providers.BrowserProvider
import org.videolan.vlc.repository.BrowserFavRepository
import org.videolan.vlc.util.convertFavorites
-class BrowserFavoritesModel(context: Context) : AndroidViewModel(context.applicationContext as Application) {
+class BrowserFavoritesModel(private val context: Context) : ViewModel() {
val favorites = LiveDataset<MediaLibraryItem>()
val provider = FavoritesProvider(context, favorites, viewModelScope)
}
More information about the Android
mailing list