diff options
9 files changed, 185 insertions, 105 deletions
diff --git a/res/layout/select_album_header.xml b/res/layout/select_album_header.xml index f9eff4e8..d028a476 100644 --- a/res/layout/select_album_header.xml +++ b/res/layout/select_album_header.xml @@ -1,114 +1,153 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/select_album_header" - android:layout_width="fill_parent" - android:layout_height="wrap_content"> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/select_album_header_wrapper" + android:layout_height="wrap_content" + android:layout_width="fill_parent"> - <LinearLayout - android:id="@+id/select_album_text_layout" + <RelativeLayout + android:id="@+id/select_album_header" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:layout_toRightOf="@+id/select_album_art" - android:orientation="vertical" - android:layout_centerVertical="true"> + android:layout_gravity="top"> - <TextView - android:text="This is the album title" - android:id="@+id/select_album_title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceLarge" - android:textStyle="bold" - android:singleLine="true" - android:ellipsize="marquee" - android:marqueeRepeatLimit="marquee_forever" - android:scrollHorizontally="true" - android:focusable="true" - android:focusableInTouchMode="true"> - - <requestFocus android:focusable="true" - android:focusableInTouchMode="true" - android:duplicateParentState="true" /> - </TextView> - - <TextView - android:text="This is the artist name" - android:id="@+id/select_album_artist" - android:layout_width="wrap_content" + <LinearLayout + android:id="@+id/select_album_text_layout" + android:layout_width="fill_parent" android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:singleLine="true" - android:ellipsize="end"/> + android:layout_toRightOf="@+id/select_album_art" + android:orientation="vertical" + android:layout_centerVertical="true"> - <TextView - android:text="XX SONGS" - android:id="@+id/select_album_song_count" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:paddingTop="14dip" - android:textAppearance="?android:attr/textAppearanceSmall" - android:singleLine="true" - android:ellipsize="none"/> - - <TextView - android:text="0:00" - android:id="@+id/select_album_song_length" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceSmall" - android:singleLine="true" - android:ellipsize="none"/> + <TextView + android:text="This is the album title" + android:id="@+id/select_album_title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textStyle="bold" + android:singleLine="true" + android:ellipsize="marquee" + android:marqueeRepeatLimit="marquee_forever" + android:scrollHorizontally="true" + android:focusable="true" + android:focusableInTouchMode="true"> - </LinearLayout> + <requestFocus android:focusable="true" + android:focusableInTouchMode="true" + android:duplicateParentState="true" /> + </TextView> - <LinearLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentBottom="true" - android:layout_alignParentRight="true" - android:padding="10dip"> + <TextView + android:text="This is the artist name" + android:id="@+id/select_album_artist" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceMedium" + android:singleLine="true" + android:ellipsize="end"/> + + <TextView + android:text="XX SONGS" + android:id="@+id/select_album_song_count" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingTop="14dip" + android:textAppearance="?android:attr/textAppearanceSmall" + android:singleLine="true" + android:ellipsize="none"/> + + <TextView + android:text="0:00" + android:id="@+id/select_album_song_length" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceSmall" + android:singleLine="true" + android:ellipsize="none"/> + + </LinearLayout> <LinearLayout - android:id="@+id/select_album_rate_wrapper" android:layout_width="wrap_content" - android:layout_height="fill_parent"> + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentRight="true" + android:padding="10dip"> + + <LinearLayout + android:id="@+id/select_album_rate_wrapper" + android:layout_width="wrap_content" + android:layout_height="fill_parent"> - <RatingBar - android:id="@+id/select_album_rate" + <RatingBar + android:id="@+id/select_album_rate" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:numStars="5" + style="@android:style/Widget.Holo.RatingBar.Small" + android:layout_gravity="center_vertical"/> + </LinearLayout> + + <ImageButton + android:id="@+id/select_album_star" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:numStars="5" - style="@android:style/Widget.Holo.RatingBar.Small" + style="@style/BasicButton" + android:src="@android:drawable/star_big_off" + android:layout_gravity="center_vertical"/> + + <ImageView + android:id="@+id/select_album_share" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:scaleType="fitCenter" + android:src="?attr/share" + style="@style/BasicButton" android:layout_gravity="center_vertical"/> </LinearLayout> - <ImageButton - android:id="@+id/select_album_star" + <github.daneren2005.dsub.view.RecyclingImageView + android:id="@+id/select_album_art" + android:layout_width="@dimen/AlbumArt.Header" + android:layout_height="@dimen/AlbumArt.Header" + android:layout_alignParentTop="true" + android:layout_alignParentLeft="true" + android:layout_marginRight="10dip" + android:scaleType="fitCenter" + android:contentDescription="@null"/> + </RelativeLayout> + + <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/header_progress" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:clickable="true" + android:visibility="gone" + android:layout_gravity="top"> + + <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" - style="@style/BasicButton" - android:src="@android:drawable/star_big_off" - android:layout_gravity="center_vertical"/> + android:orientation="vertical" + android:layout_gravity="center"> - <ImageView - android:id="@+id/select_album_share" - android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:scaleType="fitCenter" - android:src="?attr/share" - style="@style/BasicButton" - android:layout_gravity="center_vertical"/> - </LinearLayout> - - <github.daneren2005.dsub.view.RecyclingImageView - android:id="@+id/select_album_art" - android:layout_width="@dimen/AlbumArt.Header" - android:layout_height="@dimen/AlbumArt.Header" - android:layout_alignParentTop="true" - android:layout_alignParentLeft="true" - android:layout_marginRight="10dip" - android:scaleType="fitCenter" - android:contentDescription="@null"/> -</RelativeLayout> + <ProgressBar + android:id="@+id/tab_progress_spinner" + style="?android:attr/progressBarStyleLarge" + android:layout_gravity="center_horizontal" + android:layout_marginRight="6dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + + <TextView + android:id="@+id/tab_progress_message" + android:text="@string/progress.artist_info" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:textAppearance="?android:attr/textAppearanceMedium"/> + </LinearLayout> + </FrameLayout> +</FrameLayout> diff --git a/res/values/strings.xml b/res/values/strings.xml index 7b6b3c5c..352d90c2 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -133,6 +133,7 @@ <string name="search.more">Show more</string>
<string name="progress.wait">Please wait...</string>
+ <string name="progress.artist_info">Loading Artist Bio</string>
<string name="music_library.label">Media library</string>
<string name="music_library.label_offline">Offline media</string>
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index e91dec41..cfb3af69 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -55,6 +55,7 @@ import github.daneren2005.dsub.service.ServerTooOldException; import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.LoadingTask;
import github.daneren2005.dsub.util.Pair;
+import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.util.TabBackgroundTask;
import github.daneren2005.dsub.util.UserUtil;
import github.daneren2005.dsub.util.Util;
@@ -81,7 +82,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter private boolean albumContext = false;
private boolean addAlbumHeader = false;
private LoadTask currentTask;
- ArtistInfo artistInfo;
+ private ArtistInfo artistInfo;
+ private String artistInfoDelayed;
String id;
String name;
@@ -705,7 +707,11 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter artistId = id.substring(0, id.indexOf(';'));
}
- artistInfo = musicService.getArtistInfo(artistId, refresh, context, this);
+ artistInfo = musicService.getArtistInfo(artistId, refresh, false, context, this);
+
+ if(artistInfo == null) {
+ artistInfoDelayed = artistId;
+ }
} catch(Exception e) {
Log.w(TAG, "Failed to get Artist Info even though it should be supported");
}
@@ -725,8 +731,43 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter // Show header if not album list type and not root and not artist
// For Subsonic 5.1+ display a header for artists with getArtistInfo data if it exists
View header = null;
- if(albumListType == null && !"root".equals(id) && (!artist || artistInfo != null)) {
+ if(albumListType == null && !"root".equals(id) && (!artist || artistInfo != null || artistInfoDelayed != null)) {
header = createHeader();
+
+ if(header != null && artistInfoDelayed != null) {
+ final View finalHeader = header.findViewById(R.id.select_album_header);
+ final View headerProgress = header.findViewById(R.id.header_progress);
+
+ finalHeader.setVisibility(View.INVISIBLE);
+ headerProgress.setVisibility(View.VISIBLE);
+
+ new SilentBackgroundTask<Void>(context) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ artistInfo = musicService.getArtistInfo(artistInfoDelayed, false, true, context, this);
+
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ /*if(albumList instanceof HeaderGridView) {
+ HeaderGridView headerGridView = (HeaderGridView) albumList;
+ headerGridView.invalidateRowHeight();
+ ((BaseAdapter) headerGridView.getAdapter()).notifyDataSetChanged();
+ }*/
+
+ setupCoverArt(finalHeader);
+ setupTextDisplay(finalHeader);
+ setupButtonEvents(finalHeader);
+
+ finalHeader.setVisibility(View.VISIBLE);
+ headerProgress.setVisibility(View.GONE);
+ }
+ }.execute();
+ }
+
// Only add header to entry list if we aren't going recreate album grid as root anyways
if(header != null && entryList != null && (!addAlbumHeader || entries.size() > 0)) {
entryList.addHeaderView(header, null, false);
@@ -1300,7 +1341,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
private View createHeader() {
- View header = entryList.findViewById(R.id.select_album_header);
+ View header = entryList.findViewById(R.id.select_album_header_wrapper);
boolean add = false;
if(header == null) {
header = LayoutInflater.from(context).inflate(R.layout.select_album_header, entryList, false);
@@ -1415,6 +1456,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter final TextView artistView = (TextView) header.findViewById(R.id.select_album_artist);
if(podcastDescription != null || artistInfo != null) {
+ artistView.setVisibility(View.VISIBLE);
String text = podcastDescription != null ? podcastDescription : artistInfo.getBiography();
Spanned spanned = null;
if(text != null) {
diff --git a/src/github/daneren2005/dsub/fragments/SimilarArtistFragment.java b/src/github/daneren2005/dsub/fragments/SimilarArtistFragment.java index b87db495..79e759cc 100644 --- a/src/github/daneren2005/dsub/fragments/SimilarArtistFragment.java +++ b/src/github/daneren2005/dsub/fragments/SimilarArtistFragment.java @@ -115,7 +115,7 @@ public class SimilarArtistFragment extends SelectListFragment<Artist> { @Override public List<Artist> getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception { - info = musicService.getArtistInfo(artistId, refresh, context, listener); + info = musicService.getArtistInfo(artistId, refresh, true, context, listener); return info.getSimilarArtists(); } diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java index c4552e18..61d6205a 100644 --- a/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -963,15 +963,15 @@ public class CachedMusicService implements MusicService { } @Override - public ArtistInfo getArtistInfo(String id, boolean refresh, Context context, ProgressListener progressListener) throws Exception { + public ArtistInfo getArtistInfo(String id, boolean refresh, boolean allowNetwork, Context context, ProgressListener progressListener) throws Exception { String cacheName = getCacheName(context, "artistInfo", id); ArtistInfo info = null; if(!refresh) { info = FileUtil.deserialize(context, cacheName, ArtistInfo.class); } - if(info == null) { - info = musicService.getArtistInfo(id, refresh, context, progressListener); + if(info == null && allowNetwork) { + info = musicService.getArtistInfo(id, refresh, allowNetwork, context, progressListener); FileUtil.serialize(context, info, cacheName); } diff --git a/src/github/daneren2005/dsub/service/MusicService.java b/src/github/daneren2005/dsub/service/MusicService.java index 95b1bde6..4d014462 100644 --- a/src/github/daneren2005/dsub/service/MusicService.java +++ b/src/github/daneren2005/dsub/service/MusicService.java @@ -181,7 +181,7 @@ public interface MusicService { Bitmap getAvatar(String username, int size, Context context, ProgressListener progressListener, SilentBackgroundTask task) throws Exception; - ArtistInfo getArtistInfo(String id, boolean refresh, Context context, ProgressListener progressListener) throws Exception; + ArtistInfo getArtistInfo(String id, boolean refresh, boolean allowNetwork, Context context, ProgressListener progressListener) throws Exception; Bitmap getBitmap(String url, int size, Context context, ProgressListener progressListener, SilentBackgroundTask task) throws Exception; diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java index 8b38d061..b4105d07 100644 --- a/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -790,7 +790,7 @@ public class OfflineMusicService implements MusicService { } @Override - public ArtistInfo getArtistInfo(String id, boolean refresh, Context context, ProgressListener progressListener) throws Exception { + public ArtistInfo getArtistInfo(String id, boolean refresh, boolean allowNetwork, Context context, ProgressListener progressListener) throws Exception { throw new OfflineException(ERRORMSG); } diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java index 7a7eb7af..459c8c9e 100644 --- a/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -92,7 +92,6 @@ import github.daneren2005.dsub.service.parser.SearchResult2Parser; import github.daneren2005.dsub.service.parser.SearchResultParser; import github.daneren2005.dsub.service.parser.ShareParser; import github.daneren2005.dsub.service.parser.StarredListParser; -import github.daneren2005.dsub.service.parser.SubsonicRESTException; import github.daneren2005.dsub.service.parser.UserParser; import github.daneren2005.dsub.service.parser.VideosParser; import github.daneren2005.dsub.service.ssl.SSLSocketFactory; @@ -1508,7 +1507,7 @@ public class RESTMusicService implements MusicService { } @Override - public ArtistInfo getArtistInfo(String id, boolean refresh, Context context, ProgressListener progressListener) throws Exception { + public ArtistInfo getArtistInfo(String id, boolean refresh, boolean allowNetwork, Context context, ProgressListener progressListener) throws Exception { checkServerVersion(context, "1.11", "Getting artist info is not supported"); Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getArtistInfo2" : "getArtistInfo", null, Arrays.asList("id", "includeNotPresent"), Arrays.<Object>asList(id, "true")); diff --git a/src/github/daneren2005/dsub/util/ImageLoader.java b/src/github/daneren2005/dsub/util/ImageLoader.java index ce2035d4..1a0e8242 100644 --- a/src/github/daneren2005/dsub/util/ImageLoader.java +++ b/src/github/daneren2005/dsub/util/ImageLoader.java @@ -25,7 +25,6 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.LinearGradient; import android.graphics.Paint; -import android.graphics.Rect; import android.graphics.Shader; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; @@ -458,7 +457,7 @@ public class ImageLoader { @Override protected Void doInBackground() throws Throwable { MusicService musicService = MusicServiceFactory.getMusicService(mContext); - ArtistInfo artistInfo = musicService.getArtistInfo(mEntry.getId(), false, mContext, null); + ArtistInfo artistInfo = musicService.getArtistInfo(mEntry.getId(), false, true, mContext, null); String url = artistInfo.getImageUrl(); // Figure out whether we are going to get a artist image or the standard image |