migrated some ArrayLists to CopyOnWriteArrayLists

This commit is contained in:
iNPUTmice 2014-07-27 18:07:04 +02:00
parent 29f089c954
commit 2e080401b1
6 changed files with 14 additions and 22 deletions

View file

@ -1,7 +1,6 @@
package eu.siacs.conversations.entities;
import java.security.interfaces.DSAPublicKey;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.CopyOnWriteArrayList;
@ -68,7 +67,7 @@ public class Account extends AbstractEntity{
private Roster roster = null;
private List<Bookmark> bookmarks = new ArrayList<Bookmark>();
private List<Bookmark> bookmarks = new CopyOnWriteArrayList<Bookmark>();
public List<Conversation> pendingConferenceJoins = new CopyOnWriteArrayList<Conversation>();
public List<Conversation> pendingConferenceLeaves = new CopyOnWriteArrayList<Conversation>();

View file

@ -1,8 +1,8 @@
package eu.siacs.conversations.entities;
import java.security.interfaces.DSAPublicKey;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import net.java.otr4j.OtrException;
import net.java.otr4j.crypto.OtrCryptoEngineImpl;
@ -43,7 +43,7 @@ public class Conversation extends AbstractEntity {
private String nextPresence;
private transient List<Message> messages = null;
private transient CopyOnWriteArrayList<Message> messages = null;
private transient Account account = null;
private transient SessionImpl otrSession;
@ -85,8 +85,9 @@ public class Conversation extends AbstractEntity {
}
public List<Message> getMessages() {
if (messages == null)
this.messages = new ArrayList<Message>(); // prevent null pointer
if (messages == null) {
this.messages = new CopyOnWriteArrayList<Message>(); // prevent null pointer
}
// populate with Conversation (this)
@ -133,7 +134,7 @@ public class Conversation extends AbstractEntity {
}
}
public void setMessages(List<Message> msgs) {
public void setMessages(CopyOnWriteArrayList<Message> msgs) {
this.messages = msgs;
}

View file

@ -2,6 +2,7 @@ package eu.siacs.conversations.entities;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.xml.Element;
@ -81,7 +82,7 @@ public class MucOptions {
}
}
private Account account;
private ArrayList<User> users = new ArrayList<User>();
private List<User> users = new CopyOnWriteArrayList<User>();
private Conversation conversation;
private boolean isOnline = false;
private int error = ERROR_ROOM_NOT_FOUND;

View file

@ -129,12 +129,12 @@ public class DatabaseBackend extends SQLiteOpenHelper {
return list;
}
public List<Message> getMessages(Conversation conversations, int limit) {
public CopyOnWriteArrayList<Message> getMessages(Conversation conversations, int limit) {
return getMessages(conversations, limit,-1);
}
public List<Message> getMessages(Conversation conversation, int limit, long timestamp) {
List<Message> list = new CopyOnWriteArrayList<Message>();
public CopyOnWriteArrayList<Message> getMessages(Conversation conversation, int limit, long timestamp) {
CopyOnWriteArrayList<Message> list = new CopyOnWriteArrayList<Message>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor;
if (timestamp==-1) {

View file

@ -668,7 +668,7 @@ public class XmppConnectionService extends Service {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
Element query = packet.query();
List<Bookmark> bookmarks = new ArrayList<Bookmark>();
List<Bookmark> bookmarks = new CopyOnWriteArrayList<Bookmark>();
Element storage = query.findChild("storage", "storage:bookmarks");
if (storage!=null) {
for(Element item : storage.getChildren()) {

View file

@ -7,14 +7,8 @@ import java.math.BigInteger;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
@ -25,16 +19,13 @@ import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import org.bouncycastle.pqc.math.linearalgebra.GoppaCode.MaMaPe;
import org.xmlpull.v1.XmlPullParserException;
import de.duenndns.ssl.MemorizingTrustManager;
import android.content.Context;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;