aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicActivity.java3
-rw-r--r--src/github/daneren2005/dsub/domain/MusicDirectory.java10
-rw-r--r--src/github/daneren2005/dsub/domain/ServerInfo.java4
-rw-r--r--src/github/daneren2005/dsub/fragments/NowPlayingFragment.java7
-rw-r--r--src/github/daneren2005/dsub/provider/DSubWidgetProvider.java21
-rw-r--r--src/github/daneren2005/dsub/service/CachedMusicService.java9
-rw-r--r--src/github/daneren2005/dsub/service/DownloadFile.java4
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java10
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java15
-rw-r--r--src/github/daneren2005/dsub/service/MusicService.java4
-rw-r--r--src/github/daneren2005/dsub/service/OfflineMusicService.java4
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java34
-rw-r--r--src/github/daneren2005/dsub/util/FileUtil.java13
-rw-r--r--src/github/daneren2005/dsub/util/ImageLoader.java4
-rw-r--r--src/github/daneren2005/dsub/util/Notifications.java2
-rw-r--r--src/github/daneren2005/dsub/util/Util.java4
16 files changed, 102 insertions, 46 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
index 0c1a2c9a..6544b685 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -60,6 +60,7 @@ import java.util.List;
import java.util.Locale;
import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.fragments.SubsonicFragment;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.util.Constants;
@@ -395,7 +396,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
private void populateDrawer() {
SharedPreferences prefs = Util.getPreferences(this);
boolean podcastsEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_PODCASTS_ENABLED, true);
- boolean bookmarksEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_BOOKMARKS_ENABLED, true) && !Util.isOffline(this);
+ boolean bookmarksEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_BOOKMARKS_ENABLED, true) && !Util.isOffline(this) && ServerInfo.canBookmark(this);
boolean sharedEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_SHARED_ENABLED, true) && !Util.isOffline(this);
boolean chatEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_CHAT_ENABLED, true) && !Util.isOffline(this);
boolean adminEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_ADMIN_ENABLED, true) && !Util.isOffline(this);
diff --git a/src/github/daneren2005/dsub/domain/MusicDirectory.java b/src/github/daneren2005/dsub/domain/MusicDirectory.java
index c7e00719..79472a89 100644
--- a/src/github/daneren2005/dsub/domain/MusicDirectory.java
+++ b/src/github/daneren2005/dsub/domain/MusicDirectory.java
@@ -73,9 +73,11 @@ public class MusicDirectory implements Serializable {
this.parent = parent;
}
- public void addChild(Entry child) {
- children.add(child);
- }
+ public void addChild(Entry child) {
+ if(child != null) {
+ children.add(child);
+ }
+ }
public void addChildren(List<Entry> children) {
this.children.addAll(children);
}
@@ -95,7 +97,7 @@ public class MusicDirectory implements Serializable {
List<Entry> result = new ArrayList<Entry>(children.size());
for (Entry child : children) {
- if (child.isDirectory() && includeDirs || !child.isDirectory() && includeFiles) {
+ if (child != null && child.isDirectory() && includeDirs || !child.isDirectory() && includeFiles) {
result.add(child);
}
}
diff --git a/src/github/daneren2005/dsub/domain/ServerInfo.java b/src/github/daneren2005/dsub/domain/ServerInfo.java
index 4dcc8074..9e1333da 100644
--- a/src/github/daneren2005/dsub/domain/ServerInfo.java
+++ b/src/github/daneren2005/dsub/domain/ServerInfo.java
@@ -187,4 +187,8 @@ public class ServerInfo implements Serializable {
private static String getCacheName(Context context, int instance) {
return "server-" + Util.getRestUrl(context, null, instance, false).hashCode() + ".ser";
}
+
+ public static boolean canBookmark(Context context) {
+ return checkServerVersion(context, "1.9");
+ }
}
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
index 903673b8..ac197161 100644
--- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
+++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
@@ -58,6 +58,7 @@ import github.daneren2005.dsub.activity.SubsonicFragmentActivity;
import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.PlayerState;
import github.daneren2005.dsub.domain.RepeatMode;
+import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.MusicService;
@@ -934,7 +935,11 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
rateBadButton.setVisibility(View.GONE);
rateGoodButton.setVisibility(View.GONE);
} else {
- bookmarkButton.setVisibility(View.VISIBLE);
+ if(ServerInfo.canBookmark(context)) {
+ bookmarkButton.setVisibility(View.VISIBLE);
+ } else {
+ bookmarkButton.setVisibility(View.GONE);
+ }
rateBadButton.setVisibility(View.VISIBLE);
rateGoodButton.setVisibility(View.VISIBLE);
}
diff --git a/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java b/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java
index d66bc0ec..f6b28b21 100644
--- a/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java
+++ b/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java
@@ -44,8 +44,11 @@ import github.daneren2005.dsub.activity.DownloadActivity;
import github.daneren2005.dsub.activity.SubsonicActivity;
import github.daneren2005.dsub.activity.SubsonicFragmentActivity;
import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.DownloadService;
+import github.daneren2005.dsub.service.DownloadServiceLifecycleSupport;
import github.daneren2005.dsub.util.Constants;
+import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.util.Util;
@@ -88,6 +91,11 @@ public class DSubWidgetProvider extends AppWidgetProvider {
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
defaultAppWidget(context, appWidgetIds);
}
+
+ @Override
+ public void onEnabled(Context context) {
+ notifyInstances(context, DownloadService.getInstance(), false);
+ }
protected int getLayout() {
return 0;
@@ -155,7 +163,18 @@ public class DSubWidgetProvider extends AppWidgetProvider {
}
}
- MusicDirectory.Entry currentPlaying = service.getCurrentPlaying() == null ? null : service.getCurrentPlaying().getSong();
+ // Get Entry from current playing DownloadFile
+ MusicDirectory.Entry currentPlaying = null;
+ if(service == null) {
+ // Deserialize from playling list to setup
+ DownloadServiceLifecycleSupport.State state = FileUtil.deserialize(context, DownloadServiceLifecycleSupport.FILENAME_DOWNLOADS_SER, DownloadServiceLifecycleSupport.State.class);
+ if(state != null && state.currentPlayingIndex != -1) {
+ currentPlaying = state.songs.get(state.currentPlayingIndex);
+ }
+ } else {
+ currentPlaying = service.getCurrentPlaying() == null ? null : service.getCurrentPlaying().getSong();
+ }
+
String title = currentPlaying == null ? null : currentPlaying.getTitle();
CharSequence artist = currentPlaying == null ? null : currentPlaying.getArtist();
CharSequence album = currentPlaying == null ? null : currentPlaying.getAlbum();
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java
index 1e553ca2..59ed550c 100644
--- a/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -30,7 +30,6 @@ import org.apache.http.HttpResponse;
import android.content.Context;
import android.graphics.Bitmap;
-import android.util.Log;
import github.daneren2005.dsub.domain.Artist;
import github.daneren2005.dsub.domain.Bookmark;
@@ -499,8 +498,8 @@ public class CachedMusicService implements MusicService {
}
@Override
- public Bitmap getCoverArt(Context context, Entry entry, int size, ProgressListener progressListener) throws Exception {
- return musicService.getCoverArt(context, entry, size, progressListener);
+ public Bitmap getCoverArt(Context context, Entry entry, int size, ProgressListener progressListener, SilentBackgroundTask task) throws Exception {
+ return musicService.getCoverArt(context, entry, size, progressListener, task);
}
@Override
@@ -873,8 +872,8 @@ public class CachedMusicService implements MusicService {
}
@Override
- public Bitmap getAvatar(String username, int size, Context context, ProgressListener progressListener) throws Exception {
- return musicService.getAvatar(username, size, context, progressListener);
+ public Bitmap getAvatar(String username, int size, Context context, ProgressListener progressListener, SilentBackgroundTask task) throws Exception {
+ return musicService.getAvatar(username, size, context, progressListener, task);
}
@Override
diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java
index 2a1306d5..04dc537a 100644
--- a/src/github/daneren2005/dsub/service/DownloadFile.java
+++ b/src/github/daneren2005/dsub/service/DownloadFile.java
@@ -26,10 +26,8 @@ import java.io.InputStream;
import java.io.OutputStream;
import android.content.Context;
-import android.graphics.Bitmap;
import android.net.wifi.WifiManager;
import android.os.PowerManager;
-import android.util.DisplayMetrics;
import android.util.Log;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.util.Constants;
@@ -538,7 +536,7 @@ public class DownloadFile implements BufferFile {
// Check if album art already exists, don't want to needlessly load into memory
File albumArtFile = FileUtil.getAlbumArtFile(context, song);
if(!albumArtFile.exists()) {
- musicService.getCoverArt(context, song, 0, null);
+ musicService.getCoverArt(context, song, 0, null, null);
}
}
} catch (Exception x) {
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index 3b211d9c..44d63ba3 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -38,6 +38,7 @@ import github.daneren2005.dsub.domain.PlayerState;
import github.daneren2005.dsub.domain.PodcastEpisode;
import github.daneren2005.dsub.domain.RemoteControlState;
import github.daneren2005.dsub.domain.RepeatMode;
+import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.receiver.MediaButtonIntentReceiver;
import github.daneren2005.dsub.util.Notifications;
import github.daneren2005.dsub.util.SilentBackgroundTask;
@@ -987,6 +988,7 @@ public class DownloadService extends Service {
if (playerState == STARTED) {
if (remoteState != RemoteControlState.LOCAL) {
remoteController.stop();
+ setPlayerState(STOPPED);
handler.post(new Runnable() {
@Override
public void run() {
@@ -995,8 +997,8 @@ public class DownloadService extends Service {
});
} else {
mediaPlayer.pause();
+ setPlayerState(STOPPED);
}
- setPlayerState(STOPPED);
} else if(playerState == PAUSED) {
setPlayerState(STOPPED);
}
@@ -1559,14 +1561,14 @@ public class DownloadService extends Service {
playNext();
// Finished loading, delete when list is cleared
- if(downloadFile.getSong() instanceof PodcastEpisode) {
+ if (downloadFile.getSong() instanceof PodcastEpisode) {
toDelete.add(downloadFile);
}
clearCurrentBookmark(downloadFile.getSong(), true);
} else {
// If file is not completely downloaded, restart the playback from the current position.
synchronized (DownloadService.this) {
- if(downloadFile.isWorkDone()) {
+ if (downloadFile.isWorkDone()) {
// Complete was called early even though file is fully buffered
Log.i(TAG, "Requesting restart from " + pos + " of " + duration);
reset();
@@ -1911,7 +1913,7 @@ public class DownloadService extends Service {
private void checkAddBookmark() {
// Don't do anything if no current playing
- if(currentPlaying == null) {
+ if(currentPlaying == null || !ServerInfo.canBookmark(this)) {
return;
}
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index 668ca70a..13c3cea7 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -47,9 +47,8 @@ import github.daneren2005.dsub.util.Util;
* @author Sindre Mehus
*/
public class DownloadServiceLifecycleSupport {
-
private static final String TAG = DownloadServiceLifecycleSupport.class.getSimpleName();
- private static final String FILENAME_DOWNLOADS_SER = "downloadstate2.ser";
+ public static final String FILENAME_DOWNLOADS_SER = "downloadstate2.ser";
private final DownloadService downloadService;
private Looper eventLooper;
@@ -359,13 +358,13 @@ public class DownloadServiceLifecycleSupport {
}
}
- private static class State implements Serializable {
+ public static class State implements Serializable {
private static final long serialVersionUID = -6346438781062572271L;
- private List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>();
- private List<MusicDirectory.Entry> toDelete = new ArrayList<MusicDirectory.Entry>();
- private int currentPlayingIndex;
- private int currentPlayingPosition;
- private boolean renameCurrent = false;
+ public List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>();
+ public List<MusicDirectory.Entry> toDelete = new ArrayList<MusicDirectory.Entry>();
+ public int currentPlayingIndex;
+ public int currentPlayingPosition;
+ public boolean renameCurrent = false;
}
}
diff --git a/src/github/daneren2005/dsub/service/MusicService.java b/src/github/daneren2005/dsub/service/MusicService.java
index 02bfae8a..3f07e9f5 100644
--- a/src/github/daneren2005/dsub/service/MusicService.java
+++ b/src/github/daneren2005/dsub/service/MusicService.java
@@ -96,7 +96,7 @@ public interface MusicService {
String getCoverArtUrl(Context context, MusicDirectory.Entry entry) throws Exception;
- Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, ProgressListener progressListener) throws Exception;
+ Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, ProgressListener progressListener, SilentBackgroundTask task) throws Exception;
HttpResponse getDownloadInputStream(Context context, MusicDirectory.Entry song, long offset, int maxBitrate, SilentBackgroundTask task) throws Exception;
@@ -174,7 +174,7 @@ public interface MusicService {
void changePassword(String username, String password, Context context, ProgressListener progressListener) throws Exception;
- Bitmap getAvatar(String username, int size, Context context, ProgressListener progressListener) throws Exception;
+ Bitmap getAvatar(String username, int size, Context context, ProgressListener progressListener, SilentBackgroundTask task) throws Exception;
int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception;
diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java
index b62d04a1..7dd2631f 100644
--- a/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -207,7 +207,7 @@ public class OfflineMusicService implements MusicService {
}
@Override
- public Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, ProgressListener progressListener) throws Exception {
+ public Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, ProgressListener progressListener, SilentBackgroundTask task) throws Exception {
try {
return FileUtil.getAlbumArtBitmap(context, entry, size);
} catch(Exception e) {
@@ -761,7 +761,7 @@ public class OfflineMusicService implements MusicService {
}
@Override
- public Bitmap getAvatar(String username, int size, Context context, ProgressListener progressListener) throws Exception {
+ public Bitmap getAvatar(String username, int size, Context context, ProgressListener progressListener, SilentBackgroundTask task) 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 53b20634..f4571ac1 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -64,6 +64,7 @@ import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
+import android.os.Looper;
import android.util.Log;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.*;
@@ -602,7 +603,7 @@ public class RESTMusicService implements MusicService {
}
@Override
- public Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, ProgressListener progressListener) throws Exception {
+ public Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, ProgressListener progressListener, SilentBackgroundTask task) throws Exception {
// Synchronize on the entry so that we don't download concurrently for the same song.
synchronized (entry) {
@@ -619,7 +620,7 @@ public class RESTMusicService implements MusicService {
try {
List<String> parameterNames = Arrays.asList("id");
List<Object> parameterValues = Arrays.<Object>asList(entry.getCoverArt());
- HttpEntity entity = getEntityForURL(context, url, null, parameterNames, parameterValues, progressListener);
+ HttpEntity entity = getEntityForURL(context, url, null, parameterNames, parameterValues, progressListener, task);
in = entity.getContent();
Header contentEncoding = entity.getContentEncoding();
@@ -1291,7 +1292,7 @@ public class RESTMusicService implements MusicService {
}
@Override
- public Bitmap getAvatar(String username, int size, Context context, ProgressListener progressListener) throws Exception {
+ public Bitmap getAvatar(String username, int size, Context context, ProgressListener progressListener, SilentBackgroundTask task) throws Exception {
// Return silently if server is too old
if (!ServerInfo.checkServerVersion(context, "1.8")) {
return null;
@@ -1316,7 +1317,7 @@ public class RESTMusicService implements MusicService {
parameterNames = Collections.singletonList("username");
parameterValues = Arrays.<Object>asList(username);
- HttpEntity entity = getEntityForURL(context, url, null, parameterNames, parameterValues, progressListener);
+ HttpEntity entity = getEntityForURL(context, url, null, parameterNames, parameterValues, progressListener, task);
in = entity.getContent();
Header contentEncoding = entity.getContentEncoding();
if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) {
@@ -1490,9 +1491,14 @@ public class RESTMusicService implements MusicService {
return new InputStreamReader(in, Constants.UTF_8);
}
+ private HttpEntity getEntityForURL(Context context, String url, HttpParams requestParams, List<String> parameterNames,
+ List<Object> parameterValues, ProgressListener progressListener) throws Exception {
+
+ return getEntityForURL(context, url, requestParams, parameterNames, parameterValues, progressListener, null);
+ }
private HttpEntity getEntityForURL(Context context, String url, HttpParams requestParams, List<String> parameterNames,
- List<Object> parameterValues, ProgressListener progressListener) throws Exception {
- return getResponseForURL(context, url, requestParams, parameterNames, parameterValues, null, progressListener, null).getEntity();
+ List<Object> parameterValues, ProgressListener progressListener, SilentBackgroundTask task) throws Exception {
+ return getResponseForURL(context, url, requestParams, parameterNames, parameterValues, null, progressListener, task).getEntity();
}
private HttpResponse getResponseForURL(Context context, String url, HttpParams requestParams,
@@ -1516,7 +1522,7 @@ public class RESTMusicService implements MusicService {
return executeWithRetry(context, rewrittenUrl, url, requestParams, parameterNames, parameterValues, headers, progressListener, task);
}
- private HttpResponse executeWithRetry(Context context, String url, String originalUrl, HttpParams requestParams,
+ private HttpResponse executeWithRetry(final Context context, String url, String originalUrl, HttpParams requestParams,
List<String> parameterNames, List<Object> parameterValues,
List<Header> headers, ProgressListener progressListener, SilentBackgroundTask task) throws Exception {
// Strip out sensitive information from log
@@ -1544,9 +1550,19 @@ public class RESTMusicService implements MusicService {
public void onCancel() {
try {
isCancelled.set(true);
- request.abort();
+ if(Thread.currentThread() == Looper.getMainLooper().getThread()) {
+ new SilentBackgroundTask<Void>(context) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ request.abort();
+ return null;
+ }
+ }.execute();
+ } else {
+ request.abort();
+ }
} catch(Exception e) {
- Log.e(TAG, "Failed to stop http task");
+ Log.e(TAG, "Failed to stop http task", e);
}
}
});
diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java
index 60fc6031..9433043c 100644
--- a/src/github/daneren2005/dsub/util/FileUtil.java
+++ b/src/github/daneren2005/dsub/util/FileUtil.java
@@ -478,8 +478,17 @@ public class FileUtil {
if(tmp.delete()) {
return true;
} else {
- Log.w(TAG, "Failed to delete temp file");
- return false;
+ Log.w(TAG, "Failed to delete temp file, retrying");
+
+ // This should never be reached since this is a file DSub created!
+ Thread.sleep(100L);
+ tmp = new File(dir, "checkWrite");
+ if(tmp.delete()) {
+ return true;
+ } else {
+ Log.w(TAG, "Failed retry to delete temp file");
+ return false;
+ }
}
} else {
Log.w(TAG, "Temp file does not actually exist");
diff --git a/src/github/daneren2005/dsub/util/ImageLoader.java b/src/github/daneren2005/dsub/util/ImageLoader.java
index 1b91b778..ccdb3432 100644
--- a/src/github/daneren2005/dsub/util/ImageLoader.java
+++ b/src/github/daneren2005/dsub/util/ImageLoader.java
@@ -293,7 +293,7 @@ public class ImageLoader {
protected Void doInBackground() throws Throwable {
try {
MusicService musicService = MusicServiceFactory.getMusicService(mContext);
- Bitmap bitmap = musicService.getCoverArt(mContext, mEntry, mSize, null);
+ Bitmap bitmap = musicService.getCoverArt(mContext, mEntry, mSize, null, this);
String key = getKey(mEntry.getCoverArt(), mSize);
cache.put(key, bitmap);
// Make sure key is the most recently "used"
@@ -361,7 +361,7 @@ public class ImageLoader {
protected Void doInBackground() throws Throwable {
try {
MusicService musicService = MusicServiceFactory.getMusicService(mContext);
- Bitmap bitmap = musicService.getAvatar(mUsername, avatarSizeDefault, mContext, null);
+ Bitmap bitmap = musicService.getAvatar(mUsername, avatarSizeDefault, mContext, null, this);
if(bitmap != null) {
cache.put(mUsername, bitmap);
// Make sure key is the most recently "used"
diff --git a/src/github/daneren2005/dsub/util/Notifications.java b/src/github/daneren2005/dsub/util/Notifications.java
index 93db25b8..520c4a6c 100644
--- a/src/github/daneren2005/dsub/util/Notifications.java
+++ b/src/github/daneren2005/dsub/util/Notifications.java
@@ -165,7 +165,7 @@ public final class Notifications {
next = R.id.control_next;
}
- if((remote || persistent) && close == 0) {
+ if((remote || persistent) && close == 0 && expanded) {
close = R.id.notification_close;
rv.setViewVisibility(close, View.VISIBLE);
}
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index c80c0824..0b3f03b3 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -1141,7 +1141,8 @@ public final class Util {
public void onAudioFocusChange(int focusChange) {
DownloadService downloadService = (DownloadService)context;
if((focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT || focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) && !downloadService.isRemoteEnabled()) {
- if(downloadService.getPlayerState() == PlayerState.STARTED) {
+ if(downloadService.getPlayerState() == PlayerState.STARTED) {
+ Log.i(TAG, "Temporary loss of focus");
SharedPreferences prefs = getPreferences(context);
int lossPref = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_TEMP_LOSS, "1"));
if(lossPref == 2 || (lossPref == 1 && focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK)) {
@@ -1161,6 +1162,7 @@ public final class Util {
downloadService.setVolume(1.0f);
}
} else if(focusChange == AudioManager.AUDIOFOCUS_LOSS && !downloadService.isRemoteEnabled()) {
+ Log.i(TAG, "Permanently lost focus");
focusListener = null;
downloadService.pause();
audioManager.abandonAudioFocus(this);