Skip to content

Commit

Permalink
fix(lint): Cleanup code and fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
quickdesh authored and jmir1 committed Dec 7, 2023
1 parent cdfeb16 commit 7ccd74f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class PlayerViewModel @JvmOverloads constructor(
fun isEpisodeOnline(): Boolean? {
val anime = currentAnime ?: return null
val episode = currentEpisode ?: return null
return currentSource is AnimeHttpSource && !EpisodeLoader.isDownloaded(
return currentSource is AnimeHttpSource && !EpisodeLoader.isDownload(
episode.toDomainEpisode()!!,
anime,
)
Expand Down Expand Up @@ -379,8 +379,8 @@ class PlayerViewModel @JvmOverloads constructor(

val nextEpisode = this.currentPlaylist[getCurrentEpisodeIndex() + 1]
val episodesAreDownloaded =
EpisodeLoader.isDownloaded(currentEpisode.toDomainEpisode()!!, anime) &&
EpisodeLoader.isDownloaded(nextEpisode.toDomainEpisode()!!, anime)
EpisodeLoader.isDownload(currentEpisode.toDomainEpisode()!!, anime) &&
EpisodeLoader.isDownload(nextEpisode.toDomainEpisode()!!, anime)

viewModelScope.launchIO {
if (!episodesAreDownloaded) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,9 @@ class EpisodeLoader {
* @param source the source of the anime.
*/
suspend fun getLinks(episode: Episode, anime: Anime, source: AnimeSource): List<Video> {
val downloadManager: AnimeDownloadManager = Injekt.get()
val isDownloaded = downloadManager.isEpisodeDownloaded(
episode.name,
episode.scanlator,
anime.title,
anime.source,
skipCache = true,
)
val isDownloaded = isDownload(episode, anime)
return when {
isDownloaded -> isDownloaded(episode, anime, source, downloadManager)
isDownloaded -> isDownload(episode, anime, source)
source is AnimeHttpSource -> isHttp(episode, source)
source is LocalAnimeSource -> isLocal(episode)
else -> error("source not supported")
Expand All @@ -51,7 +44,7 @@ class EpisodeLoader {
* @param episode the episode being parsed.
* @param anime the anime of the episode.
*/
fun isDownloaded(episode: Episode, anime: Anime): Boolean {
fun isDownload(episode: Episode, anime: Anime): Boolean {
val downloadManager: AnimeDownloadManager = Injekt.get()
return downloadManager.isEpisodeDownloaded(
episode.name,
Expand Down Expand Up @@ -90,14 +83,13 @@ class EpisodeLoader {
* @param episode the episode being parsed.
* @param anime the anime of the episode.
* @param source the source of the anime.
* @param downloadManager the AnimeDownloadManager instance to use.
*/
private fun isDownloaded(
private fun isDownload(
episode: Episode,
anime: Anime,
source: AnimeSource,
downloadManager: AnimeDownloadManager,
): List<Video> {
val downloadManager: AnimeDownloadManager = Injekt.get()
return try {
val video = downloadManager.buildVideo(source, anime, episode)
listOf(video)
Expand All @@ -111,7 +103,7 @@ class EpisodeLoader {
*
* @param episode the episode being parsed.
*/
private suspend fun isLocal(
private fun isLocal(
episode: Episode,
): List<Video> {
return try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class PictureInPictureHandler(
MR.strings.action_previous_episode,
PIP_PREVIOUS,
PIP_PREVIOUS,
plPos != 0
plPos != 0,
)
} else {
createRemoteAction(
Expand Down Expand Up @@ -117,7 +117,7 @@ class PictureInPictureHandler(
MR.strings.action_next_episode,
PIP_NEXT,
PIP_NEXT,
plPos != plCount - 1
plPos != plCount - 1,
),
),
)
Expand Down

0 comments on commit 7ccd74f

Please sign in to comment.