forked from GitHub-Mirror/riotX-android
Group/Room list : show filtered room when a group is selected
This commit is contained in:
@ -48,6 +48,8 @@ class HomeViewModel(initialState: HomeViewState, private val session: Session) :
|
||||
withState { state ->
|
||||
if (state.selectedGroup?.groupId != action.groupSummary.groupId) {
|
||||
setState { copy(selectedGroup = action.groupSummary) }
|
||||
} else {
|
||||
setState { copy(selectedGroup = null) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -56,6 +58,7 @@ class HomeViewModel(initialState: HomeViewState, private val session: Session) :
|
||||
session
|
||||
.rx().liveRoomSummaries()
|
||||
.execute { async ->
|
||||
|
||||
val summaries = async()
|
||||
val directRooms = summaries?.filter { it.isDirect } ?: emptyList()
|
||||
val groupRooms = summaries?.filter { !it.isDirect } ?: emptyList()
|
||||
|
@ -3,6 +3,7 @@ package im.vector.riotredesign.features.home.group
|
||||
import android.widget.ImageView
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.epoxy.KotlinModel
|
||||
import im.vector.riotredesign.core.platform.CheckableFrameLayout
|
||||
import im.vector.riotredesign.features.home.AvatarRenderer
|
||||
|
||||
|
||||
@ -14,9 +15,11 @@ data class GroupSummaryItem(
|
||||
) : KotlinModel(R.layout.item_group) {
|
||||
|
||||
private val avatarImageView by bind<ImageView>(R.id.groupAvatarImageView)
|
||||
private val rootView by bind<CheckableFrameLayout>(R.id.itemGroupLayout)
|
||||
|
||||
override fun bind() {
|
||||
avatarImageView.setOnClickListener { listener?.invoke() }
|
||||
rootView.isSelected = isSelected
|
||||
rootView.setOnClickListener { listener?.invoke() }
|
||||
AvatarRenderer.render(avatarUrl, groupName.toString(), avatarImageView)
|
||||
}
|
||||
}
|
@ -25,7 +25,16 @@ class RoomSummaryController(private val callback: Callback? = null
|
||||
.addTo(this)
|
||||
|
||||
if (isDirectRoomsExpanded) {
|
||||
buildRoomModels(viewState.directRooms, viewState.selectedRoom)
|
||||
val filteredDirectRooms = viewState.directRooms.filter {
|
||||
if (viewState.selectedGroup == null) {
|
||||
true
|
||||
} else {
|
||||
it.otherMemberIds
|
||||
.intersect(viewState.selectedGroup.userIds)
|
||||
.isNotEmpty()
|
||||
}
|
||||
}
|
||||
buildRoomModels(filteredDirectRooms, viewState.selectedRoom)
|
||||
}
|
||||
|
||||
RoomCategoryItem(
|
||||
@ -40,7 +49,10 @@ class RoomSummaryController(private val callback: Callback? = null
|
||||
.addTo(this)
|
||||
|
||||
if (isGroupRoomsExpanded) {
|
||||
buildRoomModels(viewState.groupRooms, viewState.selectedRoom)
|
||||
val filteredGroupRooms = viewState.groupRooms.filter {
|
||||
viewState.selectedGroup?.roomIds?.contains(it.roomId) ?: true
|
||||
}
|
||||
buildRoomModels(filteredGroupRooms, viewState.selectedRoom)
|
||||
}
|
||||
|
||||
}
|
||||
|
13
app/src/main/res/drawable/fg_group_item.xml
Normal file
13
app/src/main/res/drawable/fg_group_item.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_selected="true">
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<stroke android:width="2dp" android:color="@color/pale_teal" />
|
||||
</shape>
|
||||
|
||||
</item>
|
||||
<item android:drawable="@android:color/transparent" />
|
||||
|
||||
</selector>
|
@ -7,7 +7,7 @@
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/groupListFragmentContainer"
|
||||
android:layout_width="56dp"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<FrameLayout
|
||||
|
@ -12,9 +12,11 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/groupAvatarImageView"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:duplicateParentState="true"
|
||||
android:foreground="@drawable/fg_group_item"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
|
||||
</im.vector.riotredesign.core.platform.CheckableFrameLayout>
|
@ -2,15 +2,17 @@
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/roomCategoryRootView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:id="@+id/roomCategoryRootView"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="24dp"
|
||||
android:padding="16dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingBottom="8dp"
|
||||
tools:background="@color/pale_grey">
|
||||
|
||||
<TextView
|
||||
|
Reference in New Issue
Block a user