summaryrefslogtreecommitdiff
path: root/src/org/fox/ttrss/ImageCacheService.java
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2011-12-07 18:02:43 +0300
committerAndrew Dolgov <fox@fakecake.org>2011-12-07 18:02:43 +0300
commit9951991e5600226695cb880edc39031ef0546c44 (patch)
tree35eb5391eda3a0d8ec1296a3c9cf001a2ba662ae /src/org/fox/ttrss/ImageCacheService.java
parent803afcc6d2573a85a493d7bbab2c3a4498823869 (diff)
better download progress notification, prevent notification spam
Diffstat (limited to 'src/org/fox/ttrss/ImageCacheService.java')
-rw-r--r--src/org/fox/ttrss/ImageCacheService.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/org/fox/ttrss/ImageCacheService.java b/src/org/fox/ttrss/ImageCacheService.java
index 999b7437..94937b24 100644
--- a/src/org/fox/ttrss/ImageCacheService.java
+++ b/src/org/fox/ttrss/ImageCacheService.java
@@ -12,7 +12,9 @@ import java.util.Date;
import android.app.ActivityManager;
import android.app.IntentService;
+import android.app.Notification;
import android.app.NotificationManager;
+import android.app.PendingIntent;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Intent;
import android.os.Environment;
@@ -117,6 +119,26 @@ public class ImageCacheService extends IntentService {
return null;
}
}
+
+ private void updateNotification(String msg) {
+ Notification notification = new Notification(R.drawable.icon,
+ getString(R.string.notify_downloading_title), System.currentTimeMillis());
+
+ PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
+ new Intent(this, MainActivity.class), 0);
+
+ notification.flags |= Notification.FLAG_ONGOING_EVENT;
+ notification.flags |= Notification.FLAG_ONLY_ALERT_ONCE;
+
+ notification.setLatestEventInfo(this, getString(R.string.notify_downloading_title), msg, contentIntent);
+
+ m_nmgr.notify(NOTIFY_DOWNLOADING, notification);
+ }
+
+ private void updateNotification(int msgResId) {
+ updateNotification(getString(msgResId));
+ }
+
@Override
protected void onHandleIntent(Intent intent) {
String url = intent.getStringExtra("url");
@@ -156,6 +178,8 @@ public class ImageCacheService extends IntentService {
m_imagesDownloaded++;
+ updateNotification(getString(R.string.notify_downloading_images, m_imagesDownloaded));
+
} catch (IOException e) {
e.printStackTrace();
}