Fix layout issue

This commit is contained in:
nielsandriesse 2021-06-07 16:36:05 +10:00
parent 7e6cd7c86f
commit 5761ce959b
2 changed files with 8 additions and 6 deletions

View File

@ -63,9 +63,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity() {
private fun setUpRecyclerView() { private fun setUpRecyclerView() {
conversationRecyclerView.adapter = adapter conversationRecyclerView.adapter = adapter
val layoutManager = LinearLayoutManager(this) val layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, true)
layoutManager.reverseLayout = true
layoutManager.stackFromEnd = true
conversationRecyclerView.layoutManager = layoutManager conversationRecyclerView.layoutManager = layoutManager
// Workaround for the fact that CursorRecyclerViewAdapter doesn't auto-update automatically (even though it says it will) // Workaround for the fact that CursorRecyclerViewAdapter doesn't auto-update automatically (even though it says it will)
LoaderManager.getInstance(this).restartLoader(0, null, object : LoaderManager.LoaderCallbacks<Cursor> { LoaderManager.getInstance(this).restartLoader(0, null, object : LoaderManager.LoaderCallbacks<Cursor> {

View File

@ -63,7 +63,7 @@ class ConversationAdapter(context: Context, cursor: Cursor, private val onItemPr
is VisibleMessageViewHolder -> { is VisibleMessageViewHolder -> {
val view = viewHolder.view val view = viewHolder.view
view.background = if (selectedItems.contains(message)) { view.background = if (selectedItems.contains(message)) {
ColorDrawable(context.resources.getColorWithID(R.color.red, context.theme)) ColorDrawable(context.resources.getColorWithID(R.color.accent, context.theme))
} else { } else {
null null
} }
@ -92,12 +92,16 @@ class ConversationAdapter(context: Context, cursor: Cursor, private val onItemPr
} }
private fun getMessageBefore(position: Int, cursor: Cursor): MessageRecord? { private fun getMessageBefore(position: Int, cursor: Cursor): MessageRecord? {
if (!cursor.moveToPosition(position - 1)) { return null } // The message that's visually before the current one is actually after the current
// one for the cursor because the layout is reversed
if (!cursor.moveToPosition(position + 1)) { return null }
return messageDB.readerFor(cursor).current return messageDB.readerFor(cursor).current
} }
private fun getMessageAfter(position: Int, cursor: Cursor): MessageRecord? { private fun getMessageAfter(position: Int, cursor: Cursor): MessageRecord? {
if (!cursor.moveToPosition(position + 1)) { return null } // The message that's visually after the current one is actually before the current
// one for the cursor because the layout is reversed
if (!cursor.moveToPosition(position - 1)) { return null }
return messageDB.readerFor(cursor).current return messageDB.readerFor(cursor).current
} }