fix semi movie

This commit is contained in:
LagradOst 2021-08-11 20:26:19 +02:00
parent 693edef893
commit 5e619c18cc
2 changed files with 47 additions and 32 deletions

View file

@ -237,6 +237,18 @@ class ResultFragment : Fragment() {
var startAction: Int? = null
private fun lateFixDownloadButton(show: Boolean) {
if (show) {
result_movie_parent.visibility = VISIBLE
result_episodes_text.visibility = GONE
result_episodes.visibility = GONE
} else {
result_movie_parent.visibility = GONE
result_episodes_text.visibility = VISIBLE
result_episodes.visibility = VISIBLE
}
}
@SuppressLint("SetTextI18n")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -690,6 +702,8 @@ class ResultFragment : Fragment() {
}
observe(viewModel.episodes) { episodeList ->
lateFixDownloadButton( episodeList.size <= 1) // movies can have multible parts but still be *movies* this will fix this
when (startAction) {
START_ACTION_RESUME_LATEST -> {
for (ep in episodeList) {
@ -884,11 +898,9 @@ class ResultFragment : Fragment() {
}
}
if (d.type == TvType.Movie && d is MovieLoadResponse) {
if (d.type == TvType.Movie) {
val hasDownloadSupport = api.hasDownloadSupport
result_movie_parent.visibility = VISIBLE
result_episodes_text.visibility = GONE
result_episodes.visibility = GONE
lateFixDownloadButton(true)
result_play_movie.setOnClickListener {
val card = currentEpisodes?.first() ?: return@setOnClickListener
@ -933,6 +945,7 @@ class ResultFragment : Fragment() {
)
) { downloadClickEvent ->
if (downloadClickEvent.action == DOWNLOAD_ACTION_DOWNLOAD) {
currentEpisodes?.first()?.let { episode ->
handleAction(
EpisodeClickEvent(
ACTION_DOWNLOAD_EPISODE,
@ -941,7 +954,7 @@ class ResultFragment : Fragment() {
null,
0,
null,
d.dataUrl,
episode.data,
d.apiName,
localId,
0,
@ -952,15 +965,14 @@ class ResultFragment : Fragment() {
)
)
)
}
} else {
handleDownloadClick(activity, currentHeaderName, downloadClickEvent)
}
}
}
} else {
result_movie_parent.visibility = GONE
result_episodes_text.visibility = VISIBLE
result_episodes.visibility = VISIBLE
lateFixDownloadButton(false)
}
when (d) {

View file

@ -50,19 +50,22 @@ object AppUtils {
* | Episode 2
* **/
fun getNameFull(name: String?, episode: Int?, season: Int?): String {
val rEpisode = if(episode == 0) null else episode
val rSeason = if(season == 0) null else season
if (name != null) {
return if(episode != null && season != null) {
"S${season}:E${episode} $name"
} else if(episode != null) {
"Episode $episode. $name"
return if(rEpisode != null && rSeason != null) {
"S${rSeason}:E${rEpisode} $name"
} else if(rEpisode != null) {
"Episode $rEpisode. $name"
} else {
name
}
} else {
if(episode != null && season != null) {
return "Season $season - Episode $episode"
} else if(season == null) {
return "Episode $episode"
if(rEpisode != null && rSeason != null) {
return "Season $rSeason - Episode $rEpisode"
} else if(rSeason == null) {
return "Episode $rEpisode"
}
}
return ""