Skip to content

Commit

Permalink
Fix crash on pressing previous button
Browse files Browse the repository at this point in the history
  • Loading branch information
brahmkshatriya committed Feb 20, 2024
1 parent cfdcb4b commit 48254e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import dev.brahmkshatriya.echo.ui.utils.observe
import dev.brahmkshatriya.echo.ui.utils.updatePaddingWithSystemInsets
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlin.math.max
import kotlin.math.min

fun createPlayer(
activity: MainActivity
Expand Down Expand Up @@ -244,8 +245,8 @@ fun createPlayer(
playerBinding.expandedSeekBar.secondaryProgress = buffered

var old = playerBinding.expandedSeekBar.progress
if(old == 0) old = current
val duration = (current - old).toLong()
if (old == 0) old = current
val duration = min(1000L, max(0L, (current - old).toLong()))
println("Duration: $duration, Current: $current, Progress: $old")
playerBinding.collapsedSeekBar.apply {
collapsedAnimator?.cancel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.paging.cachedIn
import dagger.hilt.android.lifecycle.HiltViewModel
import dev.brahmkshatriya.echo.common.clients.HomeFeedClient
import dev.brahmkshatriya.echo.common.models.MediaItemsContainer
import dev.brahmkshatriya.echo.di.MutableExtensionFlow
import dev.brahmkshatriya.echo.di.HomeFeedFlow
import dev.brahmkshatriya.echo.ui.utils.observe
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -18,13 +18,13 @@ import javax.inject.Inject

@HiltViewModel
class HomeViewModel @Inject constructor(
val homeFeedFlow: MutableExtensionFlow
val homeFeedFlow: HomeFeedFlow
) : ViewModel() {

init {
viewModelScope.launch {
observe(homeFeedFlow.flow) {
homeClient = it as? HomeFeedClient
homeClient = it
loadFeed()
}
}
Expand Down

0 comments on commit 48254e8

Please sign in to comment.