Update App.kt

This commit is contained in:
AdityasahuX07 2026-05-12 23:03:49 +05:30 committed by GitHub
parent c29f0cc064
commit 753f19d581
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -123,7 +123,6 @@ import com.nuvio.app.features.library.LibrarySection
import com.nuvio.app.features.library.LibrarySourceMode import com.nuvio.app.features.library.LibrarySourceMode
import com.nuvio.app.features.library.LibraryScreen import com.nuvio.app.features.library.LibraryScreen
import com.nuvio.app.features.library.toLibraryItem import com.nuvio.app.features.library.toLibraryItem
import com.nuvio.app.features.library.toMetaPreview
import com.nuvio.app.features.notifications.EpisodeReleaseNotificationsRepository import com.nuvio.app.features.notifications.EpisodeReleaseNotificationsRepository
import com.nuvio.app.features.player.PlayerLaunch import com.nuvio.app.features.player.PlayerLaunch
import com.nuvio.app.features.player.PlayerLaunchStore import com.nuvio.app.features.player.PlayerLaunchStore
@ -748,6 +747,11 @@ private fun MainAppContent(
AppDeepLinkRepository.markConsumed(deepLink) AppDeepLinkRepository.markConsumed(deepLink)
} }
null -> Unit
}
}
}
fun launchPlaybackWithDownloadPreference( fun launchPlaybackWithDownloadPreference(
type: String, type: String,
videoId: String, videoId: String,
@ -809,46 +813,14 @@ private fun MainAppContent(
return return
} }
} }
}
}
fun launchPlaybackWithDownloadPreference( val streamLaunchId = StreamLaunchStore.put(
type: String, StreamLaunch(
videoId: String, type = type,
parentMetaId: String,
parentMetaType: String,
title: String,
logo: String?,
poster: String?,
background: String?,
seasonNumber: Int?,
episodeNumber: Int?,
episodeTitle: String?,
episodeThumbnail: String?,
pauseDescription: String?,
resumePositionMs: Long?,
resumeProgressFraction: Float?,
manualSelection: Boolean,
startFromBeginning: Boolean,
) {
val targetResumePositionMs = if (startFromBeginning) 0L else (resumePositionMs ?: 0L)
val targetResumeProgressFraction = if (startFromBeginning) null else resumeProgressFraction
if (!manualSelection) {
val downloadedItem = DownloadsRepository.findPlayableDownload(
parentMetaId = parentMetaId,
seasonNumber = seasonNumber,
episodeNumber = episodeNumber,
videoId = videoId, videoId = videoId,
) parentMetaId = parentMetaId,
val localSourceUrl = downloadedItem?.localFileUri parentMetaType = parentMetaType,
if (!localSourceUrl.isNullOrBlank()) {
val launchId = PlayerLaunchStore.put(
PlayerLaunch(
title = title, title = title,
sourceUrl = localSourceUrl,
sourceHeaders = emptyMap(),
sourceResponseHeaders = emptyMap(),
logo = logo, logo = logo,
poster = poster, poster = poster,
background = background, background = background,
@ -856,40 +828,38 @@ private fun MainAppContent(
episodeNumber = episodeNumber, episodeNumber = episodeNumber,
episodeTitle = episodeTitle, episodeTitle = episodeTitle,
episodeThumbnail = episodeThumbnail, episodeThumbnail = episodeThumbnail,
streamTitle = downloadedItem.streamTitle.ifBlank { title },
streamSubtitle = downloadedItem.streamSubtitle,
pauseDescription = pauseDescription, pauseDescription = pauseDescription,
providerName = downloadedItem.providerName.ifBlank { downloadedProviderLabel }, resumePositionMs = if (startFromBeginning) 0L else resumePositionMs,
providerAddonId = downloadedItem.providerAddonId, resumeProgressFraction = targetResumeProgressFraction,
contentType = type, manualSelection = manualSelection,
startFromBeginning = startFromBeginning,
),
)
navController.navigate(
StreamRoute(launchId = streamLaunchId),
)
}
val onPlay: (String, String, String, String, String, String?, String?, String?, Int?, Int?, String?, String?, String?, Long?) -> Unit =
{ type, videoId, parentMetaId, parentMetaType, title, logo, poster, background, seasonNumber, episodeNumber, episodeTitle, episodeThumbnail, pauseDescription, resumePositionMs ->
launchPlaybackWithDownloadPreference(
type = type,
videoId = videoId, videoId = videoId,
parentMetaId = parentMetaId, parentMetaId = parentMetaId,
parentMetaType = parentMetaType, parentMetaType = parentMetaType,
initialPositionMs = targetResumePositionMs, title = title,
initialProgressFraction = targetResumeProgressFraction, logo = logo,
), poster = poster,
) background = background,
navController.navigate(PlayerRoute(launchId = launchId)) seasonNumber = seasonNumber,
return episodeNumber = episodeNumber,
} episodeTitle = episodeTitle,
} episodeThumbnail = episodeThumbnail,
pauseDescription = pauseDescription,
val librarySectionSubtitle = if (libraryUiState.sourceMode == LibrarySourceMode.TRAKT) { resumePositionMs = resumePositionMs,
stringResource(Res.string.compose_catalog_subtitle_trakt_library) resumeProgressFraction = null,
} else { manualSelection = false,
stringResource(Res.string.compose_catalog_subtitle_library) startFromBeginning = false,
}
val onLibrarySectionViewAllClick: (LibrarySection) -> Unit = { section ->
navController.navigate(
CatalogRoute(
title = section.displayTitle,
subtitle = librarySectionSubtitle,
manifestUrl = INTERNAL_LIBRARY_MANIFEST_URL,
type = section.items.firstOrNull()?.type ?: "movie",
catalogId = section.type,
supportsPagination = false,
),
) )
} }
@ -1857,9 +1827,6 @@ private fun MainAppContent(
}.onFailure { error -> }.onFailure { error ->
pickerError = error.message ?: getString(Res.string.trakt_lists_load_failed) pickerError = error.message ?: getString(Res.string.trakt_lists_load_failed)
} }
}.onFailure { error ->
pickerError = error.message ?: getString(Res.string.trakt_lists_load_failed)
}
pickerPending = false pickerPending = false
} }
} }
@ -1929,24 +1896,6 @@ private fun MainAppContent(
pickerError = null pickerError = null
} }
}, },
onSave = {
val item = pickerItem ?: return@TraktListPickerDialog
coroutineScope.launch {
pickerPending = true
pickerError = null
runCatching {
LibraryRepository.applyMembershipChanges(
item = item,
desiredMembership = pickerMembership,
)
}.onSuccess {
showLibraryListPicker = false
pickerItem = null
pickerError = null
}.onFailure { error ->
pickerError = error.message ?: getString(Res.string.trakt_lists_update_failed)
}
},
onSave = { onSave = {
val item = pickerItem ?: return@TraktListPickerDialog val item = pickerItem ?: return@TraktListPickerDialog
coroutineScope.launch { coroutineScope.launch {
@ -2063,7 +2012,6 @@ private fun AppTabHost(
onPosterClick: ((MetaPreview) -> Unit)? = null, onPosterClick: ((MetaPreview) -> Unit)? = null,
onPosterLongClick: ((MetaPreview) -> Unit)? = null, onPosterLongClick: ((MetaPreview) -> Unit)? = null,
onLibraryPosterClick: ((LibraryItem) -> Unit)? = null, onLibraryPosterClick: ((LibraryItem) -> Unit)? = null,
onLibraryPosterLongClick: ((LibraryItem) -> Unit)? = null,
onLibrarySectionViewAllClick: ((LibrarySection) -> Unit)? = null, onLibrarySectionViewAllClick: ((LibrarySection) -> Unit)? = null,
onContinueWatchingClick: ((ContinueWatchingItem) -> Unit)? = null, onContinueWatchingClick: ((ContinueWatchingItem) -> Unit)? = null,
onContinueWatchingLongPress: ((ContinueWatchingItem) -> Unit)? = null, onContinueWatchingLongPress: ((ContinueWatchingItem) -> Unit)? = null,
@ -2113,7 +2061,6 @@ private fun AppTabHost(
LibraryScreen( LibraryScreen(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
onPosterClick = onLibraryPosterClick, onPosterClick = onLibraryPosterClick,
onPosterLongClick = onLibraryPosterLongClick,
onSectionViewAllClick = onLibrarySectionViewAllClick, onSectionViewAllClick = onLibrarySectionViewAllClick,
) )
} }