|
|
|
@ -65,6 +65,9 @@ import java.util.LinkedHashSet; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
|
|
|
|
|
|
import io.reactivex.Single; |
|
|
|
|
import io.reactivex.schedulers.Schedulers; |
|
|
|
|
|
|
|
|
|
public class NotificationHelper { |
|
|
|
|
|
|
|
|
|
private static int notificationId = 0; |
|
|
|
@ -465,13 +468,18 @@ public class NotificationHelper { |
|
|
|
|
|
|
|
|
|
public static void clearNotificationsForActiveAccount(@NonNull Context context, @NonNull AccountManager accountManager) { |
|
|
|
|
AccountEntity account = accountManager.getActiveAccount(); |
|
|
|
|
if (account != null) { |
|
|
|
|
account.setActiveNotifications("[]"); |
|
|
|
|
accountManager.saveAccount(account); |
|
|
|
|
|
|
|
|
|
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); |
|
|
|
|
//noinspection ConstantConditions
|
|
|
|
|
notificationManager.cancel((int) account.getId()); |
|
|
|
|
if (account != null && !account.getActiveNotifications().equals("[]")) { |
|
|
|
|
Single.fromCallable(() -> { |
|
|
|
|
account.setActiveNotifications("[]"); |
|
|
|
|
accountManager.saveAccount(account); |
|
|
|
|
|
|
|
|
|
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); |
|
|
|
|
//noinspection ConstantConditions
|
|
|
|
|
notificationManager.cancel((int) account.getId()); |
|
|
|
|
return true; |
|
|
|
|
}) |
|
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
|
.subscribe(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|