clean up conversation history after swtiching to a different conversation

This commit is contained in:
iNPUTmice 2014-12-17 21:05:47 +01:00
parent de952cc959
commit f00e168752
3 changed files with 12 additions and 4 deletions

View File

@ -19,6 +19,7 @@ public final class Config {
public static final int MESSAGE_MERGE_WINDOW = 20;
public static final int PAGE_SIZE = 50;
public static final int MAX_NUM_PAGES = 3;
public static final int PROGRESS_UI_UPDATE_INTERVAL = 750;

View File

@ -129,6 +129,16 @@ public class Conversation extends AbstractEntity {
}
}
public void trim() {
synchronized (this.messages) {
final int size = messages.size();
final int maxsize = Config.PAGE_SIZE * Config.MAX_NUM_PAGES;
if (size > maxsize) {
this.messages.subList(0, size - maxsize).clear();
}
}
}
public void findUnsentMessagesWithOtrEncryption(OnMessageFound onMessageFound) {
synchronized (this.messages) {
for (Message message : this.messages) {
@ -265,10 +275,6 @@ public class Conversation extends AbstractEntity {
}
}
public String getProfilePhotoString() {
return this.getContact().getProfilePhoto();
}
public String getAccountUuid() {
return this.accountUuid;
}

View File

@ -554,6 +554,7 @@ public class ConversationFragment extends Fragment {
}
if (this.conversation != null) {
this.conversation.setNextMessage(mEditMessage.getText().toString());
this.conversation.trim();
}
this.activity = (ConversationActivity) getActivity();
this.conversation = conversation;