Group navigation cleanup

This commit is contained in:
Benoit Marty 2019-06-19 10:47:55 +02:00
parent ad601c7d5a
commit 73b55fd975
4 changed files with 11 additions and 9 deletions

View File

@ -34,9 +34,10 @@ class HomeNavigator {
fun openSelectedGroup(groupSummary: GroupSummary) {
Timber.v("Open selected group ${groupSummary.groupId}")
activity?.let {
it.drawerLayout?.closeDrawer(GravityCompat.START)
val args = HomeDetailParams(groupSummary.groupId, groupSummary.displayName, groupSummary.avatarUrl)
val homeDetailFragment = HomeDetailFragment.newInstance(args)
it.drawerLayout?.closeDrawer(GravityCompat.START)
it.replaceFragment(homeDetailFragment, R.id.homeDetailFragmentContainer)
}
}
@ -47,7 +48,6 @@ class HomeNavigator {
Timber.v("Open room detail $roomId - $eventId")
activity?.let {
//TODO enable eventId permalink. It doesn't work enough at the moment.
it.drawerLayout?.closeDrawer(GravityCompat.START)
navigator.openRoom(roomId, it)
}
}

View File

@ -46,8 +46,8 @@ class GroupListFragment : VectorBaseFragment(), GroupSummaryController.Callback
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
groupController.callback = this
stateView.contentView = epoxyRecyclerView
epoxyRecyclerView.setController(groupController)
stateView.contentView = groupListEpoxyRecyclerView
groupListEpoxyRecyclerView.setController(groupController)
viewModel.subscribe { renderState(it) }
viewModel.openGroupLiveData.observeEvent(this) {
homeNavigator.openSelectedGroup(it)

View File

@ -84,7 +84,8 @@ class GroupListViewModel(initialState: GroupListViewState,
private fun observeGroupSummaries() {
session
.rx().liveGroupSummaries()
.rx()
.liveGroupSummaries()
.map {
val myUser = session.getUser(session.sessionParams.credentials.userId)
val allCommunityGroup = GroupSummary(
@ -94,6 +95,7 @@ class GroupListViewModel(initialState: GroupListViewState,
listOf(allCommunityGroup) + it
}
.execute { async ->
// TODO Phase2 Handle the case where the selected group is deleted on another client
val newSelectedGroup = selectedGroup ?: async()?.firstOrNull()
copy(asyncGroups = async, selectedGroup = newSelectedGroup)
}

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent">
<com.airbnb.epoxy.EpoxyRecyclerView
android:id="@+id/epoxyRecyclerView"
android:id="@+id/groupListEpoxyRecyclerView"
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>