Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
530
Issue boards
Milestones
Wiki
Code
Merge requests
15
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
c66d5705
Commit
c66d5705
authored
5 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
Fix thumbnail generation crash
parent
2810e2ef
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#6608
passed with stage
in 3 minutes and 52 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java
+9
-9
9 additions, 9 deletions
...android/src/org/videolan/vlc/util/ThumbnailsProvider.java
with
9 additions
and
9 deletions
vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java
+
9
−
9
View file @
c66d5705
...
...
@@ -8,6 +8,8 @@ import android.net.Uri;
import
android.provider.MediaStore
;
import
android.text.TextUtils
;
import
androidx.annotation.WorkerThread
;
import
org.videolan.medialibrary.Medialibrary
;
import
org.videolan.medialibrary.media.Folder
;
import
org.videolan.medialibrary.media.MediaLibraryItem
;
...
...
@@ -21,11 +23,10 @@ import org.videolan.vlc.media.MediaGroup;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
androidx.annotation.WorkerThread
;
import
static
org
.
videolan
.
medialibrary
.
Medialibrary
.
THUMBS_FOLDER_NAME
;
import
static
org
.
videolan
.
vlc
.
gui
.
helpers
.
AudioUtil
.
readCoverBitmap
;
...
...
@@ -41,8 +42,7 @@ public class ThumbnailsProvider {
@WorkerThread
public
static
Bitmap
getFolderThumbnail
(
final
Folder
folder
,
int
width
)
{
final
List
<
MediaWrapper
>
media
=
Arrays
.
asList
(
folder
.
media
(
Folder
.
TYPE_FOLDER_VIDEO
,
Medialibrary
.
SORT_DEFAULT
,
true
,
4
,
0
));
final
Bitmap
img
=
ThumbnailsProvider
.
getComposedImage
(
"folder:"
+
folder
.
getTitle
(),
media
,
width
);
return
img
;
return
ThumbnailsProvider
.
getComposedImage
(
"folder:"
+
folder
.
getTitle
(),
media
,
width
);
}
@WorkerThread
...
...
@@ -105,22 +105,22 @@ public class ThumbnailsProvider {
* @return a Bitmap object
*/
private
static
Bitmap
composeImage
(
List
<
MediaWrapper
>
mediaList
,
int
imageWidth
)
{
final
Bitmap
[]
sourcesImages
=
new
Bitmap
[
Math
.
min
(
MAX_IMAGES
,
mediaList
.
size
())]
;
final
List
<
Bitmap
>
sourcesImages
=
new
ArrayList
<>()
;
int
count
=
0
,
minWidth
=
Integer
.
MAX_VALUE
,
minHeight
=
Integer
.
MAX_VALUE
;
for
(
MediaWrapper
media
:
mediaList
)
{
final
Bitmap
bm
=
getVideoThumbnail
(
media
,
imageWidth
);
if
(
bm
!=
null
)
{
int
width
=
bm
.
getWidth
();
int
height
=
bm
.
getHeight
();
sourcesImages
[
count
++]
=
bm
;
sourcesImages
.
add
(
bm
)
;
minWidth
=
Math
.
min
(
minWidth
,
width
);
minHeight
=
Math
.
min
(
minHeight
,
height
);
if
(
count
==
MAX_IMAGES
)
break
;
if
(
++
count
==
MAX_IMAGES
)
break
;
}
}
if
(
count
==
0
)
return
null
;
if
(
count
==
1
)
return
sourcesImages
[
0
]
;
return
composeCanvas
(
sourcesImages
,
count
,
minWidth
,
minHeight
);
if
(
count
==
1
)
return
sourcesImages
.
get
(
0
)
;
return
composeCanvas
(
sourcesImages
.
toArray
(
new
Bitmap
[
0
])
,
count
,
minWidth
,
minHeight
);
}
private
static
Bitmap
composeCanvas
(
Bitmap
[]
sourcesImages
,
int
count
,
int
minWidth
,
int
minHeight
)
{
...
...
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