Commit 2f7ab538 authored by Sébastien Toque's avatar Sébastien Toque

show covers in audio lists

parent 5c3871f3
......@@ -3,29 +3,42 @@
android:id="@+id/layout_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical" >
android:orientation="horizontal" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:text="@string/title"
android:textColor="@color/list_title"
android:textSize="20dip" />
<ImageView
android:id="@+id/cover"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center" />
<TextView
android:id="@+id/artist"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="5dip"
android:text="@string/artist"
android:textColor="@color/list_subtitle"
android:textSize="14dip" />
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:text="@string/title"
android:textColor="@color/list_title"
android:textSize="20dip" />
<TextView
android:id="@+id/artist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:text="@string/artist"
android:textColor="@color/list_subtitle"
android:textSize="14dip" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -5,6 +5,12 @@
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/cover"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
......
......@@ -11,6 +11,12 @@
android:layout_marginLeft="5dip"
android:background="@color/orange" />
<ImageView
android:id="@+id/cover"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
......
......@@ -29,10 +29,12 @@ import org.videolan.vlc.Util;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class AudioListAdapter extends ArrayAdapter<Media> {
......@@ -77,6 +79,7 @@ public class AudioListAdapter extends ArrayAdapter<Media> {
v = inflater.inflate(R.layout.audio_browser_item, parent, false);
holder = new ViewHolder();
holder.layout = (View) v.findViewById(R.id.layout_item);
holder.cover = (ImageView) v.findViewById(R.id.cover);
holder.title = (TextView) v.findViewById(R.id.title);
holder.artist = (TextView) v.findViewById(R.id.artist);
v.setTag(holder);
......@@ -84,6 +87,10 @@ public class AudioListAdapter extends ArrayAdapter<Media> {
holder = (ViewHolder) v.getTag();
Media media = getItem(position);
Bitmap cover = AudioUtil.getCover(v.getContext(), media, 64);
holder.cover.setImageBitmap(cover);
Util.setItemBackground(holder.layout, position);
holder.title.setText(media.getTitle());
ColorStateList titleColor = v.getResources().getColorStateList(mCurrentIndex == position
......@@ -111,6 +118,7 @@ public class AudioListAdapter extends ArrayAdapter<Media> {
static class ViewHolder {
View layout;
ImageView cover;
TextView title;
TextView artist;
}
......
......@@ -30,6 +30,7 @@ import org.videolan.vlc.Util;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -152,6 +153,7 @@ public class AudioPlaylistAdapter extends BaseExpandableListAdapter {
v = mInflater.inflate(R.layout.audio_browser_playlist, parent, false);
holder = new GroupViewHolder();
holder.layout = (View) v.findViewById(R.id.layout_item);
holder.cover = (ImageView) v.findViewById(R.id.cover);
holder.title = (TextView) v.findViewById(R.id.title);
holder.text = (TextView) v.findViewById(R.id.text);
holder.more = (ImageView) v.findViewById(R.id.more);
......@@ -161,9 +163,13 @@ public class AudioPlaylistAdapter extends BaseExpandableListAdapter {
String name = mTitles.get(groupPosition);
int count = mSubTitles.get(name).size();
int countMedia = mGroups.get(name).get(null).size();
ArrayList<Media> list = mGroups.get(name).get(null);
int countMedia = list.size();
Resources res = mContext.getResources();
Bitmap cover = AudioUtil.getCover(v.getContext(), list.get(0), 64);
holder.cover.setImageBitmap(cover);
Util.setItemBackground(holder.layout, groupPosition);
holder.title.setText(name);
if (count > 2)
......@@ -189,6 +195,7 @@ public class AudioPlaylistAdapter extends BaseExpandableListAdapter {
v = mInflater.inflate(R.layout.audio_browser_playlist_child, parent, false);
holder = new ChildViewHolder();
holder.layout = (View) v.findViewById(R.id.layout_item);
holder.cover = (ImageView) v.findViewById(R.id.cover);
holder.title = (TextView) v.findViewById(R.id.title);
holder.text = (TextView) v.findViewById(R.id.text);
v.setTag(holder);
......@@ -201,6 +208,9 @@ public class AudioPlaylistAdapter extends BaseExpandableListAdapter {
int count = list.size();
Resources res = mContext.getResources();
Bitmap cover = AudioUtil.getCover(v.getContext(), list.get(0), 64);
holder.cover.setImageBitmap(cover);
Util.setItemBackground(holder.layout, childPosition);
if (name != null)
holder.title.setText(name);
......@@ -213,6 +223,7 @@ public class AudioPlaylistAdapter extends BaseExpandableListAdapter {
static class GroupViewHolder {
View layout;
ImageView cover;
TextView title;
TextView text;
ImageView more;
......@@ -220,6 +231,7 @@ public class AudioPlaylistAdapter extends BaseExpandableListAdapter {
static class ChildViewHolder {
View layout;
ImageView cover;
TextView title;
TextView text;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment