mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Replace deprecated onBackPressed call
PiperOrigin-RevId: 523361561
(cherry picked from commit be85684dc9)
This commit is contained in:
parent
8aec88b2b4
commit
0690c9ba67
1 changed files with 10 additions and 6 deletions
|
|
@ -26,6 +26,7 @@ import android.view.ViewGroup
|
|||
import android.widget.ArrayAdapter
|
||||
import android.widget.ListView
|
||||
import android.widget.TextView
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.media3.common.MediaItem
|
||||
|
|
@ -73,21 +74,24 @@ class MainActivity : AppCompatActivity() {
|
|||
val intent = Intent(this, PlayerActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
onBackPressedDispatcher.addCallback(
|
||||
object : OnBackPressedCallback(/* enabled= */ true) {
|
||||
override fun handleOnBackPressed() {
|
||||
popPathStack()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
@SuppressWarnings("MissingSuperCall")
|
||||
override fun onBackPressed() {
|
||||
popPathStack()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
initializeBrowser()
|
||||
|
|
|
|||
Loading…
Reference in a new issue