Commit 4b925f5b authored by Geoffrey Métais's avatar Geoffrey Métais

Refactor playlist display

parent 3130dd40
......@@ -139,9 +139,10 @@
<android.support.v7.widget.RecyclerView
android:id="@+id/songs_list"
android:layout_width="match_parent"
style="@style/PlaylistStyle"
android:layout_height="match_parent"
android:clipToPadding="false"
android:layout_gravity="center_horizontal"
android:background="?attr/background_default"
android:paddingBottom="@dimen/listview_bottom_padding" />
......
......@@ -14,7 +14,6 @@
<variable
name="subTitle"
type="String"/>
type="int"/>
<variable
name="titleColor"
type="int"/>
......@@ -24,9 +23,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="3dip"
android:layout_marginBottom="3dip"
android:layout_marginLeft="5dip"
android:layout_margin="5dip"
android:clickable="true"
android:onClick="@{holder.onClick}" >
<TextView
......@@ -36,14 +33,15 @@
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/length"
android:layout_toLeftOf="@+id/item_more"
android:layout_toStartOf="@+id/item_more"
android:layout_above="@+id/audio_item_subtitle"
android:maxLines="@{TextUtils.isEmpty(subTitle) ? 2 : 1}"
android:ellipsize="middle"
android:text="@{media.title}"
android:textColor="@{titleColor}"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textSize="16sp" />
<TextView
......@@ -54,23 +52,16 @@
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/length"
android:layout_toLeftOf="@+id/item_more"
android:layout_toStartOf="@+id/item_more"
android:singleLine="true"
android:ellipsize="middle"
android:textColor="?attr/list_subtitle"
android:fontFamily="sans-serif-light"
android:textSize="12sp"
android:visibility="@{TextUtils.isEmpty(subTitle) ? View.GONE : View.VISIBLE}"/>
<TextView
android:id="@+id/length"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/item_more"
android:layout_marginRight="5dip"
android:gravity="center_vertical"
android:text="@{Strings.millisToString(media.length)}"
android:visibility="@{media.length > 0 ? View.VISIBLE : View.GONE}"/>
<ImageView
android:id="@+id/item_more"
......@@ -80,6 +71,7 @@
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignBottom="@id/audio_item_subtitle"
android:layout_alignTop="@id/audio_item_title"
android:scaleType="center"
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Playlist-->
<style name="PlaylistStyle">
<item name="android:layout_width">800dp</item>
</style>
</resources>
\ No newline at end of file
......@@ -256,4 +256,10 @@
<style name="TipsFontStyle.Small" parent="TipsFontStyle">
<item name="android:textSize">10sp</item>
</style>
<!-- Playlist-->
<style name="PlaylistStyle">
<item name="android:layout_width">match_parent</item>
</style>
</resources>
......@@ -80,10 +80,10 @@ public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHo
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Context ctx = holder.itemView.getContext();
final Context ctx = holder.itemView.getContext();
final MediaWrapper media = getItem(position);
holder.binding.setMedia(media);
holder.binding.setSubTitle(MediaUtils.getMediaSubtitle(ctx, media));
holder.binding.setSubTitle(MediaUtils.getMediaSubtitle(media));
holder.binding.setTitleColor(mCurrentIndex == position
? UiTools.getColorFromAttribute(ctx, R.attr.list_title_last)
: UiTools.getColorFromAttribute(ctx, R.attr.list_title));
......
......@@ -9,6 +9,7 @@ import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.PlaybackService;
......@@ -154,13 +155,17 @@ public class MediaUtils {
return genre != null ? genre : getMediaString(ctx, R.string.unknown_genre);
}
public static String getMediaSubtitle(Context ctx, MediaWrapper media) {
if (media.getType() == MediaWrapper.TYPE_AUDIO)
return media.getNowPlaying() != null
? media.getNowPlaying()
: getMediaArtist(ctx, media) + " - " + getMediaAlbum(ctx, media);
else
return "";
public static String getMediaSubtitle(MediaWrapper media) {
String subtitle = media.getNowPlaying() != null
? media.getNowPlaying()
: media.getArtist();
if (media.getLength() > 0L) {
if (TextUtils.isEmpty(subtitle))
subtitle = Strings.millisToString(media.getLength());
else
subtitle = subtitle + " - " + Strings.millisToString(media.getLength());
}
return subtitle;
}
public static String getMediaTitle(MediaWrapper mediaWrapper){
......
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