mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Show empty state view once messages load (Or no messages)
In ChatFragment.setChatMessages(), update the RecyclerViewEmptySupport’s state to EMPTY when the message list is empty or to DISPLAYING_DATA otherwise. This replaces the loading spinner with the correct empty or data UI.
This commit is contained in:
parent
061eeea313
commit
a4ff489e51
1 changed files with 8 additions and 1 deletions
|
|
@ -31,6 +31,7 @@ import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar.Companion.showSna
|
|||
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar.SnackbarDisplayType
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import com.habitrpg.common.habitica.extensions.observeOnce
|
||||
import com.habitrpg.common.habitica.helpers.RecyclerViewState
|
||||
import com.habitrpg.common.habitica.helpers.launchCatching
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.delay
|
||||
|
|
@ -219,11 +220,17 @@ open class ChatFragment : BaseFragment<FragmentChatBinding>() {
|
|||
chatAdapter?.data = chatMessages
|
||||
binding?.chatBarView?.chatMessages = chatMessages
|
||||
|
||||
viewModel.gotNewMessages = true
|
||||
binding?.recyclerView?.state = if (chatMessages.isEmpty()) {
|
||||
RecyclerViewState.EMPTY
|
||||
} else {
|
||||
RecyclerViewState.DISPLAYING_DATA
|
||||
}
|
||||
|
||||
viewModel.gotNewMessages = true
|
||||
markMessagesAsSeen()
|
||||
}
|
||||
|
||||
|
||||
private fun sendChatMessage(chatText: String) {
|
||||
viewModel.postGroupChat(
|
||||
chatText,
|
||||
|
|
|
|||
Loading…
Reference in a new issue