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