Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

package com.example.jetcaster.core.data.database.model

import androidx.compose.runtime.Immutable
import androidx.room.Embedded
import androidx.room.Ignore
import androidx.room.Relation
import java.util.Objects

@Immutable
class EpisodeToPodcast {
@Embedded
lateinit var episode: Episode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

package com.example.jetcaster.core.model

import androidx.compose.runtime.Immutable
import com.example.jetcaster.core.data.database.model.Category

@Immutable
data class CategoryInfo(val id: Long, val name: String)

const val CategoryTechnology = "Technology"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@

package com.example.jetcaster.core.model

import androidx.compose.runtime.Immutable
import com.example.jetcaster.core.data.database.model.Episode
import java.time.Duration
import java.time.OffsetDateTime

/**
* External data layer representation of an episode.
*/

@Immutable
data class EpisodeInfo(
val uri: String = "",
val podcastUri: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@

package com.example.jetcaster.core.model

import androidx.compose.runtime.Immutable

/**
* Model holding a list of categories and a selected category in the collection
*/

@Immutable
data class FilterableCategoriesModel(val categories: List<CategoryInfo> = emptyList(), val selectedCategory: CategoryInfo? = null) {
val isEmpty = categories.isEmpty() || selectedCategory == null
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

package com.example.jetcaster.core.model

import androidx.compose.runtime.Immutable

/**
* A model holding top podcasts and matching episodes when filtering based on a category.
*/
@Immutable
data class PodcastCategoryFilterResult(
val topPodcasts: List<PodcastInfo> = emptyList(),
val episodes: List<PodcastToEpisodeInfo> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@

package com.example.jetcaster.core.model

import androidx.compose.runtime.Immutable
import com.example.jetcaster.core.data.database.model.Podcast
import com.example.jetcaster.core.data.database.model.PodcastWithExtraInfo
import java.time.OffsetDateTime

/**
* External data layer representation of a podcast.
*/
@Immutable
data class PodcastInfo(
val uri: String = "",
val title: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

package com.example.jetcaster.core.model

import androidx.compose.runtime.Immutable
import com.example.jetcaster.core.data.database.model.EpisodeToPodcast

@Immutable
data class PodcastToEpisodeInfo(val episode: EpisodeInfo, val podcast: PodcastInfo)

fun EpisodeToPodcast.asPodcastToEpisodeInfo(): PodcastToEpisodeInfo = PodcastToEpisodeInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@

package com.example.jetcaster.core.player

import androidx.compose.runtime.Immutable
import com.example.jetcaster.core.player.model.PlayerEpisode
import java.time.Duration
import kotlinx.coroutines.flow.StateFlow

val DefaultPlaybackSpeed = Duration.ofSeconds(1)

@Immutable
data class EpisodePlayerState(
val currentEpisode: PlayerEpisode? = null,
val queue: List<PlayerEpisode> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.example.jetcaster.core.player.model

import androidx.compose.runtime.Immutable
import com.example.jetcaster.core.data.database.model.EpisodeToPodcast
import com.example.jetcaster.core.model.EpisodeInfo
import com.example.jetcaster.core.model.PodcastInfo
Expand All @@ -25,6 +26,8 @@ import java.time.OffsetDateTime
/**
* Episode data with necessary information to be used within a player.
*/

@Immutable
data class PlayerEpisode(
val uri: String = "",
val title: String = "",
Expand Down
6 changes: 6 additions & 0 deletions Jetcaster/mobile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ android {
excludes += "/META-INF/AL2.0"
excludes += "/META-INF/LGPL2.1"
}

composeCompiler {
reportsDestination = layout.buildDirectory.dir("compose_compiler")
metricsDestination = layout.buildDirectory.dir("compose_compiler")
stabilityConfigurationFiles = listOf(rootProject.layout.projectDirectory.file("stability_config.conf"))
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ import com.example.jetcaster.util.radialGradientScrim
import java.time.Duration
import java.time.LocalDateTime
import java.time.OffsetDateTime
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.toPersistentList
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
Expand Down Expand Up @@ -373,7 +373,7 @@ private fun HomeScreenBackground(modifier: Modifier = Modifier, content: @Compos
private fun HomeScreen(
windowSizeClass: WindowSizeClass,
isLoading: Boolean,
featuredPodcasts: PersistentList<PodcastInfo>,
featuredPodcasts: ImmutableList<PodcastInfo>,
selectedHomeCategory: HomeCategory,
homeCategories: List<HomeCategory>,
filterableCategoriesModel: FilterableCategoriesModel,
Expand Down Expand Up @@ -538,7 +538,7 @@ fun PillToolbar(selectedHomeCategory: HomeCategory, onHomeAction: (HomeAction) -

@Composable
private fun HomeContent(
featuredPodcasts: PersistentList<PodcastInfo>,
featuredPodcasts: ImmutableList<PodcastInfo>,
selectedHomeCategory: HomeCategory,
filterableCategoriesModel: FilterableCategoriesModel,
podcastCategoryFilterResult: PodcastCategoryFilterResult,
Expand Down Expand Up @@ -572,7 +572,7 @@ private fun HomeContent(

@Composable
private fun HomeContentGrid(
featuredPodcasts: PersistentList<PodcastInfo>,
featuredPodcasts: ImmutableList<PodcastInfo>,
selectedHomeCategory: HomeCategory,
filterableCategoriesModel: FilterableCategoriesModel,
podcastCategoryFilterResult: PodcastCategoryFilterResult,
Expand Down Expand Up @@ -630,7 +630,7 @@ private fun HomeContentGrid(

@Composable
private fun FollowedPodcastItem(
items: PersistentList<PodcastInfo>,
items: ImmutableList<PodcastInfo>,
onPodcastUnfollowed: (PodcastInfo) -> Unit,
navigateToPodcastDetails: (PodcastInfo) -> Unit,
modifier: Modifier = Modifier,
Expand All @@ -652,7 +652,7 @@ private fun FollowedPodcastItem(
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun FollowedPodcasts(
items: PersistentList<PodcastInfo>,
items: ImmutableList<PodcastInfo>,
onPodcastUnfollowed: (PodcastInfo) -> Unit,
navigateToPodcastDetails: (PodcastInfo) -> Unit,
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -767,7 +767,7 @@ private fun PreviewHome() {
HomeScreen(
windowSizeClass = CompactWindowSizeClass,
isLoading = true,
featuredPodcasts = PreviewPodcasts.toPersistentList(),
featuredPodcasts = PreviewPodcasts.toImmutableList(),
homeCategories = HomeCategory.entries,
selectedHomeCategory = HomeCategory.Discover,
filterableCategoriesModel = FilterableCategoriesModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import com.example.jetcaster.core.player.EpisodePlayer
import com.example.jetcaster.core.player.model.PlayerEpisode
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand Down Expand Up @@ -229,7 +229,7 @@ sealed interface HomeAction {
data class HomeScreenUiState(
val isLoading: Boolean = true,
val errorMessage: String? = null,
val featuredPodcasts: PersistentList<PodcastInfo> = persistentListOf(),
val featuredPodcasts: ImmutableList<PodcastInfo> = persistentListOf(),
val selectedHomeCategory: HomeCategory = HomeCategory.Discover,
val homeCategories: List<HomeCategory> = emptyList(),
val filterableCategoriesModel: FilterableCategoriesModel = FilterableCategoriesModel(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fun PodcastDetailsScreen(
PodcastDetailsScreen(
podcast = s.podcast,
episodes = s.episodes,
toggleSubscribe = viewModel::toggleSusbcribe,
toggleSubscribe = viewModel::toggleSubscribe,
onQueueEpisode = viewModel::onQueueEpisode,
removeFromQueue = viewModel::deleteEpisode,
navigateToPlayer = navigateToPlayer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.example.jetcaster.ui.podcast

import android.net.Uri
import androidx.compose.runtime.Immutable
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.jetcaster.core.data.repository.EpisodeStore
Expand All @@ -37,6 +38,7 @@ import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch

@Immutable
sealed interface PodcastUiState {
data object Loading : PodcastUiState
data class Ready(val podcast: PodcastInfo, val episodes: List<EpisodeInfo>) : PodcastUiState
Expand Down Expand Up @@ -71,7 +73,7 @@ class PodcastDetailsViewModel @AssistedInject constructor(
initialValue = PodcastUiState.Loading,
)

fun toggleSusbcribe(podcast: PodcastInfo) {
fun toggleSubscribe(podcast: PodcastInfo) {
viewModelScope.launch {
podcastStore.togglePodcastFollowed(podcast.uri)
}
Expand Down
2 changes: 2 additions & 0 deletions Jetcaster/stability_config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java.time.*
kotlin.collections.*
6 changes: 6 additions & 0 deletions Jetcaster/tv/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ android {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}

composeCompiler {
reportsDestination = layout.buildDirectory.dir("compose_compiler")
metricsDestination = layout.buildDirectory.dir("compose_compiler")
stabilityConfigurationFiles = listOf(rootProject.layout.projectDirectory.file("stability_config.conf"))
}
}

dependencies {
Expand Down
6 changes: 6 additions & 0 deletions Jetcaster/wear/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ android {
excludes += "rome-utils-" + libs.rometools.rome.get().version + ".jar"
}
}

composeCompiler {
reportsDestination = layout.buildDirectory.dir("compose_compiler")
metricsDestination = layout.buildDirectory.dir("compose_compiler")
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
}
}

dependencies {
Expand Down