aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java50
-rw-r--r--src/github/daneren2005/dsub/fragments/SimilarArtistFragment.java2
-rw-r--r--src/github/daneren2005/dsub/service/CachedMusicService.java6
-rw-r--r--src/github/daneren2005/dsub/service/MusicService.java2
-rw-r--r--src/github/daneren2005/dsub/service/OfflineMusicService.java2
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java3
-rw-r--r--src/github/daneren2005/dsub/util/ImageLoader.java3
7 files changed, 54 insertions, 14 deletions
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