From af9562f49e4b671a2796ab1714ed0c8d4a543201 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 21 Mar 2015 15:34:23 -0700 Subject: Get rid of a couple of rare ANR's --- src/github/daneren2005/dsub/fragments/MainFragment.java | 11 +++++++++-- .../daneren2005/dsub/util/compat/RemoteControlClientJB.java | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java index fb36c9e3..0e1b587e 100644 --- a/src/github/daneren2005/dsub/fragments/MainFragment.java +++ b/src/github/daneren2005/dsub/fragments/MainFragment.java @@ -254,9 +254,16 @@ public class MainFragment extends SubsonicFragment { private void setActiveServer(int instance) { if (Util.getActiveServer(context) != instance) { - DownloadService service = getDownloadService(); + final DownloadService service = getDownloadService(); if (service != null) { - service.clearIncomplete(); + new SilentBackgroundTask(context) { + @Override + protected Void doInBackground() throws Throwable { + service.clearIncomplete(); + return null; + } + }.execute(); + } Util.setActiveServer(context, instance); context.invalidate(); diff --git a/src/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java b/src/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java index 5e1ad044..c27df2ba 100644 --- a/src/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java +++ b/src/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java @@ -12,6 +12,7 @@ import android.media.MediaMetadataRetriever; import android.media.RemoteControlClient; import github.daneren2005.dsub.activity.SubsonicActivity; import github.daneren2005.dsub.service.DownloadService; +import github.daneren2005.dsub.util.SilentBackgroundTask; @TargetApi(18) public class RemoteControlClientJB extends RemoteControlClientICS { @@ -27,8 +28,14 @@ public class RemoteControlClientJB extends RemoteControlClientICS { }); mRemoteControl.setPlaybackPositionUpdateListener(new RemoteControlClient.OnPlaybackPositionUpdateListener() { @Override - public void onPlaybackPositionUpdate(long newPosition) { - downloadService.seekTo((int) newPosition); + public void onPlaybackPositionUpdate(final long newPosition) { + new SilentBackgroundTask(context) { + @Override + protected Void doInBackground() throws Throwable { + downloadService.seekTo((int) newPosition); + return null; + } + }.execute(); setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); } }); -- cgit v1.2.3