mirror of
https://github.com/imcarlost/Friendlists.git
synced 2026-04-10 10:56:54 -04:00
implement back button navigation and toolbar labeling
This commit is contained in:
@@ -3,6 +3,7 @@ package com.hako.friendlists.view
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.NavigationUI.setupActionBarWithNavController
|
||||
import com.hako.base.extensions.observeNonNull
|
||||
import com.hako.base.navigation.NavigationRouter
|
||||
import com.hako.friendlists.BuildConfig
|
||||
@@ -36,10 +37,17 @@ class MainActivity : AppCompatActivity() {
|
||||
// Pair.second is a Bundle
|
||||
navController.navigate(pair.first, pair.second)
|
||||
}
|
||||
|
||||
setupActionBarWithNavController(this, navController)
|
||||
}
|
||||
|
||||
private fun setupPicasso() {
|
||||
// Show cache indicator on images just for debug builds
|
||||
picasso.setIndicatorsEnabled(BuildConfig.DEBUG)
|
||||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
navController.navigateUp()
|
||||
return super.onSupportNavigateUp()
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,9 @@ import com.hako.friendlists.R
|
||||
import com.hako.photolist.feature.PHOTOLIST_FRAGMENT_BUNDLE_ALBUM_ID
|
||||
import com.hako.userlist.navigation.UserlistNavigation
|
||||
|
||||
// This sets the fragment title, it's referenced in every navigation
|
||||
const val FRAGMENT_TITLE = "actionTitle"
|
||||
|
||||
class NavigationViewmodel : ViewModel() {
|
||||
|
||||
val navigate = MutableLiveData<Pair<@IdRes Int, Bundle>>()
|
||||
@@ -29,6 +32,7 @@ class NavigationViewmodel : ViewModel() {
|
||||
is UserlistNavigation.ClickedOnUser -> navigate.postValue(
|
||||
buildNavigation(R.id.action_userlistFragment_to_albumlistFragment, Bundle().apply {
|
||||
putInt(ALBUMLIST_FRAGMENT_BUNDLE_USER_ID, event.userId)
|
||||
putString(FRAGMENT_TITLE, event.userName)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user