mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-24 08:38:51 -05:00
address review comments
This commit is contained in:
parent
c6df8f1ba1
commit
5dc1b82340
@ -1155,7 +1155,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
List<Attachment> attachments = new ArrayList<Attachment>();
|
||||
ArrayList<Attachment> attachments = new ArrayList<Attachment>();
|
||||
for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) {
|
||||
View view = mAttachments.getChildAt(i);
|
||||
Attachment attachment = (Attachment) view.getTag();
|
||||
@ -1164,7 +1164,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);
|
||||
|
@ -27,6 +27,9 @@ public class NotificationDeleteConfirmation extends Activity {
|
||||
private Account mAccount;
|
||||
private List<MessageReference> mMessageRefs;
|
||||
|
||||
/**
|
||||
* @param refs must be Serializable
|
||||
*/
|
||||
public static PendingIntent getIntent(Context context, final Account account, final List<MessageReference> refs) {
|
||||
Intent i = new Intent(context, NotificationDeleteConfirmation.class);
|
||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||
|
@ -708,34 +708,17 @@ public class Utility {
|
||||
return sMainThreadHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the supplied list casted to Serializable.
|
||||
*
|
||||
* See https://github.com/k9mail/k9mail_pgp_mime/pull/12#issuecomment-58767082
|
||||
*/
|
||||
public static <T> Serializable toSerializableList(List<T> list) {
|
||||
return isExpectedCollectionClass(Serializable.class, list) ?
|
||||
(Serializable) list :
|
||||
new ArrayList<T>(list);
|
||||
}
|
||||
|
||||
public static <T> ArrayList<T> toArrayList(List<T> list) {
|
||||
return isExpectedCollectionClass(ArrayList.class, list) ?
|
||||
(ArrayList<T>) list :
|
||||
new ArrayList<T>(list);
|
||||
return (Serializable) list;
|
||||
}
|
||||
|
||||
public static <T, U> Serializable toSerializableConcurrentMap(ConcurrentMap<T, U> map) {
|
||||
return isExpectedCollectionClass(ConcurrentHashMap.class, map) ?
|
||||
(ConcurrentHashMap<T, U>) map :
|
||||
new ConcurrentHashMap<T, U>(map);
|
||||
}
|
||||
|
||||
private static boolean isExpectedCollectionClass(Class<?> expected, Object instance) {
|
||||
// Objects.requireNonNull(instance); // uncomment when project moves to API level 19
|
||||
if (!expected.isInstance(instance)) {
|
||||
Log.w(K9.LOG_TAG, "Instance class [" + instance.getClass().getName()
|
||||
+ "] would be better as [" + expected.getName()
|
||||
+ "] for performance, to prevent collection copying");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return (ConcurrentHashMap<T, U>) map;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,6 +37,9 @@ public class NotificationActionService extends CoreService {
|
||||
return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param refs must be Serializable
|
||||
*/
|
||||
public static PendingIntent getReadAllMessagesIntent(Context context, final Account account,
|
||||
final List<MessageReference> refs) {
|
||||
Intent i = new Intent(context, NotificationActionService.class);
|
||||
@ -55,6 +58,9 @@ public class NotificationActionService extends CoreService {
|
||||
return PendingIntent.getService(context, account.getAccountNumber(), i, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param refs must be Serializable
|
||||
*/
|
||||
public static Intent getDeleteAllMessagesIntent(Context context, final Account account,
|
||||
final List<MessageReference> refs) {
|
||||
Intent i = new Intent(context, NotificationActionService.class);
|
||||
|
@ -1,28 +0,0 @@
|
||||
package com.fsck.k9.mail.internet;
|
||||
|
||||
import com.fsck.k9.helper.Utility;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class UtilityTest extends TestCase {
|
||||
|
||||
public void testToArrayList() {
|
||||
LinkedList<String> input = new LinkedList<String>(Arrays.asList("a", "b"));
|
||||
|
||||
Serializable serializableList = Utility.toArrayList(input);
|
||||
|
||||
assertEquals(serializableList, input);
|
||||
}
|
||||
|
||||
public void testToArrayListAlreadyArrayList() {
|
||||
ArrayList<String> input = new ArrayList<String>(Arrays.asList("a", "b"));
|
||||
|
||||
Serializable serializableList = Utility.toArrayList(input);
|
||||
|
||||
assertSame(serializableList, input);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user