Skip to content

Commit

Permalink
Fixed Related
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrave-dev committed Aug 10, 2024
1 parent 17524af commit b303218
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 66 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ android {
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
Expand All @@ -72,8 +73,8 @@ android {
viewBinding = true
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.11"
composeCompiler {
enableStrongSkippingMode = true
}
packaging {
jniLibs.useLegacyPackaging = true
Expand Down
55 changes: 0 additions & 55 deletions app/src/main/java/com/maxrave/simpmusic/extension/AllExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ import android.widget.ImageButton
import android.widget.TextView
import androidx.core.net.toUri
import androidx.datastore.preferences.preferencesDataStore
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.asFlow
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
import androidx.media3.common.util.UnstableApi
Expand Down Expand Up @@ -54,7 +49,6 @@ import com.maxrave.simpmusic.data.model.searchResult.songs.Thumbnail
import com.maxrave.simpmusic.data.model.searchResult.videos.VideosResult
import com.maxrave.simpmusic.data.parser.toListThumbnail
import com.maxrave.simpmusic.service.test.source.MergingMediaSourceFactory
import kotlinx.coroutines.flow.Flow
import java.io.File
import java.io.InputStream
import java.io.OutputStream
Expand Down Expand Up @@ -775,54 +769,6 @@ fun NavController.navigateSafe(
}
}

fun <T> LiveData<T>.observeOnce(
lifecycleOwner: LifecycleOwner,
observer: Observer<T>,
) {
observe(
lifecycleOwner,
object : Observer<T> {
override fun onChanged(value: T) {
observer.onChanged(value)
removeObserver(this)
}
},
)
}

fun <A, B> zip(
first: LiveData<A>,
second: LiveData<B>,
): Flow<Pair<A, B>> {
val mediatorLiveData = MediatorLiveData<Pair<A, B>>()

var isFirstEmitted = false
var isSecondEmitted = false
var firstValue: A? = null
var secondValue: B? = null

mediatorLiveData.addSource(first) {
isFirstEmitted = true
firstValue = it
if (isSecondEmitted) {
mediatorLiveData.value = Pair(firstValue!!, secondValue!!)
isFirstEmitted = false
isSecondEmitted = false
}
}
mediatorLiveData.addSource(second) {
isSecondEmitted = true
secondValue = it
if (isFirstEmitted) {
mediatorLiveData.value = Pair(firstValue!!, secondValue!!)
isFirstEmitted = false
isSecondEmitted = false
}
}

return mediatorLiveData.asFlow()
}

fun PodcastBrowse.EpisodeItem.toTrack(): Track {
return Track(
album = null,
Expand Down Expand Up @@ -942,7 +888,6 @@ fun String?.format(vararg data: Any): String {
}
}
catch (e: Exception) {
e.printStackTrace()
""
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,8 @@ fun NowPlayingScreen(
.aspectRatio(1f)
.clip(
CircleShape
),
)
.weight(1f),
onClick = {
sharedViewModel.onUIEvent(UIEvent.Shuffle)
}
Expand Down Expand Up @@ -946,7 +947,8 @@ fun NowPlayingScreen(
.aspectRatio(1f)
.clip(
CircleShape
),
)
.weight(1f),
onClick = {
if (controllerState.isPreviousAvailable) {
sharedViewModel.onUIEvent(UIEvent.Previous)
Expand All @@ -969,7 +971,8 @@ fun NowPlayingScreen(
.aspectRatio(1f)
.clip(
CircleShape
),
)
.weight(1f),
onClick = {
sharedViewModel.onUIEvent(UIEvent.PlayPause)
}
Expand Down Expand Up @@ -1001,7 +1004,8 @@ fun NowPlayingScreen(
.aspectRatio(1f)
.clip(
CircleShape
),
)
.weight(1f),
onClick = {
if (controllerState.isNextAvailable) {
sharedViewModel.onUIEvent(UIEvent.Next)
Expand All @@ -1024,7 +1028,8 @@ fun NowPlayingScreen(
.aspectRatio(1f)
.clip(
CircleShape
),
)
.weight(1f),
onClick = {
sharedViewModel.onUIEvent(UIEvent.Repeat)
}
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
android = "8.5.1"
android = "8.5.2"
kotlin = "2.0.0"
serialization = "2.0.0"
ksp = "2.0.0-1.0.22"
Expand All @@ -10,7 +10,7 @@ lifecycle-viewmodel-compose = "2.8.4"
lifecycle-runtime-ktx = "2.8.4"
core-ktx = "1.13.1"
appcompat = "1.7.0"
work = "2.9.0"
work = "2.9.1"
material = "1.11.0" #Version 1.12.0 caused bug
startup-runtime = "1.1.1"
lifecycle-livedata-ktx = "2.8.4"
Expand Down Expand Up @@ -40,7 +40,7 @@ swiperefreshlayout = "1.2.0-alpha01"
insetter = "0.6.1"
shimmer = "0.5.0"
lottie = "6.4.0"
paging = "3.3.1"
paging = "3.3.2"
customactivityoncrash = "2.4.0"
sdp-android = "1.1.0"
ssp-android = "1.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data class PlaylistPanelRenderer(
val currentIndex: Int?,
val isInfinite: Boolean,
val numItemsToShow: Int?,
val playlistId: String,
val playlistId: String? = null,
val continuations: List<Continuation>?,
) {
@Serializable
Expand Down

0 comments on commit b303218

Please sign in to comment.