diff options
author | Scott Jackson <daneren2005@gmail.com> | 2012-11-03 12:21:03 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2012-11-03 12:21:03 -0700 |
commit | 501ff31505a521972bb2ca06bf35de29c97f54a5 (patch) | |
tree | 5568b2e31927a4626b0726e8fbabb7ed3f1dd6c5 /subsonic-android | |
parent | 8582bf9b186d9e59012451e07466e36aa5b639bd (diff) | |
download | dsub-501ff31505a521972bb2ca06bf35de29c97f54a5.tar.gz dsub-501ff31505a521972bb2ca06bf35de29c97f54a5.tar.bz2 dsub-501ff31505a521972bb2ca06bf35de29c97f54a5.zip |
Refactor copied from main branch
Diffstat (limited to 'subsonic-android')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/util/Util.java | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java index 8e3d7169..f4a3dc4c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java @@ -643,7 +643,7 @@ public final class Util { handler.post(new Runnable() { @Override public void run() { - startForeground(downloadService, Constants.NOTIFICATION_ID_PLAYING, notification); + downloadService.startForeground(Constants.NOTIFICATION_ID_PLAYING, notification); } }); @@ -657,7 +657,7 @@ public final class Util { handler.post(new Runnable() { @Override public void run() { - stopForeground(downloadService, true); + downloadService.stopForeground(true); } }); @@ -762,34 +762,6 @@ public final class Util { } } - private static void startForeground(Service service, int notificationId, Notification notification) { - // Service.startForeground() was introduced in Android 2.0. - // Use reflection to maintain compatibility with 1.5. - try { - Method method = Service.class.getMethod("startForeground", int.class, Notification.class); - method.invoke(service, notificationId, notification); - Log.i(TAG, "Successfully invoked Service.startForeground()"); - } catch (Throwable x) { - NotificationManager notificationManager = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.notify(Constants.NOTIFICATION_ID_PLAYING, notification); - Log.i(TAG, "Service.startForeground() not available. Using work-around."); - } - } - - private static void stopForeground(Service service, boolean removeNotification) { - // Service.stopForeground() was introduced in Android 2.0. - // Use reflection to maintain compatibility with 1.5. - try { - Method method = Service.class.getMethod("stopForeground", boolean.class); - method.invoke(service, removeNotification); - Log.i(TAG, "Successfully invoked Service.stopForeground()"); - } catch (Throwable x) { - NotificationManager notificationManager = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.cancel(Constants.NOTIFICATION_ID_PLAYING); - Log.i(TAG, "Service.stopForeground() not available. Using work-around."); - } - } - /** * <p>Broadcasts the given song info as the new song being played.</p> */ |