From 7bf60cbee7650834d64656f49748e4c70848d991 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 17 Oct 2015 13:46:50 -0700 Subject: Poll for service available instead of just relying on next call to getDownloadService to execute waiting handlers --- .../daneren2005/dsub/activity/SubsonicActivity.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app/src/main') diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java index d67893ef..dc64e9d1 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -954,6 +954,22 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte runnable.run(); } else { afterServiceAvailable.add(runnable); + checkIfServiceAvailable(); + } + } + private void checkIfServiceAvailable() { + if(getDownloadService() == null) { + handler.postDelayed(new Runnable() { + @Override + public void run() { + checkIfServiceAvailable(); + } + }, 50); + } else if(afterServiceAvailable.size() > 0) { + for(Runnable runnable: afterServiceAvailable) { + handler.post(runnable); + } + afterServiceAvailable.clear(); } } -- cgit v1.2.3