Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrouge committed Apr 20, 2024
1 parent 6bc7447 commit 1b42dfb
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ class Radio(private val symphony: Symphony) : SymphonyHooks {
}
onUpdate.dispatch(RadioEvents.SongStaged)
player!!.prepare {
seek(options.startPosition ?: 0L)
options.startPosition?.let {
if (it > 0L) {
seek(it)
}
}
setSpeed(persistedSpeed, true)
setPitch(persistedPitch, true)
if (options.autostart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.media.PlaybackParams
import android.net.Uri
import io.github.zyrouge.symphony.Symphony
import io.github.zyrouge.symphony.utils.Logger
import kotlinx.coroutines.launch
import java.util.Timer

data class PlaybackPosition(
Expand Down Expand Up @@ -93,9 +94,12 @@ class RadioPlayer(val symphony: Symphony, uri: Uri) {
fun stop() {
usable = false
destroyDurationTimer()
unsafeMediaPlayer.stop()
unsafeMediaPlayer.reset()
unsafeMediaPlayer.release()
symphony.groove.coroutineScope.launch {
unsafeMediaPlayer?.let {
it.stop()
it.release()
}
}
}

fun start() = mediaPlayer?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fun ContentDrawScope.drawScrollBar(
rect = Rect(
offset = Offset(
size.width - scrollPointerWidth,
scrollPointerOffsetY
scrollPointerOffsetY,
),
size = Size(scrollPointerWidth, scrollPointerHeight),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ fun GenericGrooveBanner(
.background(
brush = Brush.verticalGradient(
0f to Color.Transparent,
1f to MaterialTheme.colorScheme.surface.copy(
alpha = 0.7f
)
1f to MaterialTheme.colorScheme.surface.copy(alpha = 0.7f)
)
)
.align(Alignment.BottomStart)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.animateIntAsState
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
Expand All @@ -18,7 +17,6 @@ import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.absoluteOffset
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
Expand Down Expand Up @@ -51,17 +49,17 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.boundsInParent
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import io.github.zyrouge.symphony.services.groove.Song
Expand Down Expand Up @@ -192,10 +190,10 @@ fun NowPlayingBottomBar(context: ViewContext, insetPadding: Boolean = true) {
transitionSpec = {
val from = fadeIn(
animationSpec = TransitionDurations.Normal.asTween(
delayMillis = TransitionDurations.Fast.milliseconds,
delayMillis = TransitionDurations.Normal.milliseconds,
),
)
val to = fadeOut(animationSpec = TransitionDurations.Fast.asTween())
val to = fadeOut(TransitionDurations.Normal.asTween())
from togetherWith to
},
) { song ->
Expand Down Expand Up @@ -260,24 +258,21 @@ fun NowPlayingBottomBar(context: ViewContext, insetPadding: Boolean = true) {

@Composable
private fun NowPlayingBottomBarContent(context: ViewContext, song: Song) {
BoxWithConstraints {
BoxWithConstraints(modifier = Modifier.clipToBounds()) {
val cardWidthPx = constraints.maxWidth
var offsetX by remember { mutableFloatStateOf(0f) }
val cardOffsetX = animateIntAsState(
offsetX.toInt(),
val cardOffsetX by animateFloatAsState(
offsetX / 2,
label = "c-now-playing-card-offset-x",
)
val cardOpacity = animateFloatAsState(
val cardOpacity by animateFloatAsState(
if (offsetX != 0f) 0.7f else 1f,
label = "c-now-playing-card-opacity",
)

Box(
modifier = Modifier
.alpha(cardOpacity.value)
.absoluteOffset {
IntOffset(cardOffsetX.value.div(2), 0)
}
.graphicsLayer(alpha = cardOpacity, translationX = cardOffsetX)
.pointerInput(Unit) {
detectHorizontalDragGestures(
onDragEnd = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fun SongExplorerList(
"/",
modifier = Modifier
.padding(4.dp, 0.dp)
.alpha(0.3f)
.alpha(0.3f),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private fun SettingsFolderTilePickerDialog(
"/",
modifier = Modifier
.padding(4.dp, 0.dp)
.alpha(0.3f)
.alpha(0.3f),
)
}
}
Expand Down

0 comments on commit 1b42dfb

Please sign in to comment.