use of android.support.v4.app.NotificationManagerCompat in project WordPress-Android by wordpress-mobile.
the class GCMMessageService method removeNotificationWithNoteIdFromSystemBar.
// Removes a specific notification from the system bar
public static synchronized void removeNotificationWithNoteIdFromSystemBar(Context context, String noteID) {
if (context == null || TextUtils.isEmpty(noteID) || !hasNotifications()) {
return;
}
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
// so we need to keep cancelling them and removing them from our activeNotificationsMap as we find it suitable
for (Iterator<Map.Entry<Integer, Bundle>> it = sActiveNotificationsMap.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<Integer, Bundle> row = it.next();
Integer pushId = row.getKey();
Bundle noteBundle = row.getValue();
if (noteBundle.getString(PUSH_ARG_NOTE_ID, "").equals(noteID)) {
notificationManager.cancel(pushId);
it.remove();
}
}
if (sActiveNotificationsMap.size() == 0) {
notificationManager.cancel(GCMMessageService.GROUP_NOTIFICATION_ID);
}
}
use of android.support.v4.app.NotificationManagerCompat in project WordPress-Android by wordpress-mobile.
the class GCMMessageService method removeAllNotifications.
// Removes all app notifications from the system bar
public static synchronized void removeAllNotifications(Context context) {
if (context == null || !hasNotifications()) {
return;
}
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
Bundle authPNBundle = sActiveNotificationsMap.remove(AUTH_PUSH_NOTIFICATION_ID);
for (Integer pushId : sActiveNotificationsMap.keySet()) {
notificationManager.cancel(pushId);
}
notificationManager.cancel(GCMMessageService.GROUP_NOTIFICATION_ID);
//reinsert 2fa bundle if it was present
if (authPNBundle != null) {
sActiveNotificationsMap.put(AUTH_PUSH_NOTIFICATION_ID, authPNBundle);
}
clearNotifications();
}
use of android.support.v4.app.NotificationManagerCompat in project WordPress-Android by wordpress-mobile.
the class NativeNotificationsUtils method showMessageToUserWithBuilder.
public static void showMessageToUserWithBuilder(NotificationCompat.Builder builder, String message, boolean intermediateMessage, int pushId, Context context) {
if (!intermediateMessage) {
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
}
builder.setProgress(0, 0, intermediateMessage);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(pushId, builder.build());
}
use of android.support.v4.app.NotificationManagerCompat in project wh-app-android by WhiteHouse.
the class NotificationPublisher method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
final NotificationManagerCompat nm = NotificationManagerCompat.from(context);
final Notification n = intent.getParcelableExtra(EXTRA_NOTIFICATION);
final int id = intent.getIntExtra(EXTRA_NOTIFICATION_ID, 0);
nm.notify(id, n);
}
use of android.support.v4.app.NotificationManagerCompat in project wh-app-android by WhiteHouse.
the class LiveService method postLiveItem.
private void postLiveItem(final FeedItem item) {
final Notification notification = buildLiveNotification(item);
final NotificationManagerCompat nm = NotificationManagerCompat.from(this);
nm.notify(0, notification);
}
Aggregations