mirror of
https://github.com/element-hq/element-android
synced 2024-11-25 02:45:37 +03:00
Group navigation cleanup
This commit is contained in:
parent
ad601c7d5a
commit
73b55fd975
4 changed files with 11 additions and 9 deletions
|
@ -34,9 +34,10 @@ class HomeNavigator {
|
||||||
fun openSelectedGroup(groupSummary: GroupSummary) {
|
fun openSelectedGroup(groupSummary: GroupSummary) {
|
||||||
Timber.v("Open selected group ${groupSummary.groupId}")
|
Timber.v("Open selected group ${groupSummary.groupId}")
|
||||||
activity?.let {
|
activity?.let {
|
||||||
|
it.drawerLayout?.closeDrawer(GravityCompat.START)
|
||||||
|
|
||||||
val args = HomeDetailParams(groupSummary.groupId, groupSummary.displayName, groupSummary.avatarUrl)
|
val args = HomeDetailParams(groupSummary.groupId, groupSummary.displayName, groupSummary.avatarUrl)
|
||||||
val homeDetailFragment = HomeDetailFragment.newInstance(args)
|
val homeDetailFragment = HomeDetailFragment.newInstance(args)
|
||||||
it.drawerLayout?.closeDrawer(GravityCompat.START)
|
|
||||||
it.replaceFragment(homeDetailFragment, R.id.homeDetailFragmentContainer)
|
it.replaceFragment(homeDetailFragment, R.id.homeDetailFragmentContainer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +48,6 @@ class HomeNavigator {
|
||||||
Timber.v("Open room detail $roomId - $eventId")
|
Timber.v("Open room detail $roomId - $eventId")
|
||||||
activity?.let {
|
activity?.let {
|
||||||
//TODO enable eventId permalink. It doesn't work enough at the moment.
|
//TODO enable eventId permalink. It doesn't work enough at the moment.
|
||||||
it.drawerLayout?.closeDrawer(GravityCompat.START)
|
|
||||||
navigator.openRoom(roomId, it)
|
navigator.openRoom(roomId, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,8 @@ class GroupListFragment : VectorBaseFragment(), GroupSummaryController.Callback
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
groupController.callback = this
|
groupController.callback = this
|
||||||
stateView.contentView = epoxyRecyclerView
|
stateView.contentView = groupListEpoxyRecyclerView
|
||||||
epoxyRecyclerView.setController(groupController)
|
groupListEpoxyRecyclerView.setController(groupController)
|
||||||
viewModel.subscribe { renderState(it) }
|
viewModel.subscribe { renderState(it) }
|
||||||
viewModel.openGroupLiveData.observeEvent(this) {
|
viewModel.openGroupLiveData.observeEvent(this) {
|
||||||
homeNavigator.openSelectedGroup(it)
|
homeNavigator.openSelectedGroup(it)
|
||||||
|
|
|
@ -84,7 +84,8 @@ class GroupListViewModel(initialState: GroupListViewState,
|
||||||
|
|
||||||
private fun observeGroupSummaries() {
|
private fun observeGroupSummaries() {
|
||||||
session
|
session
|
||||||
.rx().liveGroupSummaries()
|
.rx()
|
||||||
|
.liveGroupSummaries()
|
||||||
.map {
|
.map {
|
||||||
val myUser = session.getUser(session.sessionParams.credentials.userId)
|
val myUser = session.getUser(session.sessionParams.credentials.userId)
|
||||||
val allCommunityGroup = GroupSummary(
|
val allCommunityGroup = GroupSummary(
|
||||||
|
@ -94,6 +95,7 @@ class GroupListViewModel(initialState: GroupListViewState,
|
||||||
listOf(allCommunityGroup) + it
|
listOf(allCommunityGroup) + it
|
||||||
}
|
}
|
||||||
.execute { async ->
|
.execute { async ->
|
||||||
|
// TODO Phase2 Handle the case where the selected group is deleted on another client
|
||||||
val newSelectedGroup = selectedGroup ?: async()?.firstOrNull()
|
val newSelectedGroup = selectedGroup ?: async()?.firstOrNull()
|
||||||
copy(asyncGroups = async, selectedGroup = newSelectedGroup)
|
copy(asyncGroups = async, selectedGroup = newSelectedGroup)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
|
||||||
<im.vector.riotredesign.core.platform.StateView xmlns:android="http://schemas.android.com/apk/res/android"
|
<im.vector.riotredesign.core.platform.StateView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/stateView"
|
android:id="@+id/stateView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<com.airbnb.epoxy.EpoxyRecyclerView
|
<com.airbnb.epoxy.EpoxyRecyclerView
|
||||||
android:id="@+id/epoxyRecyclerView"
|
android:id="@+id/groupListEpoxyRecyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent"
|
||||||
|
tools:listitem="@layout/item_group" />
|
||||||
|
|
||||||
</im.vector.riotredesign.core.platform.StateView>
|
</im.vector.riotredesign.core.platform.StateView>
|
||||||
|
|
Loading…
Reference in a new issue