From 1fd0c140dfa434cb55a7816056d7bfea0f3b2c22 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 14 Nov 2012 21:05:09 -0800 Subject: On delete cache don't pop back to the top of the list --- .../res/layout/select_album_header.xml | 122 ++++++++++----------- .../dsub/activity/SelectAlbumActivity.java | 39 +++++++ 2 files changed, 95 insertions(+), 66 deletions(-) (limited to 'subsonic-android') diff --git a/subsonic-android/res/layout/select_album_header.xml b/subsonic-android/res/layout/select_album_header.xml index 7f5fb767..6905d421 100644 --- a/subsonic-android/res/layout/select_album_header.xml +++ b/subsonic-android/res/layout/select_album_header.xml @@ -1,69 +1,59 @@ + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java index 9561500f..877a9452 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java @@ -39,7 +39,9 @@ import github.daneren2005.dsub.service.MusicServiceFactory; import github.daneren2005.dsub.util.*; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class SelectAlbumActivity extends SubsonicTabActivity { @@ -553,6 +555,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { if (songCount > 0) { getImageLoader().loadImage(getSupportActionBar(), entries.get(0)); + entryList.addHeaderView(createHeader(entries), null, false); entryList.addFooterView(footer); } else { hideButtons = true; @@ -569,4 +572,40 @@ public class SelectAlbumActivity extends SubsonicTabActivity { } } } + + private View createHeader(List entries) { + View header = LayoutInflater.from(this).inflate(R.layout.select_album_header, entryList, false); + + View coverArtView = header.findViewById(R.id.select_album_art); + getImageLoader().loadImage(coverArtView, entries.get(0), true, true); + + TextView titleView = (TextView) header.findViewById(R.id.select_album_title); + titleView.setText(getTitle()); + + int songCount = 0; + + Set artists = new HashSet(); + for (MusicDirectory.Entry entry : entries) { + if (!entry.isDirectory()) { + songCount++; + if (entry.getArtist() != null) { + artists.add(entry.getArtist()); + } + } + } + + TextView artistView = (TextView) header.findViewById(R.id.select_album_artist); + if (artists.size() == 1) { + artistView.setText(artists.iterator().next()); + artistView.setVisibility(View.VISIBLE); + } else { + artistView.setVisibility(View.GONE); + } + + TextView songCountView = (TextView) header.findViewById(R.id.select_album_song_count); + String s = getResources().getQuantityString(R.plurals.select_album_n_songs, songCount, songCount); + songCountView.setText(s.toUpperCase()); + + return header; + } } -- cgit v1.2.3