From 6585876b2572831d780c3caf7fe0e81ddf703df9 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Sun, 22 Apr 2018 11:29:39 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Add=20number=20of=20messages=20t?= =?UTF-8?q?o=20conversation=20list=20item?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/SwipeableConversationAdapter.kt | 10 +- app/src/main/res/layout/conversation_row.xml | 125 ++++++++++++++++++ 2 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/layout/conversation_row.xml diff --git a/app/src/main/java/ch/dissem/apps/abit/adapter/SwipeableConversationAdapter.kt b/app/src/main/java/ch/dissem/apps/abit/adapter/SwipeableConversationAdapter.kt index 19f99aa..ec2332d 100644 --- a/app/src/main/java/ch/dissem/apps/abit/adapter/SwipeableConversationAdapter.kt +++ b/app/src/main/java/ch/dissem/apps/abit/adapter/SwipeableConversationAdapter.kt @@ -82,6 +82,7 @@ class SwipeableConversationAdapter(ctx: Context) : val sender = v.findViewById(R.id.sender)!! val subject = v.findViewById(R.id.subject)!! val extract = v.findViewById(R.id.text)!! + val count = v.findViewById(R.id.count)!! override fun getSwipeableContainerView() = container } @@ -149,7 +150,7 @@ class SwipeableConversationAdapter(ctx: Context) : override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val inflater = LayoutInflater.from(parent.context) - val v = inflater.inflate(R.layout.message_row, parent, false) + val v = inflater.inflate(R.layout.conversation_row, parent, false) return ViewHolder(v) } @@ -180,6 +181,13 @@ class SwipeableConversationAdapter(ctx: Context) : }.map { it.alias ?: labelUnknown }.distinct().joinToString() subject.text = prepareMessageExtract(item.subject) extract.text = prepareMessageExtract(item.extract) + item.messages.size.let { size -> + if (size <= 1) { + count.text = "" + } else { + count.text = size.toString() + } + } if (item.hasUnread()) { sender.typeface = Typeface.DEFAULT_BOLD subject.typeface = Typeface.DEFAULT_BOLD diff --git a/app/src/main/res/layout/conversation_row.xml b/app/src/main/res/layout/conversation_row.xml new file mode 100644 index 0000000..84a8b35 --- /dev/null +++ b/app/src/main/res/layout/conversation_row.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + +