diff --git a/app/src/main/java/dev/brahmkshatriya/echo/player/InitPlayer.kt b/app/src/main/java/dev/brahmkshatriya/echo/player/InitPlayer.kt index 7d26f0a4..b2bc1296 100644 --- a/app/src/main/java/dev/brahmkshatriya/echo/player/InitPlayer.kt +++ b/app/src/main/java/dev/brahmkshatriya/echo/player/InitPlayer.kt @@ -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 @@ -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() diff --git a/app/src/main/java/dev/brahmkshatriya/echo/ui/home/HomeViewModel.kt b/app/src/main/java/dev/brahmkshatriya/echo/ui/home/HomeViewModel.kt index ca086677..b93e2163 100644 --- a/app/src/main/java/dev/brahmkshatriya/echo/ui/home/HomeViewModel.kt +++ b/app/src/main/java/dev/brahmkshatriya/echo/ui/home/HomeViewModel.kt @@ -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 @@ -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() } }