Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
534
Issue boards
Milestones
Wiki
Code
Merge requests
10
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
55265e3f
Commit
55265e3f
authored
6 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
Pass image width to thumbnail provider
parent
3d776270
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
+3
-5
3 additions, 5 deletions
vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java
+10
-12
10 additions, 12 deletions
...android/src/org/videolan/vlc/util/ThumbnailsProvider.java
with
13 additions
and
17 deletions
vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
+
3
−
5
View file @
55265e3f
...
...
@@ -69,11 +69,9 @@ private suspend fun getImage(v: View, item: MediaLibraryItem, binding: ViewDataB
binding
?.
removeOnRebindCallback
(
rebindCallbacks
!!
)
}
private
suspend
fun
obtainBitmap
(
item
:
MediaLibraryItem
,
width
:
Int
)
:
Bitmap
?
{
return
withContext
(
VLCIO
)
{
if
(
item
.
itemType
==
MediaLibraryItem
.
TYPE_MEDIA
)
ThumbnailsProvider
.
getMediaThumbnail
(
item
as
MediaWrapper
)
else
AudioUtil
.
readCoverBitmap
(
Uri
.
decode
(
item
.
artworkMrl
),
width
)
}
private
suspend
fun
obtainBitmap
(
item
:
MediaLibraryItem
,
width
:
Int
)
=
withContext
(
VLCIO
)
{
if
(
item
.
itemType
==
MediaLibraryItem
.
TYPE_MEDIA
)
ThumbnailsProvider
.
getMediaThumbnail
(
item
as
MediaWrapper
,
width
)
else
AudioUtil
.
readCoverBitmap
(
Uri
.
decode
(
item
.
artworkMrl
),
width
)
}
@MainThread
...
...
This diff is collapsed.
Click to expand it.
vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.java
+
10
−
12
View file @
55265e3f
...
...
@@ -12,7 +12,6 @@ import android.text.TextUtils;
import
org.videolan.medialibrary.Medialibrary
;
import
org.videolan.medialibrary.media.MediaLibraryItem
;
import
org.videolan.medialibrary.media.MediaWrapper
;
import
org.videolan.vlc.R
;
import
org.videolan.vlc.VLCApplication
;
import
org.videolan.vlc.gui.helpers.AudioUtil
;
import
org.videolan.vlc.gui.helpers.BitmapCache
;
...
...
@@ -32,14 +31,13 @@ public class ThumbnailsProvider {
private
static
File
appDir
;
private
static
String
cacheDir
;
private
static
final
int
sImageWidth
=
VLCApplication
.
getAppResources
().
getDimensionPixelSize
(
VLCApplication
.
showTvUi
()
?
R
.
dimen
.
tv_grid_card_thumb_width
:
R
.
dimen
.
grid_card_thumb_width
);
private
static
final
int
MAX_IMAGES
=
4
;
@WorkerThread
public
static
Bitmap
getMediaThumbnail
(
final
MediaWrapper
item
)
{
if
(
item
.
getType
()
==
MediaWrapper
.
TYPE_GROUP
)
return
ThumbnailsProvider
.
getComposedImage
((
MediaGroup
)
item
);
if
(
item
.
getType
()
==
MediaWrapper
.
TYPE_VIDEO
&&
TextUtils
.
isEmpty
(
item
.
getArtworkMrl
()))
return
getVideoThumbnail
(
item
);
else
return
AudioUtil
.
readCoverBitmap
(
Uri
.
decode
(
item
.
getArtworkMrl
()),
sImageW
idth
);
public
static
Bitmap
getMediaThumbnail
(
final
MediaWrapper
item
,
int
width
)
{
if
(
item
.
getType
()
==
MediaWrapper
.
TYPE_GROUP
)
return
ThumbnailsProvider
.
getComposedImage
((
MediaGroup
)
item
,
width
);
if
(
item
.
getType
()
==
MediaWrapper
.
TYPE_VIDEO
&&
TextUtils
.
isEmpty
(
item
.
getArtworkMrl
()))
return
getVideoThumbnail
(
item
,
width
);
else
return
AudioUtil
.
readCoverBitmap
(
Uri
.
decode
(
item
.
getArtworkMrl
()),
w
idth
);
}
public
static
String
getMediaCacheKey
(
boolean
isMedia
,
MediaLibraryItem
item
)
{
...
...
@@ -53,14 +51,14 @@ public class ThumbnailsProvider {
}
@WorkerThread
private
static
Bitmap
getVideoThumbnail
(
final
MediaWrapper
media
)
{
private
static
Bitmap
getVideoThumbnail
(
final
MediaWrapper
media
,
int
width
)
{
final
String
filePath
=
media
.
getUri
().
getPath
();
if
(
appDir
==
null
)
appDir
=
VLCApplication
.
getAppContext
().
getExternalFilesDir
(
null
);
final
boolean
hasCache
=
appDir
!=
null
&&
appDir
.
exists
();
final
String
thumbPath
=
getMediaCacheKey
(
true
,
media
);
final
Bitmap
cacheBM
=
hasCache
?
BitmapCache
.
getInstance
().
getBitmapFromMemCache
(
thumbPath
)
:
null
;
if
(
cacheBM
!=
null
)
return
cacheBM
;
if
(
hasCache
&&
new
File
(
thumbPath
).
exists
())
return
readCoverBitmap
(
thumbPath
,
sImageW
idth
);
if
(
hasCache
&&
new
File
(
thumbPath
).
exists
())
return
readCoverBitmap
(
thumbPath
,
w
idth
);
if
(
media
.
isThumbnailGenerated
())
return
null
;
final
Bitmap
bitmap
=
ThumbnailUtils
.
createVideoThumbnail
(
filePath
,
MediaStore
.
Video
.
Thumbnails
.
MINI_KIND
);
if
(
bitmap
!=
null
)
{
...
...
@@ -76,12 +74,12 @@ public class ThumbnailsProvider {
}
@WorkerThread
private
static
Bitmap
getComposedImage
(
MediaGroup
group
)
{
private
static
Bitmap
getComposedImage
(
MediaGroup
group
,
int
width
)
{
final
BitmapCache
bmc
=
BitmapCache
.
getInstance
();
final
String
key
=
"group:"
+
group
.
getTitle
();
Bitmap
composedImage
=
bmc
.
getBitmapFromMemCache
(
key
);
if
(
composedImage
==
null
)
{
composedImage
=
composeImage
(
group
);
composedImage
=
composeImage
(
group
,
width
);
if
(
composedImage
!=
null
)
bmc
.
addBitmapToMemCache
(
key
,
composedImage
);
}
return
composedImage
;
...
...
@@ -91,11 +89,11 @@ public class ThumbnailsProvider {
* @param group The MediaGroup instance
* @return a Bitmap object
*/
private
static
Bitmap
composeImage
(
MediaGroup
group
)
{
private
static
Bitmap
composeImage
(
MediaGroup
group
,
int
imageWidth
)
{
final
Bitmap
[]
sourcesImages
=
new
Bitmap
[
Math
.
min
(
MAX_IMAGES
,
group
.
size
())];
int
count
=
0
,
minWidth
=
Integer
.
MAX_VALUE
,
minHeight
=
Integer
.
MAX_VALUE
;
for
(
MediaWrapper
media
:
group
.
getAll
())
{
final
Bitmap
bm
=
getVideoThumbnail
(
media
);
final
Bitmap
bm
=
getVideoThumbnail
(
media
,
imageWidth
);
if
(
bm
!=
null
)
{
int
width
=
bm
.
getWidth
();
int
height
=
bm
.
getHeight
();
...
...
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