aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-09-13 10:53:49 -0700
committerScott Jackson <daneren2005@gmail.com>2013-09-13 10:53:49 -0700
commitfcf2cb688ebe27c1c6a41df52c87c45b2be1e75d (patch)
tree03fb810626c58ae7c9121c08d80ea4c9808f87e8 /src/github/daneren2005
parentfad4181aa8cfb2d2d210078cbbe56e556a4cba75 (diff)
downloaddsub-fcf2cb688ebe27c1c6a41df52c87c45b2be1e75d.tar.gz
dsub-fcf2cb688ebe27c1c6a41df52c87c45b2be1e75d.tar.bz2
dsub-fcf2cb688ebe27c1c6a41df52c87c45b2be1e75d.zip
Make downloading notification just a ongoing, startForeground doesn't respect ids
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceImpl.java4
-rw-r--r--src/github/daneren2005/dsub/util/Util.java28
2 files changed, 12 insertions, 20 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index 2df1f30a..be4378e6 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -1426,11 +1426,11 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
if(!backgroundDownloadList.isEmpty() && downloadRevision != revision) {
- Util.showDownloadingNotification(this, this, currentDownloading, backgroundDownloadList.size(), handler);
+ Util.showDownloadingNotification(this, currentDownloading, backgroundDownloadList.size());
downloadRevision = revision;
downloadOngoing = true;
} else if(backgroundDownloadList.isEmpty() && downloadOngoing) {
- Util.hideDownloadingNotification(this, this, handler);
+ Util.hideDownloadingNotification(this);
downloadOngoing = false;
}
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index f5638110..587bd2b8 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -22,6 +22,7 @@ import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Notification;
+import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
@@ -933,13 +934,14 @@ public final class Util {
DSubWidgetProvider.notifyInstances(context, downloadService, false);
}
- public static void showDownloadingNotification(final Context context, final DownloadServiceImpl downloadService, DownloadFile file, int size, Handler handler) {
+ public static void showDownloadingNotification(final Context context, DownloadFile file, int size) {
NotificationCompat.Builder builder;
builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.stat_notify_download)
.setContentTitle("Downloading " + size + " songs")
.setContentText("Current: " + file.getSong().getTitle())
- .setProgress(10, 5, true);
+ .setProgress(10, 5, true)
+ .setOngoing(true);
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.putExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD, true);
@@ -947,23 +949,13 @@ public final class Util {
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
builder.setContentIntent(PendingIntent.getActivity(context, 0, notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP));
- final Notification notification = builder.build();
-
- handler.post(new Runnable() {
- @Override
- public void run() {
- downloadService.startForeground(Constants.NOTIFICATION_ID_DOWNLOADING, notification);
- }
- });
+ NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.notify(Constants.NOTIFICATION_ID_DOWNLOADING, builder.build());
+
}
- public static void hideDownloadingNotification(final Context context, final DownloadServiceImpl downloadService, Handler handler) {
- // Remove notification and remove the service from the foreground
- handler.post(new Runnable() {
- @Override
- public void run() {
- downloadService.stopForeground(true);
- }
- });
+ public static void hideDownloadingNotification(final Context context) {
+ NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.cancel(Constants.NOTIFICATION_ID_DOWNLOADING);
}
public static void sleepQuietly(long millis) {