saket / InboxRecyclerView

Build expandable descendant navigation, inspired by Google Inbox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make the library suitable for Navigation Component

JonathanImperato opened this issue · comments

This is a Request.

Since I am using many Architecture Component, and in this case, the Navigation one, which I am addicted to, and many others like me, I was wondering if you could make your library compatible with it. It would be really wonderful and even easier to use your Library.

Thanks for you hard work and efforts!

Any ideas on what needs to be changed for making InboxRecyclerView compatible with the navigation library?

Any ideas on what needs to be changed for making InboxRecyclerView compatible with the navigation library?

Right now you are attaching the fragment by doing so
supportFragmentManager .beginTransaction() .replace(emailPageLayout.id, threadFragment) .commitNowAllowingStateLoss()

as emailPageLayout page layout acts as a Fragment container.

The point with the navigation component is that you already have a Fragment container,

<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHost
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:defaultNavHost="true"
app:navGraph="@navigation/navigation_graph"/>

that you use the first time by creating an instance of a NavHostFragment by attaching the Nav Graph
host = NavHostFragment.create(R.navigation.navigation_graph)
and committing the fragment transaction
supportFragmentManager.beginTransaction().replace(R.id.nav_host_fragment, host!!) .setPrimaryNavigationFragment(host).commit()

From this point forward you use the Navigation Component methods to navigate between destinations (other fragments).

So, I would be able to use your library by simply by doing findNavController(R.id.nav_host_fragment).navigate(expandableFragment) and not by attacching a new fragment Container inside my fragment.

The sample app shows just one way of building the UI using the page as the fragment, but you are free to not do that. You can instead keep the page as a child View inside NavHost fragment. Does that make sense?

The sample app shows just one way of building the UI using the page as the fragment, but you are free to not do that. You can instead keep the page as a child View inside NavHost fragment. Does that make sense?

I'll give it a try

Closing this in the meantime. Feel free to reopen it.