Skip to content

Commit 462f0ad

Browse files
ProfpatschStypox
authored andcommitted
PlayerUIList: inline init block
1 parent 183cc58 commit 462f0ad

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/ui/PlayerUiList.kt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,29 @@ package org.schabi.newpipe.player.ui
33
import org.schabi.newpipe.util.GuardedByMutex
44
import java.util.Optional
55

6+
/**
7+
* Creates a [PlayerUiList] starting with the provided player uis. The provided player uis
8+
* will not be prepared like those passed to [.addAndPrepare], because when
9+
* the [PlayerUiList] constructor is called, the player is still not running and it
10+
* wouldn't make sense to initialize uis then. Instead the player will initialize them by doing
11+
* proper calls to [.call].
12+
*
13+
* @param initialPlayerUis the player uis this list should start with; the order will be kept
14+
*/
615
class PlayerUiList(vararg initialPlayerUis: PlayerUi) {
7-
private val playerUis = GuardedByMutex(mutableListOf<PlayerUi>())
16+
private val playerUis = GuardedByMutex(mutableListOf(*initialPlayerUis))
817

918
/**
19+
* Adds the provided player ui to the list and calls on it the initialization functions that
20+
/**
1021
* Creates a [PlayerUiList] starting with the provided player uis. The provided player uis
1122
* will not be prepared like those passed to [.addAndPrepare], because when
1223
* the [PlayerUiList] constructor is called, the player is still not running and it
1324
* wouldn't make sense to initialize uis then. Instead the player will initialize them by doing
1425
* proper calls to [.call].
1526
*
1627
* @param initialPlayerUis the player uis this list should start with; the order will be kept
17-
*/
18-
init {
19-
playerUis.runWithLockSync {
20-
lockData.addAll(listOf(*initialPlayerUis))
21-
}
22-
}
23-
24-
/**
25-
* Adds the provided player ui to the list and calls on it the initialization functions that
26-
* apply based on the current player state. The preparation step needs to be done since when UIs
28+
*/* apply based on the current player state. The preparation step needs to be done since when UIs
2729
* are removed and re-added, the player will not call e.g. initPlayer again since the exoplayer
2830
* is already initialized, but we need to notify the newly built UI that the player is ready
2931
* nonetheless.

0 commit comments

Comments
 (0)