LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 package org.adblockplus.android; | 18 package org.adblockplus.android; |
19 | 19 |
20 import org.adblockplus.android.updater.UpdaterActivity; | 20 import org.adblockplus.android.updater.UpdaterActivity; |
21 import org.adblockplus.libadblockplus.JsValue; | 21 import org.adblockplus.libadblockplus.JsValue; |
22 import org.adblockplus.libadblockplus.Subscription; | 22 import org.adblockplus.libadblockplus.Subscription; |
23 | 23 import org.apache.commons.lang.StringUtils; |
24 import com.github.rjeschke.neetutils.Strings; | |
25 | 24 |
26 import android.app.Notification; | 25 import android.app.Notification; |
27 import android.app.PendingIntent; | 26 import android.app.PendingIntent; |
28 import android.content.Context; | 27 import android.content.Context; |
29 import android.content.Intent; | 28 import android.content.Intent; |
30 import android.support.v4.app.NotificationCompat; | 29 import android.support.v4.app.NotificationCompat; |
31 | 30 |
32 public final class Utils | 31 public final class Utils |
33 { | 32 { |
34 private Utils() | 33 private Utils() |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 final String downloadStatus = jsDownloadStatus.isNull() ? "" : jsDownloadSta
tus.toString(); | 95 final String downloadStatus = jsDownloadStatus.isNull() ? "" : jsDownloadSta
tus.toString(); |
97 final long lastDownload = sub.getProperty("lastDownload").asLong(); | 96 final long lastDownload = sub.getProperty("lastDownload").asLong(); |
98 | 97 |
99 String status = "synchronize_never"; | 98 String status = "synchronize_never"; |
100 long time = 0; | 99 long time = 0; |
101 | 100 |
102 if (sub.isUpdating()) | 101 if (sub.isUpdating()) |
103 { | 102 { |
104 status = "synchronize_in_progress"; | 103 status = "synchronize_in_progress"; |
105 } | 104 } |
106 else if (!Strings.isEmpty(downloadStatus) && !downloadStatus.equals("synchro
nize_ok")) | 105 else if (StringUtils.isNotEmpty(downloadStatus) && !downloadStatus.equals("s
ynchronize_ok")) |
107 { | 106 { |
108 status = downloadStatus; | 107 status = downloadStatus; |
109 } | 108 } |
110 else if (lastDownload > 0) | 109 else if (lastDownload > 0) |
111 { | 110 { |
112 time = lastDownload; | 111 time = lastDownload; |
113 status = "synchronize_last_at"; | 112 status = "synchronize_last_at"; |
114 } | 113 } |
115 | 114 |
116 context.sendBroadcast(new Intent(AdblockPlus.BROADCAST_SUBSCRIPTION_STATUS) | 115 context.sendBroadcast(new Intent(AdblockPlus.BROADCAST_SUBSCRIPTION_STATUS) |
117 .putExtra("url", sub.getProperty("url").toString()) | 116 .putExtra("url", sub.getProperty("url").toString()) |
118 .putExtra("status", status) | 117 .putExtra("status", status) |
119 .putExtra("time", time * 1000L)); | 118 .putExtra("time", time * 1000L)); |
120 } | 119 } |
121 } | 120 } |
LEFT | RIGHT |