keep reference to previous and next message in message
This commit is contained in:
parent
a8a37ec08d
commit
0bb2c3c4d5
|
@ -57,8 +57,8 @@ public class Conversation extends AbstractEntity {
|
||||||
|
|
||||||
private String nextPresence;
|
private String nextPresence;
|
||||||
|
|
||||||
private transient ArrayList<Message> messages = new ArrayList<Message>();
|
protected ArrayList<Message> messages = new ArrayList<Message>();
|
||||||
private transient Account account = null;
|
protected Account account = null;
|
||||||
|
|
||||||
private transient SessionImpl otrSession;
|
private transient SessionImpl otrSession;
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,9 @@ public class Message extends AbstractEntity {
|
||||||
protected Downloadable downloadable = null;
|
protected Downloadable downloadable = null;
|
||||||
public boolean markable = false;
|
public boolean markable = false;
|
||||||
|
|
||||||
|
private Message mNextMessage = null;
|
||||||
|
private Message mPreviousMessage = null;
|
||||||
|
|
||||||
private Message() {
|
private Message() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -293,21 +296,34 @@ public class Message extends AbstractEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Message next() {
|
public Message next() {
|
||||||
int index = this.conversation.getMessages().indexOf(this);
|
if (this.mNextMessage == null) {
|
||||||
if (index < 0 || index >= this.conversation.getMessages().size() - 1) {
|
synchronized (this.conversation.messages) {
|
||||||
return null;
|
int index = this.conversation.messages.indexOf(this);
|
||||||
} else {
|
if (index < 0
|
||||||
return this.conversation.getMessages().get(index + 1);
|
|| index >= this.conversation.getMessages().size() - 1) {
|
||||||
|
this.mNextMessage = null;
|
||||||
|
} else {
|
||||||
|
this.mNextMessage = this.conversation.messages
|
||||||
|
.get(index + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return this.mNextMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Message prev() {
|
public Message prev() {
|
||||||
int index = this.conversation.getMessages().indexOf(this);
|
if (this.mPreviousMessage == null) {
|
||||||
if (index <= 0 || index > this.conversation.getMessages().size()) {
|
synchronized (this.conversation.messages) {
|
||||||
return null;
|
int index = this.conversation.messages.indexOf(this);
|
||||||
} else {
|
if (index <= 0 || index > this.conversation.messages.size()) {
|
||||||
return this.conversation.getMessages().get(index - 1);
|
this.mPreviousMessage = null;
|
||||||
|
} else {
|
||||||
|
this.mPreviousMessage = this.conversation.messages
|
||||||
|
.get(index - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return this.mPreviousMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean mergable(Message message) {
|
public boolean mergable(Message message) {
|
||||||
|
|
|
@ -40,7 +40,6 @@ import android.util.SparseArray;
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
import eu.siacs.conversations.ui.StartConversationActivity;
|
|
||||||
import eu.siacs.conversations.utils.CryptoHelper;
|
import eu.siacs.conversations.utils.CryptoHelper;
|
||||||
import eu.siacs.conversations.utils.DNSHelper;
|
import eu.siacs.conversations.utils.DNSHelper;
|
||||||
import eu.siacs.conversations.utils.zlib.ZLibOutputStream;
|
import eu.siacs.conversations.utils.zlib.ZLibOutputStream;
|
||||||
|
|
Loading…
Reference in a new issue