diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 5331890d6..738ee32a3 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -117,7 +117,10 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { private static final int DIALOG_RECREATE_ACCOUNT = 3; private static final int DIALOG_NO_FILE_MANAGER = 4; - private ConcurrentMap accountStats = new ConcurrentHashMap(); + /* + * Must be serializable hence implementation class used for declaration. + */ + private ConcurrentHashMap accountStats = new ConcurrentHashMap(); private ConcurrentMap pendingWork = new ConcurrentHashMap(); @@ -492,7 +495,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { outState.putString(SELECTED_CONTEXT_ACCOUNT, mSelectedContextAccount.getUuid()); } outState.putSerializable(STATE_UNREAD_COUNT, mUnreadMessageCount); - outState.putSerializable(ACCOUNT_STATS, Utility.toSerializableConcurrentMap(accountStats)); + outState.putSerializable(ACCOUNT_STATS, accountStats); } private StorageManager.StorageListener storageListener = new StorageManager.StorageListener() { diff --git a/src/com/fsck/k9/activity/MessageCompose.java b/src/com/fsck/k9/activity/MessageCompose.java index 8110f66e9..5b975247c 100644 --- a/src/com/fsck/k9/activity/MessageCompose.java +++ b/src/com/fsck/k9/activity/MessageCompose.java @@ -1154,7 +1154,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - List attachments = new ArrayList(); + ArrayList attachments = new ArrayList(); for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) { View view = mAttachments.getChildAt(i); Attachment attachment = (Attachment) view.getTag(); @@ -1163,7 +1163,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, outState.putInt(STATE_KEY_NUM_ATTACHMENTS_LOADING, mNumAttachmentsLoading); outState.putString(STATE_KEY_WAITING_FOR_ATTACHMENTS, mWaitingForAttachments.name()); - outState.putParcelableArrayList(STATE_KEY_ATTACHMENTS, Utility.toArrayList(attachments)); + outState.putParcelableArrayList(STATE_KEY_ATTACHMENTS, attachments); outState.putBoolean(STATE_KEY_CC_SHOWN, mCcWrapper.getVisibility() == View.VISIBLE); outState.putBoolean(STATE_KEY_BCC_SHOWN, mBccWrapper.getVisibility() == View.VISIBLE); outState.putSerializable(STATE_KEY_QUOTED_TEXT_MODE, mQuotedTextMode); diff --git a/src/com/fsck/k9/activity/NotificationDeleteConfirmation.java b/src/com/fsck/k9/activity/NotificationDeleteConfirmation.java index 9a070ed39..fd6f87db5 100644 --- a/src/com/fsck/k9/activity/NotificationDeleteConfirmation.java +++ b/src/com/fsck/k9/activity/NotificationDeleteConfirmation.java @@ -1,5 +1,6 @@ package com.fsck.k9.activity; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -25,12 +26,12 @@ public class NotificationDeleteConfirmation extends Activity { private final static int DIALOG_CONFIRM = 1; private Account mAccount; - private List mMessageRefs; + private ArrayList mMessageRefs; - public static PendingIntent getIntent(Context context, final Account account, final List refs) { + public static PendingIntent getIntent(Context context, final Account account, final Serializable refs) { Intent i = new Intent(context, NotificationDeleteConfirmation.class); i.putExtra(EXTRA_ACCOUNT, account.getUuid()); - i.putExtra(EXTRA_MESSAGE_LIST, Utility.toSerializableList(refs)); + i.putExtra(EXTRA_MESSAGE_LIST, refs); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); return PendingIntent.getActivity(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT); diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index e09453e9b..07f2f5e05 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -2,6 +2,7 @@ package com.fsck.k9.controller; import java.io.CharArrayWriter; import java.io.PrintWriter; +import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -286,17 +287,14 @@ public class MessagingController implements Runnable { } /** - * Gets a list of references for all pending messages for the notification. - * - * @return Message reference list + * Adds a list of references for all pending messages for the notification to the supplied + * List. */ - public List getAllMessageRefs() { - List refs = new ArrayList(); + public void supplyAllMessageRefs(List refs) { for (Message m : messages) { refs.add(m.makeMessageReference()); } refs.addAll(droppedMessages); - return refs; } /** @@ -4844,7 +4842,8 @@ public class MessagingController implements Runnable { String accountDescr = (account.getDescription() != null) ? account.getDescription() : account.getEmail(); - final List allRefs = data.getAllMessageRefs(); + final ArrayList allRefs = new ArrayList(); + data.supplyAllMessageRefs(allRefs); if (platformSupportsExtendedNotifications() && !privacyModeEnabled) { if (newMessages > 1) { diff --git a/src/com/fsck/k9/helper/Utility.java b/src/com/fsck/k9/helper/Utility.java index a03a774fb..370920d59 100644 --- a/src/com/fsck/k9/helper/Utility.java +++ b/src/com/fsck/k9/helper/Utility.java @@ -724,22 +724,4 @@ public class Utility { return sMainThreadHandler; } - public static Serializable toSerializableList(List list) { - return list instanceof Serializable ? - (Serializable) list : - new ArrayList(list); - } - - public static ArrayList toArrayList(List list) { - return list instanceof ArrayList ? - (ArrayList) list : - new ArrayList(list); - } - - - public static Serializable toSerializableConcurrentMap(ConcurrentMap list) { - return list instanceof ConcurrentHashMap ? - (ConcurrentHashMap) list : - new ConcurrentHashMap(list); - } } diff --git a/src/com/fsck/k9/service/NotificationActionService.java b/src/com/fsck/k9/service/NotificationActionService.java index e4cad21c9..107bd0f4c 100644 --- a/src/com/fsck/k9/service/NotificationActionService.java +++ b/src/com/fsck/k9/service/NotificationActionService.java @@ -1,5 +1,6 @@ package com.fsck.k9.service; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -37,11 +38,10 @@ public class NotificationActionService extends CoreService { return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT); } - public static PendingIntent getReadAllMessagesIntent(Context context, final Account account, - final List refs) { + public static PendingIntent getReadAllMessagesIntent(Context context, final Account account, final Serializable refs) { Intent i = new Intent(context, NotificationActionService.class); i.putExtra(EXTRA_ACCOUNT, account.getUuid()); - i.putExtra(EXTRA_MESSAGE_LIST, Utility.toSerializableList(refs)); + i.putExtra(EXTRA_MESSAGE_LIST, refs); i.setAction(READ_ALL_ACTION); return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT); @@ -55,11 +55,10 @@ public class NotificationActionService extends CoreService { return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT); } - public static Intent getDeleteAllMessagesIntent(Context context, final Account account, - final List refs) { + public static Intent getDeleteAllMessagesIntent(Context context, final Account account, final Serializable refs) { Intent i = new Intent(context, NotificationActionService.class); i.putExtra(EXTRA_ACCOUNT, account.getUuid()); - i.putExtra(EXTRA_MESSAGE_LIST, Utility.toSerializableList(refs)); + i.putExtra(EXTRA_MESSAGE_LIST, refs); i.setAction(DELETE_ALL_ACTION); return i;