allow displaying older messages
This commit is contained in:
parent
d2f824ed66
commit
ec157ba19e
|
@ -367,20 +367,21 @@ class ThreadActivity : SimpleActivity() {
|
|||
private fun fetchNextMessages() {
|
||||
if (messages.isEmpty() || allMessagesFetched || loadingOlderMessages) return
|
||||
|
||||
//toast("fetchNextMessages")
|
||||
|
||||
val date = messages.first().date
|
||||
if (oldestMessageDate == date) {
|
||||
allMessagesFetched = true
|
||||
return
|
||||
}
|
||||
|
||||
toast("fetchNextMessages")
|
||||
|
||||
oldestMessageDate = date
|
||||
loadingOlderMessages = true
|
||||
|
||||
ensureBackgroundThread {
|
||||
val olderMessages = getMessages(threadId, true, oldestMessageDate)
|
||||
messages.addAll(0, olderMessages)
|
||||
threadItems = getThreadItems()
|
||||
|
||||
allMessagesFetched = olderMessages.size < MESSAGES_LIMIT || olderMessages.size == 0
|
||||
|
||||
|
@ -391,7 +392,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
runOnUiThread {
|
||||
loadingOlderMessages = false
|
||||
val itemAtRefreshIndex = messages.indexOfFirst { it == topItemAtRefresh }
|
||||
adapter.updateMessages(getThreadItems(), itemAtRefreshIndex)
|
||||
adapter.updateMessages(threadItems, itemAtRefreshIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ const val FILE_SIZE_600_KB = 614_400L
|
|||
const val FILE_SIZE_1_MB = 1_048_576L
|
||||
const val FILE_SIZE_2_MB = 2_097_152L
|
||||
|
||||
const val MESSAGES_LIMIT = 15
|
||||
const val MESSAGES_LIMIT = 100
|
||||
|
||||
fun refreshMessages() {
|
||||
EventBus.getDefault().post(Events.RefreshMessages())
|
||||
|
|
Loading…
Reference in New Issue