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
14
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
51b95a20
Commit
51b95a20
authored
7 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
Video adapter extends BaseQueuedAdapter
parent
08ee95ae
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+12
-18
12 additions, 18 deletions
...roid/src/org/videolan/vlc/gui/video/VideoListAdapter.java
with
12 additions
and
18 deletions
vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+
12
−
18
View file @
51b95a20
...
...
@@ -45,6 +45,7 @@ import org.videolan.medialibrary.media.MediaWrapper;
import
org.videolan.vlc.BR
;
import
org.videolan.vlc.R
;
import
org.videolan.vlc.VLCApplication
;
import
org.videolan.vlc.gui.BaseQueuedAdapter
;
import
org.videolan.vlc.gui.helpers.AsyncImageLoader
;
import
org.videolan.vlc.gui.helpers.UiTools
;
import
org.videolan.vlc.interfaces.IEventsHandler
;
...
...
@@ -52,14 +53,13 @@ import org.videolan.vlc.media.MediaGroup;
import
org.videolan.vlc.util.MediaItemFilter
;
import
org.videolan.vlc.util.MediaLibraryItemComparator
;
import
java.util.ArrayDeque
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.LinkedList
;
import
java.util.List
;
public
class
VideoListAdapter
extends
RecyclerView
.
Adapter
<
VideoListAdapter
.
ViewHolder
>
implements
Filterable
{
public
class
VideoListAdapter
extends
BaseQueuedAdapter
<
ArrayList
<
MediaWrapper
>,
VideoListAdapter
.
ViewHolder
>
implements
Filterable
{
public
final
static
String
TAG
=
"VLC/VideoListAdapter"
;
...
...
@@ -72,7 +72,6 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
private
IEventsHandler
mEventsHandler
;
private
static
MediaLibraryItemComparator
sMediaComparator
=
new
MediaLibraryItemComparator
(
MediaLibraryItemComparator
.
ADAPTER_VIDEO
);
private
ArrayList
<
MediaWrapper
>
mVideos
=
new
ArrayList
<>();
private
ArrayDeque
<
ArrayList
<
MediaWrapper
>>
mPendingUpdates
=
new
ArrayDeque
<>();
private
ArrayList
<
MediaWrapper
>
mOriginalData
=
null
;
private
ItemFilter
mFilter
=
new
ItemFilter
();
private
int
mSelectionCount
=
0
;
...
...
@@ -176,8 +175,8 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
}
@MainThread
p
rivate
ArrayList
<
MediaWrapper
>
peekLast
()
{
return
m
PendingUpdates
.
isEmpty
()
?
mVideos
:
mPendingUpdates
.
peekLast
();
p
ublic
ArrayList
<
MediaWrapper
>
peekLast
()
{
return
has
PendingUpdates
()
?
super
.
peekLast
()
:
mVideos
;
}
public
boolean
contains
(
MediaWrapper
mw
)
{
...
...
@@ -411,35 +410,30 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
view
.
setLayoutParams
(
layoutParams
);
}
@MainThread
void
update
(
final
ArrayList
<
MediaWrapper
>
items
,
final
boolean
detectMoves
)
{
mPendingUpdates
.
add
(
items
);
if
(
mPendingUpdates
.
size
()
==
1
)
internalUpdate
(
items
,
detectMoves
);
}
private
void
internalUpdate
(
final
ArrayList
<
MediaWrapper
>
items
,
final
boolean
detectMoves
)
{
protected
void
internalUpdate
(
final
ArrayList
<
MediaWrapper
>
items
,
final
boolean
detectMoves
)
{
VLCApplication
.
runBackground
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
detectMoves
||
mVideos
.
isEmpty
())
if
(
detectMoves
||
items
.
size
()
!=
getItemCount
())
Collections
.
sort
(
items
,
sMediaComparator
);
final
DiffUtil
.
DiffResult
result
=
DiffUtil
.
calculateDiff
(
new
VideoItemDiffCallback
(
mVideos
,
items
),
detectMoves
);
VLCApplication
.
runOnMainThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
mPendingUpdates
.
remove
();
mVideos
=
items
;
result
.
dispatchUpdatesTo
(
VideoListAdapter
.
this
);
mEventsHandler
.
onUpdateFinished
(
null
);
if
(!
mPendingUpdates
.
isEmpty
())
internalUpdate
(
mPendingUpdates
.
peek
(),
true
);
processQueue
();
}
});
}
});
}
@Override
protected
void
onUpdateFinished
()
{
mEventsHandler
.
onUpdateFinished
(
null
);
}
private
class
VideoItemDiffCallback
extends
DiffUtil
.
Callback
{
ArrayList
<
MediaWrapper
>
oldList
,
newList
;
VideoItemDiffCallback
(
ArrayList
<
MediaWrapper
>
oldList
,
ArrayList
<
MediaWrapper
>
newList
)
{
...
...
This diff is collapsed.
Click to expand it.
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