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 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") @SuppressLint("SetTextI18n")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
@ -690,6 +702,8 @@ class ResultFragment : Fragment() {
} }
observe(viewModel.episodes) { episodeList -> observe(viewModel.episodes) { episodeList ->
lateFixDownloadButton( episodeList.size <= 1) // movies can have multible parts but still be *movies* this will fix this
when (startAction) { when (startAction) {
START_ACTION_RESUME_LATEST -> { START_ACTION_RESUME_LATEST -> {
for (ep in episodeList) { 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 val hasDownloadSupport = api.hasDownloadSupport
result_movie_parent.visibility = VISIBLE lateFixDownloadButton(true)
result_episodes_text.visibility = GONE
result_episodes.visibility = GONE
result_play_movie.setOnClickListener { result_play_movie.setOnClickListener {
val card = currentEpisodes?.first() ?: return@setOnClickListener val card = currentEpisodes?.first() ?: return@setOnClickListener
@ -933,34 +945,34 @@ class ResultFragment : Fragment() {
) )
) { downloadClickEvent -> ) { downloadClickEvent ->
if (downloadClickEvent.action == DOWNLOAD_ACTION_DOWNLOAD) { if (downloadClickEvent.action == DOWNLOAD_ACTION_DOWNLOAD) {
handleAction( currentEpisodes?.first()?.let { episode ->
EpisodeClickEvent( handleAction(
ACTION_DOWNLOAD_EPISODE, EpisodeClickEvent(
ResultEpisode( ACTION_DOWNLOAD_EPISODE,
d.name, ResultEpisode(
null, d.name,
0, null,
null, 0,
d.dataUrl, null,
d.apiName, episode.data,
localId, d.apiName,
0, localId,
0L, 0,
0L, 0L,
null, 0L,
null null,
null
)
) )
) )
) }
} else { } else {
handleDownloadClick(activity, currentHeaderName, downloadClickEvent) handleDownloadClick(activity, currentHeaderName, downloadClickEvent)
} }
} }
} }
} else { } else {
result_movie_parent.visibility = GONE lateFixDownloadButton(false)
result_episodes_text.visibility = VISIBLE
result_episodes.visibility = VISIBLE
} }
when (d) { when (d) {

View file

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