fix: navigating back home after clicking home section link (#6976)

This commit is contained in:
Thomas W. 2025-01-19 11:53:39 +01:00 committed by GitHub
parent 9893df8763
commit 8911810c76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 49 additions and 16 deletions

View File

@ -33,6 +33,7 @@ import com.github.libretube.ui.models.HomeViewModel
import com.github.libretube.ui.models.SubscriptionsViewModel import com.github.libretube.ui.models.SubscriptionsViewModel
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
class HomeFragment : Fragment(R.layout.fragment_home) { class HomeFragment : Fragment(R.layout.fragment_home) {
private var _binding: FragmentHomeBinding? = null private var _binding: FragmentHomeBinding? = null
private val binding get() = _binding!! private val binding get() = _binding!!
@ -54,23 +55,23 @@ class HomeFragment : Fragment(R.layout.fragment_home) {
} }
binding.featuredTV.setOnClickListener { binding.featuredTV.setOnClickListener {
findNavController().navigate(R.id.subscriptionsFragment) findNavController().navigate(R.id.action_homeFragment_to_subscriptionsFragment)
} }
binding.watchingTV.setOnClickListener { binding.watchingTV.setOnClickListener {
findNavController().navigate(R.id.watchHistoryFragment) findNavController().navigate(R.id.action_homeFragment_to_watchHistoryFragment)
} }
binding.trendingTV.setOnClickListener { binding.trendingTV.setOnClickListener {
findNavController().navigate(R.id.trendsFragment) findNavController().navigate(R.id.action_homeFragment_to_trendsFragment)
} }
binding.playlistsTV.setOnClickListener { binding.playlistsTV.setOnClickListener {
findNavController().navigate(R.id.libraryFragment) findNavController().navigate(R.id.action_homeFragment_to_libraryFragment)
} }
binding.bookmarksTV.setOnClickListener { binding.bookmarksTV.setOnClickListener {
findNavController().navigate(R.id.libraryFragment) findNavController().navigate(R.id.action_homeFragment_to_libraryFragment)
} }
binding.refresh.setOnRefreshListener { binding.refresh.setOnRefreshListener {

View File

@ -8,7 +8,36 @@
android:id="@+id/homeFragment" android:id="@+id/homeFragment"
android:name="com.github.libretube.ui.fragments.HomeFragment" android:name="com.github.libretube.ui.fragments.HomeFragment"
android:label="fragment_home" android:label="fragment_home"
tools:layout="@layout/fragment_home" /> tools:layout="@layout/fragment_home">
<action
android:id="@+id/action_homeFragment_to_libraryFragment"
app:destination="@id/libraryFragment"
app:popUpTo="@id/homeFragment"
app:popUpToInclusive="false"
app:popUpToSaveState="true"
app:restoreState="true" />
<action
android:id="@+id/action_homeFragment_to_watchHistoryFragment"
app:destination="@id/watchHistoryFragment"
app:popUpTo="@id/homeFragment"
app:popUpToInclusive="false"
app:popUpToSaveState="true"
app:restoreState="true" />
<action
android:id="@+id/action_homeFragment_to_trendsFragment"
app:destination="@id/trendsFragment"
app:popUpTo="@id/homeFragment"
app:popUpToInclusive="false"
app:popUpToSaveState="true"
app:restoreState="true" />
<action
android:id="@+id/action_homeFragment_to_subscriptionsFragment"
app:destination="@id/subscriptionsFragment"
app:popUpTo="@id/homeFragment"
app:popUpToInclusive="false"
app:popUpToSaveState="true"
app:restoreState="true" />
</fragment>
<fragment <fragment
android:id="@+id/trendsFragment" android:id="@+id/trendsFragment"
android:name="com.github.libretube.ui.fragments.TrendsFragment" android:name="com.github.libretube.ui.fragments.TrendsFragment"
@ -43,17 +72,17 @@
android:id="@+id/channelFragment" android:id="@+id/channelFragment"
android:name="com.github.libretube.ui.fragments.ChannelFragment" android:name="com.github.libretube.ui.fragments.ChannelFragment"
android:label="channel" android:label="channel"
tools:layout="@layout/fragment_channel" > tools:layout="@layout/fragment_channel">
<argument <argument
android:name="channelId" android:name="channelId"
android:defaultValue="@null"
app:argType="string" app:argType="string"
app:nullable="true" app:nullable="true" />
android:defaultValue="@null" />
<argument <argument
android:name="channelName" android:name="channelName"
android:defaultValue="@null"
app:argType="string" app:argType="string"
app:nullable="true" app:nullable="true" />
android:defaultValue="@null" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/playlistFragment" android:id="@+id/playlistFragment"
@ -66,9 +95,9 @@
app:nullable="false" /> app:nullable="false" />
<argument <argument
android:name="playlistType" android:name="playlistType"
android:defaultValue="PUBLIC"
app:argType="com.github.libretube.enums.PlaylistType" app:argType="com.github.libretube.enums.PlaylistType"
app:nullable="false" app:nullable="false" />
android:defaultValue="PUBLIC" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/watchHistoryFragment" android:id="@+id/watchHistoryFragment"
@ -81,10 +110,13 @@
android:label="@string/downloads" android:label="@string/downloads"
tools:layout="@layout/fragment_downloads" /> tools:layout="@layout/fragment_downloads" />
<action android:id="@+id/openChannel" <action
android:id="@+id/openChannel"
app:destination="@id/channelFragment" /> app:destination="@id/channelFragment" />
<action android:id="@+id/openPlaylist" <action
android:id="@+id/openPlaylist"
app:destination="@id/playlistFragment" /> app:destination="@id/playlistFragment" />
<action android:id="@+id/showSearchResults" <action
android:id="@+id/showSearchResults"
app:destination="@id/searchResultFragment" /> app:destination="@id/searchResultFragment" />
</navigation> </navigation>