Fixed warnings, simplification

pull/156/head
M66B 6 years ago
parent d44d0d6230
commit 4c1db52b01

@ -561,7 +561,6 @@ class Core {
} }
ifolder.expunge(); ifolder.expunge();
} else { } else {
// Mark source read // Mark source read
if (autoread) if (autoread)
@ -1241,7 +1240,6 @@ class Core {
IMAPFolder ifolder, IMAPMessage imessage, IMAPFolder ifolder, IMAPMessage imessage,
boolean browsed, boolean browsed,
List<EntityRule> rules) throws MessagingException, IOException { List<EntityRule> rules) throws MessagingException, IOException {
synchronized (folder) {
long uid = ifolder.getUID(imessage); long uid = ifolder.getUID(imessage);
if (imessage.isExpunged()) { if (imessage.isExpunged()) {
@ -1508,7 +1506,6 @@ class Core {
return message; return message;
} }
}
private static EntityIdentity matchIdentity(Context context, EntityFolder folder, EntityMessage message) { private static EntityIdentity matchIdentity(Context context, EntityFolder folder, EntityMessage message) {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
@ -1743,6 +1740,8 @@ class Core {
Log.i("Notify messages=" + messages.size()); Log.i("Notify messages=" + messages.size());
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (nm == null)
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean badge = prefs.getBoolean("badge", true); boolean badge = prefs.getBoolean("badge", true);
@ -1844,7 +1843,8 @@ class Core {
List<Notification> notifications = new ArrayList<>(); List<Notification> notifications = new ArrayList<>();
// https://developer.android.com/training/notify-user/group // https://developer.android.com/training/notify-user/group
if (messages == null || messages.size() == 0) NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (messages == null || messages.size() == 0 || nm == null)
return notifications; return notifications;
boolean pro = Helper.isPro(context); boolean pro = Helper.isPro(context);
@ -1860,8 +1860,6 @@ class Core {
boolean notify_flag = prefs.getBoolean("notify_flag", false) && pro; boolean notify_flag = prefs.getBoolean("notify_flag", false) && pro;
boolean notify_seen = prefs.getBoolean("notify_seen", true); boolean notify_seen = prefs.getBoolean("notify_seen", true);
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// Get contact info // Get contact info
Map<TupleMessageEx, ContactInfo> messageContact = new HashMap<>(); Map<TupleMessageEx, ContactInfo> messageContact = new HashMap<>();
for (TupleMessageEx message : messages) for (TupleMessageEx message : messages)
@ -2138,12 +2136,14 @@ class Core {
EntityLog.log(context, title + " " + Helper.formatThrowable(ex)); EntityLog.log(context, title + " " + Helper.formatThrowable(ex));
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (nm == null)
return;
if (ex instanceof AuthenticationFailedException || // Also: Too many simultaneous connections if (ex instanceof AuthenticationFailedException || // Also: Too many simultaneous connections
ex instanceof AlertException || ex instanceof AlertException ||
ex instanceof SendFailedException) { ex instanceof SendFailedException)
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(tag, 1, getNotificationError(context, title, ex).build()); nm.notify(tag, 1, getNotificationError(context, title, ex).build());
}
// connection failure: Too many simultaneous connections // connection failure: Too many simultaneous connections
@ -2160,11 +2160,9 @@ class Core {
!(ex instanceof MessagingException && ex.getCause() instanceof SocketException) && !(ex instanceof MessagingException && ex.getCause() instanceof SocketException) &&
!(ex instanceof MessagingException && ex.getCause() instanceof SocketTimeoutException) && !(ex instanceof MessagingException && ex.getCause() instanceof SocketTimeoutException) &&
!(ex instanceof MessagingException && ex.getCause() instanceof SSLException) && !(ex instanceof MessagingException && ex.getCause() instanceof SSLException) &&
!(ex instanceof MessagingException && "connection failure".equals(ex.getMessage()))) { !(ex instanceof MessagingException && "connection failure".equals(ex.getMessage())))
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(tag, 1, getNotificationError(context, title, ex).build()); nm.notify(tag, 1, getNotificationError(context, title, ex).build());
} }
}
static NotificationCompat.Builder getNotificationError(Context context, String title, Throwable ex) { static NotificationCompat.Builder getNotificationError(Context context, String title, Throwable ex) {
return getNotificationError(context, "error", title, ex, true); return getNotificationError(context, "error", title, ex, true);

Loading…
Cancel
Save