[Android] Video: bind viewmodel to activity lifecycle
Geoffrey Métais
git at videolan.org
Tue Apr 30 16:02:14 CEST 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Apr 30 15:58:28 2019 +0200| [3e587a46c4857a865308a2ce2a4b8c53856ca624] | committer: Geoffrey Métais
Video: bind viewmodel to activity lifecycle
> https://code.videolan.org/videolan/vlc-android/commit/3e587a46c4857a865308a2ce2a4b8c53856ca624
---
vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt | 2 +-
vlc-android/src/org/videolan/vlc/viewmodels/paged/PagedVideosModel.kt | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index 587febc3a..ac9faa61f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -101,7 +101,7 @@ class VideoGridFragment : MediaBrowserFragment<PagedVideosModel>(), androidx.swi
val seenMarkVisible = preferences.getBoolean("media_seen", true)
videoListAdapter = VideoListAdapter(this, seenMarkVisible)
multiSelectHelper = videoListAdapter.multiSelectHelper
- viewModel = PagedVideosModel.get(requireContext(), this, videoFolder)
+ viewModel = PagedVideosModel.get(this, videoFolder)
viewModel.pagedList.observe(this, this)
}
if (savedInstanceState != null) setGroup(savedInstanceState.getString(KEY_GROUP))
diff --git a/vlc-android/src/org/videolan/vlc/viewmodels/paged/PagedVideosModel.kt b/vlc-android/src/org/videolan/vlc/viewmodels/paged/PagedVideosModel.kt
index c01751860..bb49fd7a0 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/paged/PagedVideosModel.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/paged/PagedVideosModel.kt
@@ -97,13 +97,12 @@ class PagedVideosModel(
companion object {
@JvmOverloads
fun get(
- context: Context,
fragment: Fragment,
folder: Folder? = null,
sort : Int = Medialibrary.SORT_DEFAULT,
desc : Boolean? = null
) : PagedVideosModel {
- return ViewModelProviders.of(fragment, Factory(context, folder, sort, desc)).get(PagedVideosModel::class.java)
+ return ViewModelProviders.of(fragment.requireActivity(), Factory(fragment.requireContext(), folder, sort, desc)).get(PagedVideosModel::class.java)
}
}
}
\ No newline at end of file
More information about the Android
mailing list