aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-11-26 19:31:03 -0800
committerScott Jackson <daneren2005@gmail.com>2013-11-26 19:31:03 -0800
commit2f8ed351e5d319aea98f296233503088bc7957f4 (patch)
treec04e6c2242f69b35acc7774f946660472f99afc5 /src/github
parent24a6132bf5f852bf822e272676ceb6072f8ce248 (diff)
downloaddsub-2f8ed351e5d319aea98f296233503088bc7957f4.tar.gz
dsub-2f8ed351e5d319aea98f296233503088bc7957f4.tar.bz2
dsub-2f8ed351e5d319aea98f296233503088bc7957f4.zip
Fix web commits
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicActivity.java5
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java34
-rw-r--r--src/github/daneren2005/dsub/fragments/SearchFragment.java4
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java2
-rw-r--r--src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java5
-rw-r--r--src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java44
6 files changed, 56 insertions, 38 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
index 53d8eaca..5b5aeb91 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -296,6 +296,11 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
lastSelectedPosition = savedInstanceState.getInt(Constants.FRAGMENT_POSITION);
recreateSpinner();
}
+
+ @Override
+ public void onNewIntent(Intent intent) {
+
+ }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
index e74f6ff3..08acf591 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
@@ -211,24 +211,26 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
- if(currentFragment != null && currentFragment instanceof SearchFragment && intent.getStringExtra(Constants.INTENT_EXTRA_NAME_QUERY) != null) {
- String query = intent.getStringExtra(Constants.INTENT_EXTRA_NAME_QUERY);
- boolean autoplay = intent.getBooleanExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
- boolean requestsearch = intent.getBooleanExtra(Constants.INTENT_EXTRA_REQUEST_SEARCH, false);
-
- if (query != null) {
- ((SearchFragment)currentFragment).search(query, autoplay);
- } else {
- ((SearchFragment)currentFragment).populateList();
- if (requestsearch) {
- onSearchRequested();
+ if(currentFragment != null && intent.getStringExtra(Constants.INTENT_EXTRA_NAME_QUERY) != null) {
+ if(currentFragment instanceof SearchFragment) {
+ String query = intent.getStringExtra(Constants.INTENT_EXTRA_NAME_QUERY);
+ boolean autoplay = intent.getBooleanExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
+ boolean requestsearch = intent.getBooleanExtra(Constants.INTENT_EXTRA_REQUEST_SEARCH, false);
+
+ if (query != null) {
+ ((SearchFragment)currentFragment).search(query, autoplay);
+ } else {
+ ((SearchFragment)currentFragment).populateList();
+ if (requestsearch) {
+ onSearchRequested();
+ }
}
- }
- } else if(currentFragment != null && intent.getStringExtra(Constants.INTENT_EXTRA_NAME_QUERY) != null) {
- setIntent(intent);
+ } else {
+ setIntent(intent);
- SearchFragment fragment = new SearchFragment();
- replaceFragment(fragment, currentFragment.getRootId(), fragment.getSupportTag());
+ SearchFragment fragment = new SearchFragment();
+ replaceFragment(fragment, currentFragment.getRootId(), fragment.getSupportTag());
+ }
} else {
setIntent(intent);
}
diff --git a/src/github/daneren2005/dsub/fragments/SearchFragment.java b/src/github/daneren2005/dsub/fragments/SearchFragment.java
index 8eca35c0..22a3cff0 100644
--- a/src/github/daneren2005/dsub/fragments/SearchFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SearchFragment.java
@@ -356,9 +356,9 @@ public class SearchFragment extends SubsonicFragment {
MusicDirectory.Entry album = searchResult.getAlbums().isEmpty() ? null : searchResult.getAlbums().get(0);
MusicDirectory.Entry song = searchResult.getSongs().isEmpty() ? null : searchResult.getSongs().get(0);
- if(artist != null && query.equals(artist.getName()) {
+ if(artist != null && query.equals(artist.getName())) {
onArtistSelected(artist, true);
- } else if(album != null && query.equals(album.getTitle()) {
+ } else if(album != null && query.equals(album.getTitle())) {
onAlbumSelected(album, true);
} else if(song != null) {
onSongSelected(song, false, false, true, false);
diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
index e0cdf543..c13776dd 100644
--- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
@@ -42,6 +42,7 @@ import github.daneren2005.dsub.service.ServerTooOldException;
import github.daneren2005.dsub.util.BackgroundTask;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.LoadingTask;
+import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.util.TabBackgroundTask;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.BookmarkAdapter;
@@ -187,6 +188,7 @@ public class SelectBookmarkFragment extends SubsonicFragment implements AdapterV
@Override
protected Void doInBackground() throws Throwable {
downloadService.download(bookmark);
+ return null;
}
@Override
diff --git a/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java b/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java
index 1b4419d9..2b1d0be5 100644
--- a/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java
+++ b/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java
@@ -1,6 +1,7 @@
package github.daneren2005.dsub.util.compat;
import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.service.DownloadServiceImpl;
import github.daneren2005.dsub.util.ImageLoader;
import android.annotation.TargetApi;
import android.app.PendingIntent;
@@ -17,10 +18,10 @@ import github.daneren2005.dsub.service.DownloadService;
public class RemoteControlClientICS extends RemoteControlClientHelper {
protected RemoteControlClient mRemoteControl;
protected ImageLoader imageLoader;
- protected DownloadService downloadService;
+ protected DownloadServiceImpl downloadService;
public void register(final Context context, final ComponentName mediaButtonReceiverComponent) {
- downloadService = (DownloadService) context;
+ downloadService = (DownloadServiceImpl) context;
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
// build the PendingIntent for the remote control client
diff --git a/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java b/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java
index 06329c15..e88b4122 100644
--- a/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java
+++ b/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java
@@ -8,9 +8,13 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
+import android.media.MediaMetadataEditor;
import android.media.MediaMetadataRetriever;
import android.media.Rating;
import android.media.RemoteControlClient;
+import android.os.AsyncTask;
+import android.util.Log;
+
import github.daneren2005.dsub.activity.SubsonicActivity;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.MusicService;
@@ -21,11 +25,14 @@ import java.io.File;
@TargetApi(19)
public class RemoteControlClientKK extends RemoteControlClientJB {
+ private static String TAG = RemoteControlClientKK.class.getSimpleName();
+ protected MusicDirectory.Entry currentSong;
+
@Override
public void register(final Context context, final ComponentName mediaButtonReceiverComponent) {
super.register(context, mediaButtonReceiverComponent);
-
- mRemoteControl.setMetadataUpdateListener(new RemoteControlClient.onMetadataUpdateListener() {
+
+ mRemoteControl.setMetadataUpdateListener(new RemoteControlClient.OnMetadataUpdateListener() {
@Override
public void onMetadataUpdate(int key, Object newValue) {
if(key == MediaMetadataEditor.RATING_KEY_BY_USER) {
@@ -41,6 +48,7 @@ public class RemoteControlClientKK extends RemoteControlClientJB {
super.updateMetadata(currentSong, editor);
editor.putObject(MediaMetadataEditor.RATING_KEY_BY_USER, Rating.newHeartRating(currentSong.isStarred()));
editor.addEditableKey(MediaMetadataEditor.RATING_KEY_BY_USER);
+ this.currentSong = currentSong;
}
@Override
@@ -50,23 +58,23 @@ public class RemoteControlClientKK extends RemoteControlClientJB {
private void setStarred(final MusicDirectory.Entry entry, final boolean starred) {
entry.setStarred(starred);
-
- new SilentBackgroundTask<Void>(context) {
- @Override
- protected Void doInBackground() throws Throwable {
- MusicService musicService = MusicServiceFactory.getMusicService(context);
- musicService.setStarred(entry.getId(), starred, context, null);
-
- // Make sure to clear parent cache
- String s = Util.getRestUrl(context, null) + entry.getParent();
- String parentCache = "directory-" + s.hashCode() + ".ser";
- File file = new File(context.getCacheDir(), parentCache);
- file.delete();
- }
-
+
+ new AsyncTask<Void, Void, Void>() {
@Override
- protected void done(Void result) {
-
+ protected Void doInBackground(Void... params) {
+ try {
+ MusicService musicService = MusicServiceFactory.getMusicService(downloadService);
+ musicService.setStarred(entry.getId(), starred, downloadService, null);
+
+ // Make sure to clear parent cache
+ String s = Util.getRestUrl(downloadService, null) + entry.getParent();
+ String parentCache = "directory-" + s.hashCode() + ".ser";
+ File file = new File(downloadService.getCacheDir(), parentCache);
+ file.delete();
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to set star for " + entry.getTitle());
+ }
+ return null;
}
}.execute();
}