Add in album button that will in future add all album songs to queue. Add more details into track listing.
This commit is contained in:
@@ -16,6 +16,12 @@ public class TracksAdapter extends RealmBaseAdapter<Track> {
|
||||
super(context, realmResults, automaticUpdate);
|
||||
}
|
||||
|
||||
private String convertSecondsToTrackTime(long seconds) {
|
||||
int fullMinutes = (int) Math.floor(seconds/60);
|
||||
int leftSeconds = (int) (seconds%60);
|
||||
return fullMinutes+":"+String.format("%02d",leftSeconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if(convertView == null) {
|
||||
@@ -23,6 +29,12 @@ public class TracksAdapter extends RealmBaseAdapter<Track> {
|
||||
}
|
||||
TextView trackName = (TextView) convertView.findViewById(R.id.track_name);
|
||||
trackName.setText(realmResults.get(position).getTrackname());
|
||||
|
||||
TextView trackNum = (TextView) convertView.findViewById(R.id.track_num);
|
||||
trackNum.setText(String.valueOf(realmResults.get(position).getTracknumber()));
|
||||
|
||||
TextView trackLength = (TextView) convertView.findViewById(R.id.track_length);
|
||||
trackLength.setText(convertSecondsToTrackTime(realmResults.get(position).getSeconds()));
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.magnatune.eyecreate.companionformagnatune.fragments;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -7,6 +8,7 @@ import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -16,6 +18,7 @@ import android.widget.ImageView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.magnatune.eyecreate.companionformagnatune.R;
|
||||
import com.magnatune.eyecreate.companionformagnatune.adapters.TracksAdapter;
|
||||
@@ -81,6 +84,16 @@ public class AlbumFragment extends Fragment {
|
||||
Album currentAlbum = db.where(Album.class).equalTo("albumsku",getArguments().getString(ARG_ALBUM_ID)).findFirst();
|
||||
((TextView)v.findViewById(R.id.album_name)).setText(currentAlbum.getAlbumname());
|
||||
((TextView)v.findViewById(R.id.artist_name)).setText(currentAlbum.getArtist().getArtistname());
|
||||
//Set up hint for button like in menu items
|
||||
v.findViewById(R.id.queue_album).setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
Toast hint = Toast.makeText(view.getContext(),R.string.queue_album,Toast.LENGTH_SHORT);
|
||||
hint.setGravity(Gravity.TOP|Gravity.RIGHT,25,20);
|
||||
hint.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
Picasso.with(getActivity()).load(currentAlbum.getCover_small()).into((ImageView) v.findViewById(R.id.album_cover), new Callback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
@@ -95,6 +108,13 @@ public class AlbumFragment extends Fragment {
|
||||
}
|
||||
if (swatch != null) {
|
||||
((TextView) v.findViewById(R.id.album_name)).setTextColor(swatch.getTitleTextColor());
|
||||
((TextView) v.findViewById(R.id.queue_album)).setTextColor(swatch.getTitleTextColor());
|
||||
|
||||
//Get a slightly off color for button background.
|
||||
float[] modColor = swatch.getHsl();
|
||||
modColor[2] = (float) (modColor[2]<=0.5?modColor[2]+0.1:modColor[2]-0.1);
|
||||
v.findViewById(R.id.queue_album).setBackgroundColor(Color.HSVToColor(modColor));
|
||||
|
||||
((TextView) v.findViewById(R.id.artist_name)).setTextColor(swatch.getBodyTextColor());
|
||||
v.findViewById(R.id.album_details).setBackgroundColor(swatch.getRgb());
|
||||
}
|
||||
@@ -105,7 +125,7 @@ public class AlbumFragment extends Fragment {
|
||||
|
||||
}
|
||||
});
|
||||
TracksAdapter adapter = new TracksAdapter(getActivity(),db.where(Track.class).equalTo("albumname",currentAlbum.getAlbumname()).equalTo("artist",currentAlbum.getArtist().getArtistname()).findAll(),true);
|
||||
TracksAdapter adapter = new TracksAdapter(getActivity(),db.where(Track.class).equalTo("albumname",currentAlbum.getAlbumname()).equalTo("artist",currentAlbum.getArtist().getArtistname()).findAllSorted("tracknumber"),true);
|
||||
listView.setAdapter(adapter);
|
||||
setListViewHeightBasedOnChildren(listView);
|
||||
return v;
|
||||
|
||||
@@ -43,6 +43,18 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="+"
|
||||
android:textSize="30sp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:id="@+id/queue_album"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:orientation="horizontal" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:layout_margin="5dp"
|
||||
android:id="@+id/track_num"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/track_name"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:layout_margin="5dp"
|
||||
android:id="@+id/track_length"/>
|
||||
</LinearLayout>
|
||||
@@ -7,4 +7,6 @@
|
||||
|
||||
<string name="artists">Artists</string>
|
||||
<string name="albums">Albums</string>
|
||||
|
||||
<string name="queue_album">Queue Album</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user