mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-13 15:54:59 +01:00
Fix search & state transitions
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
d66134c663
commit
d5abcc01a3
@ -220,11 +220,11 @@ class ConversationsListView : BaseView(), OnQueryTextListener,
|
||||
)
|
||||
) {
|
||||
view?.stateWithMessageView?.errorStateImageView?.setImageResource(
|
||||
R.drawable.ic_cloud_off_white_24dp
|
||||
drawable.ic_cloud_off_white_24dp
|
||||
)
|
||||
} else {
|
||||
view?.stateWithMessageView?.errorStateImageView?.setImageResource(
|
||||
R.drawable.ic_announcement_white_24dp
|
||||
drawable.ic_announcement_white_24dp
|
||||
)
|
||||
}
|
||||
view?.floatingActionButton?.visibility = View.GONE
|
||||
@ -232,7 +232,7 @@ class ConversationsListView : BaseView(), OnQueryTextListener,
|
||||
view?.floatingActionButton?.visibility = View.VISIBLE
|
||||
view?.stateWithMessageView?.errorStateTextView?.text =
|
||||
resources?.getText(R.string.nc_conversations_empty)
|
||||
view?.stateWithMessageView?.errorStateImageView?.setImageResource(R.drawable.ic_logo)
|
||||
view?.stateWithMessageView?.errorStateImageView?.setImageResource(drawable.ic_logo)
|
||||
}
|
||||
|
||||
view?.stateWithMessageView?.visibility = View.VISIBLE
|
||||
@ -326,8 +326,7 @@ class ConversationsListView : BaseView(), OnQueryTextListener,
|
||||
override fun onItemLongClick(position: Int) {
|
||||
val clickedItem = recyclerViewAdapter.getItem(position)
|
||||
clickedItem?.let {
|
||||
val conversationItem = it as ConversationItem
|
||||
val conversation = conversationItem.model
|
||||
val conversation = (it as ConversationItem).model
|
||||
|
||||
activity?.let { activity ->
|
||||
MaterialDialog(activity, BottomSheet(WRAP_CONTENT)).show {
|
||||
|
@ -92,10 +92,14 @@ class ConversationsListViewModel constructor(
|
||||
object : UseCaseResponse<GenericOverall> {
|
||||
override fun onSuccess(result: GenericOverall) {
|
||||
// TODO: Use binary search to find the right room
|
||||
conversations.find { it.roomId == conversation.roomId }?.let {
|
||||
conversations.remove(it)
|
||||
conversationsLiveListData.value = conversations
|
||||
}
|
||||
conversations.find { it.roomId == conversation.roomId }
|
||||
?.let {
|
||||
conversations.remove(it)
|
||||
conversationsLiveListData.value = conversations
|
||||
if (conversations.isEmpty()) {
|
||||
viewState.value = LOADED_EMPTY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(errorModel: ErrorModel?) {
|
||||
@ -113,10 +117,14 @@ class ConversationsListViewModel constructor(
|
||||
object : UseCaseResponse<GenericOverall> {
|
||||
override fun onSuccess(result: GenericOverall) {
|
||||
// TODO: Use binary search to find the right room
|
||||
conversations.find { it.roomId == conversation.roomId }?.let {
|
||||
conversations.remove(it)
|
||||
conversationsLiveListData.value = conversations
|
||||
}
|
||||
conversations.find { it.roomId == conversation.roomId }
|
||||
?.let {
|
||||
conversations.remove(it)
|
||||
conversationsLiveListData.value = conversations
|
||||
if (conversations.isEmpty()) {
|
||||
viewState.value = LOADED_EMPTY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(errorModel: ErrorModel?) {
|
||||
@ -138,11 +146,12 @@ class ConversationsListViewModel constructor(
|
||||
object : UseCaseResponse<GenericOverall> {
|
||||
override fun onSuccess(result: GenericOverall) {
|
||||
// TODO: Use binary search to find the right room
|
||||
conversations.find { it.roomId == conversation.roomId }?.apply {
|
||||
updating = false
|
||||
isFavorite = favorite
|
||||
conversationsLiveListData.value = conversations
|
||||
}
|
||||
conversations.find { it.roomId == conversation.roomId }
|
||||
?.apply {
|
||||
updating = false
|
||||
isFavorite = favorite
|
||||
conversationsLiveListData.value = conversations
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(errorModel: ErrorModel?) {
|
||||
@ -154,8 +163,8 @@ class ConversationsListViewModel constructor(
|
||||
fun loadConversations() {
|
||||
currentUser = userUtils.currentUser
|
||||
|
||||
if (viewState.value?.equals(FAILED)!! || !getConversationsUseCase.isUserInitialized() ||
|
||||
getConversationsUseCase.user != currentUser
|
||||
if ((FAILED).equals(viewState.value) || (LOADED_EMPTY).equals(viewState.value) ||
|
||||
!getConversationsUseCase.isUserInitialized() || getConversationsUseCase.user != currentUser
|
||||
) {
|
||||
getConversationsUseCase.user = currentUser
|
||||
viewState.value = LOADING
|
||||
@ -294,10 +303,14 @@ class ConversationsListViewModel constructor(
|
||||
return items
|
||||
}
|
||||
|
||||
private fun setConversationUpdateStatus(conversation: Conversation, value: Boolean) {
|
||||
conversations.find { it.roomId == conversation.roomId }?.apply {
|
||||
updating = value
|
||||
conversationsLiveListData.value = conversations
|
||||
}
|
||||
private fun setConversationUpdateStatus(
|
||||
conversation: Conversation,
|
||||
value: Boolean
|
||||
) {
|
||||
conversations.find { it.roomId == conversation.roomId }
|
||||
?.apply {
|
||||
updating = value
|
||||
conversationsLiveListData.value = conversations
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,8 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/generic_rv_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<include layout="@layout/view_states"/>
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
android:title="@string/nc_search"
|
||||
android:icon="@drawable/ic_search_white_24dp"
|
||||
app:showAsAction="collapseActionView|always"
|
||||
android:visible="false"
|
||||
android:animateLayoutChanges="true"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user