Skip to content
Snippets Groups Projects
Commit bff8188e authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Util method to get default cover drawables

parent 12b00509
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment