mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
refactor getHeaders and removeHeaders to use a common method and an
iterator to address a Market FC: java.util.ConcurrentModificationException at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573) at com.fsck.k9.mail.internet.MimeHeader.getHeader(MimeHeader.java:87) at com.fsck.k9.mail.internet.MimeHeader.getFirstHeader(MimeHeader.java:51) at com.fsck.k9.mail.internet.MimeMessage.getFirstHeader(MimeMessage.java:437) at com.fsck.k9.mail.internet.MimeMessage.getContentType(MimeMessage.java:130) at com.fsck.k9.mail.internet.MimeMessage.getMimeType(MimeMessage.java:159) at com.fsck.k9.mail.internet.MimeUtility.findFirstPartByMimeType(MimeUtility.java:971) at com.fsck.k9.crypto.Apg.isEncrypted(Apg.java:464) at com.fsck.k9.activity.MessageView.updateDecryptLayout(MessageView.java:2702) at com.fsck.k9.activity.MessageView$Listener$6.run(MessageView.java:2466) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:144) at android.app.ActivityThread.main(ActivityThread.java:4937) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
This commit is contained in:
parent
23254e8998
commit
1149f2d916
@ -83,14 +83,7 @@ public class MimeHeader
|
||||
|
||||
public String[] getHeader(String name)
|
||||
{
|
||||
ArrayList<String> values = new ArrayList<String>();
|
||||
for (Field field : mFields)
|
||||
{
|
||||
if (field.name.equalsIgnoreCase(name))
|
||||
{
|
||||
values.add(field.value);
|
||||
}
|
||||
}
|
||||
ArrayList<String> values = findHeaders(name);
|
||||
if (values.size() == 0)
|
||||
{
|
||||
return null;
|
||||
@ -100,17 +93,27 @@ public class MimeHeader
|
||||
|
||||
public void removeHeader(String name)
|
||||
{
|
||||
ArrayList<Field> removeFields = new ArrayList<Field>();
|
||||
for (Field field : mFields)
|
||||
{
|
||||
if (field.name.equalsIgnoreCase(name))
|
||||
{
|
||||
removeFields.add(field);
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<String> removeFields = findHeaders(name);
|
||||
mFields.removeAll(removeFields);
|
||||
}
|
||||
|
||||
private ArrayList findHeaders(String name) {
|
||||
ArrayList<String> values = new ArrayList<String>();
|
||||
Iterator<Field> iter = mFields.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Field field = iter.next();
|
||||
if (field.name.equalsIgnoreCase(name) )
|
||||
{
|
||||
values.add(field.value);
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
public void writeTo(OutputStream out) throws IOException, MessagingException
|
||||
{
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024);
|
||||
|
Loading…
Reference in New Issue
Block a user