[Android] Util method to get default cover drawables
Geoffrey Métais
git at videolan.org
Tue Jan 31 16:30:10 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan 31 16:26:11 2017 +0100| [bff8188e482c2fc74bea9c2781d2ba575b009e44] | committer: Geoffrey Métais
Util method to get default cover drawables
> https://code.videolan.org/videolan/vlc-android/commit/bff8188e482c2fc74bea9c2781d2ba575b009e44
---
.../org/videolan/vlc/gui/helpers/AsyncImageLoader.java | 4 +++-
.../src/org/videolan/vlc/gui/helpers/UiTools.java | 18 ++++++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java b/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
index 5442948..b7c0d46 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
@@ -59,8 +59,10 @@ public class AsyncImageLoader {
public static final Bitmap DEFAULT_COVER_VIDEO = BitmapCache.getFromResource(VLCApplication.getAppResources(), R.drawable.ic_no_thumbnail_1610);
public static final BitmapDrawable DEFAULT_COVER_VIDEO_DRAWABLE = new BitmapDrawable(VLCApplication.getAppResources(), DEFAULT_COVER_VIDEO);
- public static final Bitmap DEFAULT_COVER_AUDIO = BitmapCache.getFromResource(VLCApplication.getAppResources(), R.drawable.icon);
+ public static final Bitmap DEFAULT_COVER_AUDIO = BitmapCache.getFromResource(VLCApplication.getAppResources(), R.drawable.ic_no_song);
public static final BitmapDrawable DEFAULT_COVER_AUDIO_DRAWABLE = new BitmapDrawable(VLCApplication.getAppResources(), DEFAULT_COVER_AUDIO);
+ public static final BitmapDrawable DEFAULT_COVER_ARTIST_DRAWABLE = new BitmapDrawable(VLCApplication.getAppResources(), BitmapCache.getFromResource(VLCApplication.getAppResources(), R.drawable.ic_no_artist));
+ public static final BitmapDrawable DEFAULT_COVER_ALBUM_DRAWABLE = new BitmapDrawable(VLCApplication.getAppResources(), BitmapCache.getFromResource(VLCApplication.getAppResources(), R.drawable.ic_no_album));
/*
* Custom bindings to trigger image (down)loading
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
index e1fc507..66e3064 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
@@ -28,6 +28,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.databinding.BindingAdapter;
+import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -36,9 +37,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.text.TextUtils;
import android.util.DisplayMetrics;
@@ -52,6 +51,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.TextView;
+import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.R;
@@ -249,4 +249,18 @@ public class UiTools {
if (Looper.getMainLooper() != Looper.myLooper())
throw new IllegalThreadStateException();
}
+
+ public static BitmapDrawable getDefaultCover(MediaLibraryItem item) {
+ switch (item.getItemType()) {
+ case MediaLibraryItem.TYPE_ARTIST:
+ return AsyncImageLoader.DEFAULT_COVER_ARTIST_DRAWABLE;
+ case MediaLibraryItem.TYPE_ALBUM:
+ return AsyncImageLoader.DEFAULT_COVER_ALBUM_DRAWABLE;
+ case MediaLibraryItem.TYPE_MEDIA:
+ if (((MediaWrapper)item).getType() == MediaWrapper.TYPE_VIDEO)
+ return AsyncImageLoader.DEFAULT_COVER_VIDEO_DRAWABLE;
+ default:
+ return AsyncImageLoader.DEFAULT_COVER_AUDIO_DRAWABLE;
+ }
+ }
}
More information about the Android
mailing list