Fix Kotlin 2.0 compilation error in session demo app
Since Kotlin 2.0 the compiler became better at detecting incorrect annotation applications. The @OptIn annotation can't be applied to an expression, so when compiling with Kotlin 2.0 it results in an error. PiperOrigin-RevId: 604596657
This commit is contained in:
parent
25498b151b
commit
718cf1299b
@ -54,6 +54,7 @@ class PlayerActivity : AppCompatActivity() {
|
|||||||
private val mediaItemList: MutableList<MediaItem> = mutableListOf()
|
private val mediaItemList: MutableList<MediaItem> = mutableListOf()
|
||||||
private var lastMediaItemId: String? = null
|
private var lastMediaItemId: String? = null
|
||||||
|
|
||||||
|
@OptIn(UnstableApi::class) // PlayerView.hideController
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_player)
|
setContentView(R.layout.activity_player)
|
||||||
@ -67,7 +68,6 @@ class PlayerActivity : AppCompatActivity() {
|
|||||||
val controller = this.controller ?: return@run
|
val controller = this.controller ?: return@run
|
||||||
if (controller.currentMediaItemIndex == position) {
|
if (controller.currentMediaItemIndex == position) {
|
||||||
controller.playWhenReady = !controller.playWhenReady
|
controller.playWhenReady = !controller.playWhenReady
|
||||||
@OptIn(UnstableApi::class) // PlayerView.hideController
|
|
||||||
if (controller.playWhenReady) {
|
if (controller.playWhenReady) {
|
||||||
playerView.hideController()
|
playerView.hideController()
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ class PlayerActivity : AppCompatActivity() {
|
|||||||
controllerFuture =
|
controllerFuture =
|
||||||
MediaController.Builder(
|
MediaController.Builder(
|
||||||
this,
|
this,
|
||||||
SessionToken(this, ComponentName(this, PlaybackService::class.java))
|
SessionToken(this, ComponentName(this, PlaybackService::class.java)),
|
||||||
)
|
)
|
||||||
.buildAsync()
|
.buildAsync()
|
||||||
updateMediaMetadataUI()
|
updateMediaMetadataUI()
|
||||||
@ -163,7 +163,7 @@ class PlayerActivity : AppCompatActivity() {
|
|||||||
private inner class MediaItemListAdapter(
|
private inner class MediaItemListAdapter(
|
||||||
context: Context,
|
context: Context,
|
||||||
viewID: Int,
|
viewID: Int,
|
||||||
mediaItemList: List<MediaItem>
|
mediaItemList: List<MediaItem>,
|
||||||
) : ArrayAdapter<MediaItem>(context, viewID, mediaItemList) {
|
) : ArrayAdapter<MediaItem>(context, viewID, mediaItemList) {
|
||||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||||
val mediaItem = getItem(position)!!
|
val mediaItem = getItem(position)!!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user