From 550b832d582b123fcfab584935f2ca36119a4a91 Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Wed, 3 Aug 2022 19:57:38 +0200 Subject: [PATCH] small fix --- .../cloudstream3/ui/result/ResultFragment.kt | 156 ++---------------- .../ui/result/ResultViewModel2.kt | 4 +- 2 files changed, 12 insertions(+), 148 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt index 0208eeb4..10d5fbd4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt @@ -39,6 +39,7 @@ import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.mvvm.* import com.lagradost.cloudstream3.syncproviders.providers.Kitsu import com.lagradost.cloudstream3.ui.WatchType +import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_DOWNLOAD import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick import com.lagradost.cloudstream3.ui.download.EasyDownloadButton import com.lagradost.cloudstream3.ui.player.CSPlayerEvent @@ -289,14 +290,6 @@ class ResultFragment : ResultTrailerPlayer() { } } - private fun fromIndexToSeasonText(selection: Int?): String { - return when (selection) { - null -> getString(R.string.no_season) - -2 -> getString(R.string.no_season) - else -> "${getString(R.string.season)} $selection" - } - } - var startAction: Int? = null private var startValue: Int? = null @@ -863,7 +856,6 @@ class ResultFragment : ResultTrailerPlayer() { } observe(viewModel.loadedLinks) { load -> - when (load) { is Some.Success -> { if (loadingDialog?.isShowing != true) { @@ -1034,17 +1026,15 @@ class ResultFragment : ResultTrailerPlayer() { System.currentTimeMillis(), ) ) { click -> - //when(click.action) { - // DOWNLOAD_ACTION_LONG_CLICK -> { - // viewModel.handleAction( - // activity, - // EpisodeClickEvent(ACTION_DOWNLOAD_MIRROR, ep) - // ) - // } - // - //} - handleDownloadClick(activity, click) - // handleDownloadClick(activity,) + when(click.action) { + DOWNLOAD_ACTION_DOWNLOAD -> { + viewModel.handleAction( + activity, + EpisodeClickEvent(ACTION_DOWNLOAD_EPISODE, ep) + ) + } + else -> handleDownloadClick(activity, click) + } } result_movie_progress_downloaded_holder?.isVisible = true } @@ -1176,132 +1166,6 @@ class ResultFragment : ResultTrailerPlayer() { result_tag?.addView(viewBtt, index) } } - - //TODO FIX - /* - if (d.typeText.isMovieType()) { - val hasDownloadSupport = api.hasDownloadSupport - lateFixDownloadButton(true) - - result_play_movie?.setOnClickListener { - val card = - currentEpisodes?.firstOrNull() ?: return@setOnClickListener - handleAction(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card)) - } - - result_play_movie?.setOnLongClickListener { - val card = currentEpisodes?.firstOrNull() - ?: return@setOnLongClickListener true - handleAction(EpisodeClickEvent(ACTION_SHOW_OPTIONS, card)) - return@setOnLongClickListener true - } - - result_download_movie?.setOnLongClickListener { - val card = currentEpisodes?.firstOrNull() - ?: return@setOnLongClickListener true - handleAction(EpisodeClickEvent(ACTION_SHOW_OPTIONS, card)) - return@setOnLongClickListener true - } - - result_movie_progress_downloaded_holder?.isVisible = hasDownloadSupport - if (hasDownloadSupport) { - val localId = d.getId() - - val file = - VideoDownloadManager.getDownloadFileInfoAndUpdateSettings( - requireContext(), - localId - ) - downloadButton?.dispose() - downloadButton = EasyDownloadButton() - downloadButton?.setUpMoreButton( - file?.fileLength, - file?.totalBytes, - result_movie_progress_downloaded, - result_movie_download_icon, - result_movie_download_text, - result_movie_download_text_precentage, - result_download_movie, - true, - VideoDownloadHelper.DownloadEpisodeCached( - d.name, - d.posterUrl, - 0, - null, - localId, - localId, - d.rating, - d.plot, - System.currentTimeMillis(), - ), - ::handleDownloadButton - ) - - result_download_movie?.setOnLongClickListener { - val card = - currentEpisodes?.firstOrNull() - ?: return@setOnLongClickListener false - handleAction(EpisodeClickEvent(ACTION_DOWNLOAD_MIRROR, card)) - return@setOnLongClickListener true - } - - /*downloadButton?.setUpMaterialButton( - file?.fileLength, - file?.totalBytes, - result_movie_progress_downloaded, - result_download_movie, - null, //result_movie_text_progress - VideoDownloadHelper.DownloadEpisodeCached( - d.name, - d.posterUrl, - 0, - null, - localId, - localId, - d.rating, - d.plot, - System.currentTimeMillis(), - ) - ) { downloadClickEvent -> - if (downloadClickEvent.action == DOWNLOAD_ACTION_DOWNLOAD) { - currentEpisodes?.firstOrNull()?.let { episode -> - handleAction( - EpisodeClickEvent( - ACTION_DOWNLOAD_EPISODE, - ResultEpisode( - d.name, - d.name, - null, - 0, - null, - episode.data, - d.apiName, - localId, - 0, - 0L, - 0L, - null, - null, - null, - d.type, - localId, - ) - ) - ) - } - } else { - handleDownloadClick( - activity, - currentHeaderName, - downloadClickEvent - ) - } - }*/ - } - } else { - lateFixDownloadButton(false) - } - */ } is Resource.Failure -> { result_error_text.text = url?.plus("\n") + data.errorString diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt index 67d30a00..03b31936 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt @@ -1659,9 +1659,9 @@ class ResultViewModel2 : ViewModel() { if (loadResponse is EpisodeResponse) { _seasonSelections.postValue(seasonsSelection.map { seasonNumber -> val name = - loadResponse.seasonNames?.firstOrNull { it.season == seasonNumber }?.name?.let { seasonData -> + /*loadResponse.seasonNames?.firstOrNull { it.season == seasonNumber }?.name?.let { seasonData -> txt(seasonData) - } ?: txt(R.string.season_format, txt(R.string.season), seasonNumber) + } ?:*/ txt(R.string.season_format, txt(R.string.season), seasonNumber) //TODO FIX name to seasonNumber }) }