Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
eneim committed Apr 25, 2020
1 parent b09e60c commit eb8616f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
30 changes: 14 additions & 16 deletions kohii-core/src/main/java/kohii/v1/core/AbstractPlayable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ abstract class AbstractPlayable<RENDERER : Any>(
}
}

@Suppress("IfThenToElvis")
override var playback: Playback? = null
set(value) {
val from = field
Expand All @@ -128,23 +127,22 @@ abstract class AbstractPlayable<RENDERER : Any>(
if (from.playable === this) from.playable = null
}

this.manager =
if (to != null) {
to.manager
this.manager = if (to != null) {
to.manager
} else {
val configChange = from?.manager?.isChangingConfigurations() == true
if (!configChange) {
// TODO need a better implementation.
if (master.manuallyStartedPlayable.get() === this && isPlaying()) master
else null
} else if (!onConfigChange()) {
// On config change, if the Playable doesn't support, we need to pause the Video.
onPause()
null
} else {
val configChange = if (from != null) from.manager.isChangingConfigurations() else false
if (!configChange) {
// TODO need a better implementation.
if (master.manuallyStartedPlayable.get() === this && isPlaying()) master
else null
} else if (!onConfigChange()) {
// On config change, if the Playable doesn't support, we need to pause the Video.
onPause()
null
} else {
master // to prevent the Playable from being destroyed when Manager is null.
}
master // to prevent the Playable from being destroyed when Manager is null.
}
}

if (to != null) {
to.playable = this
Expand Down
2 changes: 1 addition & 1 deletion kohii-core/src/main/java/kohii/v1/core/Bucket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract class Bucket constructor(
const val BOTH_AXIS = -1
const val NONE_AXIS = -2

val playbackComparators = mapOf(
private val playbackComparators = mapOf(
HORIZONTAL to Playback.HORIZONTAL_COMPARATOR,
VERTICAL to Playback.VERTICAL_COMPARATOR,
BOTH_AXIS to Playback.BOTH_AXIS_COMPARATOR,
Expand Down
2 changes: 1 addition & 1 deletion kohii-core/src/main/java/kohii/v1/core/Manager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class Manager(
}

internal fun findBucketForContainer(container: ViewGroup): Bucket? {
require(ViewCompat.isAttachedToWindow(container))
if (!ViewCompat.isAttachedToWindow(container)) return null
return buckets.find { it.accepts(container) }
}

Expand Down
4 changes: 2 additions & 2 deletions kohii-core/src/main/java/kohii/v1/core/Strategy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ sealed class Strategy : Selector {
}

object MULTI_PLAYER : Strategy() {
override fun invoke(playback: Collection<Playback>): Collection<Playback> {
return playback
override fun invoke(playbacks: Collection<Playback>): Collection<Playback> {
return playbacks
}
}
}

0 comments on commit eb8616f

Please sign in to comment.