From bd9c53a96c96aa870d3edcb8db44a52f6afb2d42 Mon Sep 17 00:00:00 2001
From: Maxime NATUREL <46314705+mnaturel@users.noreply.github.com>
Date: Fri, 30 Dec 2022 14:57:37 +0100
Subject: [PATCH] Show message when list is empty
---
.../src/main/res/values/strings.xml | 3 ++-
.../roomprofile/polls/RoomPollsFragment.kt | 2 +-
.../polls/active/RoomActivePollsFragment.kt | 8 +++++--
.../res/layout/fragment_room_polls_list.xml | 23 ++++++++++++++++++-
4 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml
index e0f2f7b288..43507e60ce 100644
--- a/library/ui-strings/src/main/res/values/strings.xml
+++ b/library/ui-strings/src/main/res/values/strings.xml
@@ -3191,7 +3191,8 @@
Voters see results as soon as they have voted
Closed poll
Results are only revealed when you end the poll
- Active polls
+ Active polls
+ There are no active polls in this room
Share location
diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/polls/RoomPollsFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/polls/RoomPollsFragment.kt
index 7617da71df..5c150f4391 100644
--- a/vector/src/main/java/im/vector/app/features/roomprofile/polls/RoomPollsFragment.kt
+++ b/vector/src/main/java/im/vector/app/features/roomprofile/polls/RoomPollsFragment.kt
@@ -66,7 +66,7 @@ class RoomPollsFragment : VectorBaseFragment() {
tabLayoutMediator = TabLayoutMediator(views.roomPollsTabs, views.roomPollsViewPager) { tab, position ->
when (position) {
- 0 -> tab.text = getString(R.string.active_polls)
+ 0 -> tab.text = getString(R.string.room_polls_active)
}
}.also { it.attach() }
}
diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/polls/active/RoomActivePollsFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/polls/active/RoomActivePollsFragment.kt
index b4e812a49e..4cc318edf9 100644
--- a/vector/src/main/java/im/vector/app/features/roomprofile/polls/active/RoomActivePollsFragment.kt
+++ b/vector/src/main/java/im/vector/app/features/roomprofile/polls/active/RoomActivePollsFragment.kt
@@ -20,9 +20,11 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.core.view.isVisible
import com.airbnb.mvrx.parentFragmentViewModel
import com.airbnb.mvrx.withState
import dagger.hilt.android.AndroidEntryPoint
+import im.vector.app.R
import im.vector.app.core.extensions.cleanup
import im.vector.app.core.extensions.configureWith
import im.vector.app.core.platform.VectorBaseFragment
@@ -55,7 +57,8 @@ class RoomActivePollsFragment :
private fun setupList() {
roomActivePollsController.listener = this
- views.activePollsList.configureWith(roomActivePollsController)
+ views.roomPollsList.configureWith(roomActivePollsController)
+ views.roomPollsEmptyTitle.text = getString(R.string.room_polls_active_no_item)
}
override fun onDestroyView() {
@@ -64,7 +67,7 @@ class RoomActivePollsFragment :
}
private fun cleanUpList() {
- views.activePollsList.cleanup()
+ views.roomPollsList.cleanup()
roomActivePollsController.listener = null
}
@@ -79,6 +82,7 @@ class RoomActivePollsFragment :
private fun renderList(polls: List) {
roomActivePollsController.setData(polls)
+ views.roomPollsEmptyTitle.isVisible = polls.isEmpty()
}
override fun onPollClicked(pollId: String) {
diff --git a/vector/src/main/res/layout/fragment_room_polls_list.xml b/vector/src/main/res/layout/fragment_room_polls_list.xml
index 1aa6625ae5..6949bb0c67 100644
--- a/vector/src/main/res/layout/fragment_room_polls_list.xml
+++ b/vector/src/main/res/layout/fragment_room_polls_list.xml
@@ -6,7 +6,7 @@
android:layout_height="match_parent">
+
+
+