aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-09-09 16:22:49 -0700
committerdaneren2005 <daneren2005@gmail.com>2013-09-09 16:22:49 -0700
commit3b16539fafbbf406d9a3c8b7fc447e5cf5f727f3 (patch)
tree7e756c049bc038fb0db9314221a3084b3e9d1bdc /src
parentf7a91c5429181f93bb8706c1eae699e32a820f5d (diff)
downloaddsub-3b16539fafbbf406d9a3c8b7fc447e5cf5f727f3.tar.gz
dsub-3b16539fafbbf406d9a3c8b7fc447e5cf5f727f3.tar.bz2
dsub-3b16539fafbbf406d9a3c8b7fc447e5cf5f727f3.zip
Added show/hide downloading notification methods
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/util/Util.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index a83abae5..78c14f4d 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -40,6 +40,7 @@ import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
+import android.support.v4.app.NotificationCompat;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
@@ -930,6 +931,37 @@ public final class Util {
// Update widget
DSubWidgetProvider.notifyInstances(context, downloadService, false);
}
+
+ public static void showDownloadingNotification(final Context context, DownloadFile file, int size, Handler handler) {
+ NotificationCompat.Builder notification;
+ notification = new NotificationCompta.Builder(context)
+ .setSmallIcon(R.downloading)
+ .setContentTitle("Downloading " + size + " songs")
+ .setContentText("Current: " + file.getSong().getTitle())
+ .setProgress(10, 5, true);
+
+ Intent notificationIntent = new Intent(context, MainActivity.class);
+ notificationIntent.putExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD, true);
+ notificationIntent.putExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW, true);
+ notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ notification.setContentIntent(PendingIntent.getActivity(context, 0, notificationIntent, 0));
+
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ downloadService.startForeground(Constants.NOTIFICATION_ID_DOWNLOADING, notification.build());
+ }
+ });
+ }
+ public static void hideDownloadingNotification(final Context context, 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 sleepQuietly(long millis) {
try {