Replace deprecated onBackPressed
This commit is contained in:
parent
48e5b99cf8
commit
bd2bf79bc8
3 changed files with 8 additions and 6 deletions
|
@ -6,6 +6,7 @@ import android.os.Bundle
|
|||
import android.view.View
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavGraph
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
|
@ -35,6 +36,8 @@ class MainActivity : AppCompatActivity() {
|
|||
@Inject
|
||||
lateinit var appPreferences: AppPreferences
|
||||
|
||||
lateinit var navController: NavController
|
||||
|
||||
@OptIn(NavigationUiSaveStateControl::class)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -46,7 +49,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
val navHostFragment =
|
||||
supportFragmentManager.findFragmentById(R.id.nav_host_fragment_activity_main) as NavHostFragment
|
||||
val navController = navHostFragment.navController
|
||||
navController = navHostFragment.navController
|
||||
val inflater = navController.navInflater
|
||||
val graph = inflater.inflate(R.navigation.app_navigation)
|
||||
|
||||
|
@ -102,8 +105,7 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
onBackPressed()
|
||||
return true
|
||||
return navController.navigateUp()
|
||||
}
|
||||
|
||||
private fun checkServersEmpty(graph: NavGraph, onServersEmpty: () -> Unit = {}) {
|
||||
|
|
|
@ -59,7 +59,7 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
}
|
||||
|
||||
binding.playerView.findViewById<View>(R.id.back_button).setOnClickListener {
|
||||
onBackPressed()
|
||||
finish()
|
||||
}
|
||||
|
||||
val videoNameTextView = binding.playerView.findViewById<TextView>(R.id.video_name)
|
||||
|
@ -169,7 +169,7 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
|
||||
viewModel.navigateBack.observe(this) {
|
||||
if (it) {
|
||||
onBackPressed()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ internal class TvPlayerActivity : BasePlayerActivity() {
|
|||
}
|
||||
|
||||
findViewById<View>(R.id.back_button).setOnClickListener {
|
||||
onBackPressed()
|
||||
finish()
|
||||
}
|
||||
|
||||
bindAudioControl()
|
||||
|
|
Loading…
Reference in a new issue