From 994ed6653cdc65bf4a61543f168d7db575c5cd0b Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 29 Aug 2010 16:57:40 +0000 Subject: [PATCH] simplify some of our flagging logic and remove duplication using ternary operators --- src/com/fsck/k9/mail/store/LocalStore.java | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index 476270261..dbad05d87 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -4794,10 +4794,10 @@ public class LocalStore extends Store implements Serializable */ try { + LocalFolder folder = (LocalFolder)mFolder; if (flag == Flag.DELETED || flag == Flag.X_DESTROYED || (flag == Flag.SEEN && !isSet(Flag.DELETED))) { - LocalFolder folder = (LocalFolder)mFolder; if (set && !isSet(Flag.SEEN)) { folder.setUnreadMessageCount(folder.getUnreadMessageCount() - 1); @@ -4809,27 +4809,11 @@ public class LocalStore extends Store implements Serializable } if ((flag == Flag.DELETED || flag == Flag.X_DESTROYED) && isSet(Flag.FLAGGED)) { - LocalFolder folder = (LocalFolder)mFolder; - if (set) - { - folder.setFlaggedMessageCount(folder.getFlaggedMessageCount() - 1); - } - else - { - folder.setFlaggedMessageCount(folder.getFlaggedMessageCount() + 1); - } + folder.setFlaggedMessageCount(folder.getFlaggedMessageCount() + (set ? -1 : 1)); } if (flag == Flag.FLAGGED && !isSet(Flag.DELETED)) { - LocalFolder folder = (LocalFolder)mFolder; - if (set) - { - folder.setFlaggedMessageCount(folder.getFlaggedMessageCount() + 1); - } - else - { - folder.setFlaggedMessageCount(folder.getFlaggedMessageCount() - 1); - } + folder.setFlaggedMessageCount(folder.getFlaggedMessageCount() + (set ? 1 : -1)); } } catch (MessagingException me)