🎨 Conversation rendering improvements

This commit is contained in:
Christian Basler 2018-04-20 07:04:31 +02:00
parent be7a7f1af6
commit e05d27bfbc
3 changed files with 11 additions and 4 deletions

View File

@ -80,7 +80,8 @@ class ConversationListFragment : Fragment(), ListHolder<Label> {
if (!isLoading && !isLastPage) {
if (visibleItemCount + firstVisibleItemPosition >= totalItemCount - 5
&& firstVisibleItemPosition >= 0) {
&& firstVisibleItemPosition >= 0
) {
loadMoreItems()
}
}
@ -183,7 +184,7 @@ class ConversationListFragment : Fragment(), ListHolder<Label> {
val swipeManager = RecyclerViewSwipeManager()
//swipeableConversationAdapter
val adapter = SwipeableConversationAdapter().apply {
val adapter = SwipeableConversationAdapter(context).apply {
setActivateOnItemClick(activateOnItemClick)
}
adapter.eventListener = object : SwipeableConversationAdapter.EventListener {

View File

@ -18,6 +18,7 @@
package ch.dissem.apps.abit.adapter
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Typeface
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
@ -47,7 +48,7 @@ import java.util.*
* @author Christian Basler
* @see [https://github.com/h6ah4i/android-advancedrecyclerview](https://github.com/h6ah4i/android-advancedrecyclerview)
*/
class SwipeableConversationAdapter :
class SwipeableConversationAdapter(ctx: Context) :
RecyclerView.Adapter<SwipeableConversationAdapter.ViewHolder>(),
SwipeableItemAdapter<SwipeableConversationAdapter.ViewHolder>, SwipeableItemConstants {
@ -60,6 +61,8 @@ class SwipeableConversationAdapter :
private var selectedPosition = -1
private var activateOnItemClick: Boolean = false
private val labelUnknown = ctx.getString(R.string.unknown)
fun setActivateOnItemClick(activateOnItemClick: Boolean) {
this.activateOnItemClick = activateOnItemClick
}
@ -172,7 +175,9 @@ class SwipeableConversationAdapter :
// set data
avatar.setImageDrawable(MultiIdenticon(item.participants))
sender.text = item.participants.mapNotNull { it.alias }.joinToString()
sender.text = item.participants.sortedBy {
(it.alias?.let { 0 } ?: 1) + if (it.isChan) 2 else 0
}.map { it.alias ?: labelUnknown }.distinct().joinToString()
subject.text = prepareMessageExtract(item.subject)
extract.text = prepareMessageExtract(item.extract)
if (item.hasUnread()) {

View File

@ -149,4 +149,5 @@ As an alternative you could configure a trusted node in the settings, but as of
<string name="preference_group_advanced_summary"></string>
<string name="preference_group_experimental">Experimental</string>
<string name="preference_group_experimental_summary">Only change if you know what you\'re doing</string>
<string name="unknown">Unknown</string>
</resources>