Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
531
Issue boards
Milestones
Wiki
Code
Merge requests
13
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
f240566d
Commit
f240566d
authored
5 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
VideogridFragment: Move observer in the Fragment
parent
9a4e7844
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7840
failed with stage
in 21 minutes and 54 seconds
Changes
2
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+12
-3
12 additions, 3 deletions
...droid/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt
+3
-3
3 additions, 3 deletions
...ndroid/src/org/videolan/vlc/gui/video/VideoListAdapter.kt
with
15 additions
and
6 deletions
vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+
12
−
3
View file @
f240566d
...
...
@@ -96,8 +96,6 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
}
}
private
val
handler
=
VideoGridFragmentHandler
(
WeakReference
(
this
))
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
if
(!
::
videoListAdapter
.
isInitialized
)
{
...
...
@@ -109,6 +107,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
else
arguments
?.
getParcelable
(
KEY_FOLDER
)
viewModel
=
getViewModel
(
folder
)
viewModel
.
provider
.
pagedList
.
observe
(
this
,
this
)
AbstractMedialibrary
.
lastThumb
.
observe
(
this
,
thumbObs
)
}
}
...
...
@@ -175,7 +174,6 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
override
fun
onDestroy
()
{
super
.
onDestroy
()
gridItemDecoration
=
null
videoListAdapter
.
release
()
}
override
fun
onChanged
(
list
:
PagedList
<
AbstractMediaWrapper
>?)
{
...
...
@@ -377,4 +375,15 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
CTX_ADD_TO_PLAYLIST
->
UiTools
.
addToPlaylist
(
requireActivity
(),
media
.
tracks
,
SavePlaylistDialog
.
KEY_NEW_TRACKS
)
}
}
private
val
handler
=
VideoGridFragmentHandler
(
WeakReference
(
this
))
private
val
thumbObs
=
Observer
<
AbstractMediaWrapper
>
{
media
->
if
(!
::
videoListAdapter
.
isInitialized
)
return
@Observer
val
position
=
viewModel
.
provider
.
pagedList
.
value
?.
indexOf
(
media
)
?:
return
@Observer
videoListAdapter
.
getItem
(
position
)
?.
run
{
artworkURL
=
media
.
artworkURL
videoListAdapter
.
notifyItemChanged
(
position
)
}
}
}
This diff is collapsed.
Click to expand it.
vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt
+
3
−
3
View file @
f240566d
...
...
@@ -20,6 +20,7 @@
package
org.videolan.vlc.gui.video
import
android.annotation.SuppressLint
import
android.annotation.TargetApi
import
android.content.Context
import
android.os.Build
...
...
@@ -126,9 +127,7 @@ class VideoListAdapter internal constructor(
override
fun
getItem
(
position
:
Int
)
=
if
(
isPositionValid
(
position
))
super
.
getItem
(
position
)
else
null
private
fun
isPositionValid
(
position
:
Int
):
Boolean
{
return
position
in
0
..
(
itemCount
-
1
)
}
private
fun
isPositionValid
(
position
:
Int
)
=
position
in
0
until
itemCount
// operator fun contains(mw: AbstractMediaWrapper): Boolean {
// return getDataset().indexOf(mw) !== -1
...
...
@@ -223,6 +222,7 @@ class VideoListAdapter internal constructor(
return
oldItem
===
newItem
||
oldItem
.
type
==
newItem
.
type
&&
oldItem
.
equals
(
newItem
)
}
@SuppressLint
(
"DiffUtilEquals"
)
override
fun
areContentsTheSame
(
oldItem
:
AbstractMediaWrapper
,
newItem
:
AbstractMediaWrapper
):
Boolean
{
return
oldItem
===
newItem
||
(
oldItem
.
displayTime
==
newItem
.
displayTime
&&
TextUtils
.
equals
(
oldItem
.
artworkMrl
,
newItem
.
artworkMrl
)
...
...
This diff is collapsed.
Click to expand it.
Duncan McNamara
@Skantes
mentioned in issue
#904 (closed)
·
5 years ago
mentioned in issue
#904 (closed)
mentioned in issue #904
Toggle commit list
Duncan McNamara
@Skantes
mentioned in issue
#910 (closed)
·
5 years ago
mentioned in issue
#910 (closed)
mentioned in issue #910
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment