From ec1b17c7bce3633a59774fd64681dc1f30a04240 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 11 Nov 2015 17:59:29 -0800 Subject: Don't constantly update position for Auto --- .../daneren2005/dsub/service/DownloadService.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index 40538eae..0ed79d52 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -1461,7 +1461,7 @@ public class DownloadService extends Service { subtractNextPosition = 0; } } - onSongProgress(); + onSongProgress(cachedPosition < 2000 ? true: false); Thread.sleep(1000L); } catch(Exception e) { @@ -2632,7 +2632,11 @@ public class DownloadService extends Service { }); } } + private synchronized void onSongProgress() { + onSongProgress(true); + } + private synchronized void onSongProgress(boolean manual) { final long atRevision = revision; final Integer duration = getPlayerDuration(); final boolean isSeekable = isSeekable(); @@ -2648,12 +2652,15 @@ public class DownloadService extends Service { }); } - handler.post(new Runnable() { - @Override - public void run() { - mRemoteControl.setPlaybackState(playerState.getRemoteControlClientPlayState()); - } - }); + if(manual) { + Log.d(TAG, "Manual update"); + handler.post(new Runnable() { + @Override + public void run() { + mRemoteControl.setPlaybackState(playerState.getRemoteControlClientPlayState()); + } + }); + } } private void onStateUpdate() { final long atRevision = revision; -- cgit v1.2.3