From 66f26683269c9cbae9ad1c2eb5dc81985af2ef86 Mon Sep 17 00:00:00 2001 From: Fumiaki Yoshimatsu Date: Thu, 18 Jun 2020 09:40:23 -0400 Subject: [PATCH] Do not cache locale in each conversation object. Fixes #9751 --- .../ConversationListAdapter.java | 2 +- .../ConversationListDataSource.java | 7 ++----- .../conversationlist/model/Conversation.java | 16 +++------------- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversationlist/ConversationListAdapter.java b/app/src/main/java/org/thoughtcrime/securesms/conversationlist/ConversationListAdapter.java index ce0f5c6a1..c55874157 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversationlist/ConversationListAdapter.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversationlist/ConversationListAdapter.java @@ -141,7 +141,7 @@ class ConversationListAdapter extends PagedListAdapter { @@ -60,14 +59,13 @@ abstract class ConversationListDataSource extends PositionalDataSource conversations = new ArrayList<>(params.requestedLoadSize); - Locale locale = Locale.getDefault(); int totalCount = getTotalCount(); int effectiveCount = params.requestedStartPosition; try (ThreadDatabase.Reader reader = threadDatabase.readerFor(getCursor(params.requestedStartPosition, params.requestedLoadSize))) { ThreadRecord record; while ((record = reader.getNext()) != null && effectiveCount < totalCount && !isInvalid()) { - conversations.add(new Conversation(record, locale)); + conversations.add(new Conversation(record)); effectiveCount++; } } @@ -86,12 +84,11 @@ abstract class ConversationListDataSource extends PositionalDataSource conversations = new ArrayList<>(params.loadSize); - Locale locale = Locale.getDefault(); try (ThreadDatabase.Reader reader = threadDatabase.readerFor(getCursor(params.startPosition, params.loadSize))) { ThreadRecord record; while ((record = reader.getNext()) != null && !isInvalid()) { - conversations.add(new Conversation(record, locale)); + conversations.add(new Conversation(record)); } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversationlist/model/Conversation.java b/app/src/main/java/org/thoughtcrime/securesms/conversationlist/model/Conversation.java index 16f736e24..c93b268ca 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversationlist/model/Conversation.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversationlist/model/Conversation.java @@ -4,37 +4,27 @@ import androidx.annotation.NonNull; import org.thoughtcrime.securesms.database.model.ThreadRecord; -import java.util.Locale; -import java.util.Objects; - public class Conversation { private final ThreadRecord threadRecord; - private final Locale locale; - public Conversation(@NonNull ThreadRecord threadRecord, @NonNull Locale locale) { + public Conversation(@NonNull ThreadRecord threadRecord) { this.threadRecord = threadRecord; - this.locale = locale; } public @NonNull ThreadRecord getThreadRecord() { return threadRecord; } - public @NonNull Locale getLocale() { - return locale; - } - @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Conversation that = (Conversation) o; - return threadRecord.equals(that.threadRecord) && - locale.equals(that.locale); + return threadRecord.equals(that.threadRecord); } @Override public int hashCode() { - return Objects.hash(threadRecord, locale); + return threadRecord.hashCode(); } }