Skip to content

Commit

Permalink
v0.1.9 - playlists update fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dadencukillia committed Nov 16, 2024
1 parent d905111 commit 85390e4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId = "com.crocoby.animeplayerua"
minSdk = 28
targetSdk = 34
versionCode = 8
versionName = "0.1.8"
versionCode = 9
versionName = "0.1.9"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
39 changes: 25 additions & 14 deletions app/src/main/java/com/crocoby/animeplayerua/activities/Playlists.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,48 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
import com.crocoby.animeplayerua.AnimeItem
import com.crocoby.animeplayerua.logic.CustomActivity
import com.crocoby.animeplayerua.logic.runParser
import com.crocoby.animeplayerua.widgets.AnimeCategory
import com.crocoby.animeplayerua.widgets.AnimeCategoryLoading
import com.crocoby.animeplayerua.widgets.ApplicationScaffold
import com.crocoby.animeplayerua.widgets.TextBanner
import kotlinx.coroutines.launch

class PlaylistsActivity: CustomActivity() {
@Composable
override fun Page() {
val animeContinueWatching = remember { mutableListOf<AnimeItem>() }
val animeLiked = remember { mutableListOf<AnimeItem>() }
val animeWatched = remember { mutableListOf<AnimeItem>() }
var animeContinueWatching by remember { mutableStateOf(listOf<AnimeItem>()) }
var animeLiked by remember { mutableStateOf(listOf<AnimeItem>()) }
var animeWatched by remember { mutableStateOf(listOf<AnimeItem>()) }
var loaded by remember { mutableStateOf(false) }
val coroutine = rememberCoroutineScope()

runParser(
function = {
if (!loaded) {
animeContinueWatching.addAll(database.getEpisodeWatched().map {it.toAnimeItem()})
animeLiked.addAll(database.getLiked().map {it.toAnimeItem()})
animeWatched.addAll(database.getWatched().map {it.toAnimeItem()})
LifecycleEventEffect(Lifecycle.Event.ON_RESUME) {
coroutine.launch {
val newContinueWatching = database.getEpisodeWatched().map { it.toAnimeItem() }
val newLiked = database.getLiked().map { it.toAnimeItem() }
val newWatched = database.getWatched().map { it.toAnimeItem() }

loaded = true
if (newContinueWatching != animeContinueWatching) {
animeContinueWatching = newContinueWatching.toMutableList()
}
},
onError = {}
)
if (newLiked != animeLiked) {
animeLiked = newLiked.toMutableList()
}
if (newWatched != animeWatched) {
animeWatched = newWatched.toMutableList()
}

loaded = true
}
}

ApplicationScaffold(this::class.java) {
if (animeContinueWatching.isEmpty() && animeLiked.isEmpty() && animeWatched.isEmpty() && loaded) {
Expand Down
4 changes: 2 additions & 2 deletions releaseVersion
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
0.1.8
https://github.com/dadencukillia/animeplayerua/releases/tag/v0.1.8
0.1.9
https://github.com/dadencukillia/animeplayerua/releases/tag/v0.1.9

0 comments on commit 85390e4

Please sign in to comment.