[Android] audio: show vlc icon if there is no cover
Sébastien Toque
git at videolan.org
Sun Oct 14 18:55:12 CEST 2012
vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Sun Oct 14 18:55:09 2012 +0200| [88834c72637099fe24e724dbd49ea5e4412cb166] | committer: Sébastien Toque
audio: show vlc icon if there is no cover
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=88834c72637099fe24e724dbd49ea5e4412cb166
---
.../src/org/videolan/vlc/gui/audio/AudioListAdapter.java | 5 ++++-
.../src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java | 7 +++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java
index e373710..47e6598 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java
@@ -30,6 +30,7 @@ import org.videolan.vlc.Util;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -41,11 +42,13 @@ public class AudioListAdapter extends ArrayAdapter<Media> {
private ArrayList<Media> mMediaList;
private int mCurrentIndex;
+ private Bitmap mDefaultCover;
public AudioListAdapter(Context context) {
super(context, 0);
mMediaList = new ArrayList<Media>();
mCurrentIndex = -1;
+ mDefaultCover = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon);
}
@Override
@@ -89,7 +92,7 @@ public class AudioListAdapter extends ArrayAdapter<Media> {
Media media = getItem(position);
Bitmap cover = AudioUtil.getCover(v.getContext(), media, 64);
- holder.cover.setImageBitmap(cover);
+ holder.cover.setImageBitmap(cover != null ? cover : mDefaultCover);
Util.setItemBackground(holder.layout, position);
holder.title.setText(media.getTitle());
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
index 16f1833..5bd938d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
@@ -31,6 +31,7 @@ import org.videolan.vlc.Util;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -47,6 +48,7 @@ public class AudioPlaylistAdapter extends BaseExpandableListAdapter {
private ArrayList<String> mTitles;
private HashMap<String, ArrayList<String>> mSubTitles;
private HashMap<String, HashMap<String, ArrayList<Media>>> mGroups;
+ private Bitmap mDefaultCover;
public AudioPlaylistAdapter(Context context, int groupTextId, int childTextId) {
mContext = context;
@@ -56,6 +58,7 @@ public class AudioPlaylistAdapter extends BaseExpandableListAdapter {
mTitles = new ArrayList<String>();
mSubTitles = new HashMap<String, ArrayList<String>>();
mGroups = new HashMap<String, HashMap<String, ArrayList<Media>>>();
+ mDefaultCover = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon);
}
public void add(String title, String subtitle, Media media) {
@@ -168,7 +171,7 @@ public class AudioPlaylistAdapter extends BaseExpandableListAdapter {
Resources res = mContext.getResources();
Bitmap cover = AudioUtil.getCover(v.getContext(), list.get(0), 64);
- holder.cover.setImageBitmap(cover);
+ holder.cover.setImageBitmap(cover != null ? cover : mDefaultCover);
Util.setItemBackground(holder.layout, groupPosition);
holder.title.setText(name);
@@ -209,7 +212,7 @@ public class AudioPlaylistAdapter extends BaseExpandableListAdapter {
Resources res = mContext.getResources();
Bitmap cover = AudioUtil.getCover(v.getContext(), list.get(0), 64);
- holder.cover.setImageBitmap(cover);
+ holder.cover.setImageBitmap(cover != null ? cover : mDefaultCover);
Util.setItemBackground(holder.layout, childPosition);
if (name != null)
More information about the Android
mailing list