From 86df932ce8e917c75523e2cb03b869aeaa6c847c Mon Sep 17 00:00:00 2001 From: Pavel Poley Date: Mon, 6 Jun 2022 16:18:05 +0300 Subject: [PATCH] fix scroll position resetting on refresh --- .../smsmessenger/activities/ThreadActivity.kt | 5 +++++ .../com/simplemobiletools/smsmessenger/helpers/Config.kt | 1 - .../simplemobiletools/smsmessenger/models/ThreadDateTime.kt | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt index 9c43960f..2959d69d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt @@ -227,6 +227,11 @@ class ThreadActivity : SimpleActivity() { ArrayList() } + messages.sortBy { it.date } + if (messages.size > MESSAGES_LIMIT) { + messages = ArrayList(messages.takeLast(MESSAGES_LIMIT)) + } + setupParticipants() setupAdapter() diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt index edca4fef..77550a12 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt @@ -3,7 +3,6 @@ package com.simplemobiletools.smsmessenger.helpers import android.content.Context import com.simplemobiletools.commons.helpers.BaseConfig import com.simplemobiletools.smsmessenger.models.Conversation -import java.util.HashSet class Config(context: Context) : BaseConfig(context) { companion object { diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/models/ThreadDateTime.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/models/ThreadDateTime.kt index d69d81fa..aae15f0f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/models/ThreadDateTime.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/models/ThreadDateTime.kt @@ -1,3 +1,3 @@ package com.simplemobiletools.smsmessenger.models -open class ThreadDateTime(val date: Int, val simID: String) : ThreadItem() +data class ThreadDateTime(val date: Int, val simID: String) : ThreadItem()