AoDParser Media handling rework [Part 2/2]

* move Player to new AoD media Implementation
* remove old AoD media Implementation from AoDParser
This commit is contained in:
2021-09-04 13:33:46 +02:00
parent c2a5f768b8
commit ed9eff433b
11 changed files with 81 additions and 313 deletions

View File

@ -82,6 +82,11 @@ data class AoDEpisode(
?: streams.first()
}
data class Stream(
val url: String,
val language : Locale
)
// TODO will be watched info (state and callback) -> remove description and number
data class AoDEpisodeInfo(
val aodMediaId: Int,
@ -114,62 +119,6 @@ val AoDEpisodeNone = AoDEpisode(
mutableListOf()
)
// LEGACY
data class Media(
val id: Int,
val link: String,
val type: DataTypes.MediaType,
val info: Info = Info(),
val episodes: ArrayList<Episode> = arrayListOf()
) {
fun hasEpisode(id: Int) = episodes.any { it.id == id }
fun getEpisodeById(id: Int) = episodes.first { it.id == id }
}
/**
* uses var, since the values are written in different steps
*/
data class Info(
var title: String = "",
var posterUrl: String = "",
var shortDesc: String = "",
var description: String = "",
var year: Int = 0,
var age: Int = 0,
var episodesCount: Int = 0,
var similar: List<ItemMedia> = listOf()
)
/**
* number = episode number (0..n)
*/
data class Episode(
val id: Int = -1,
val streams: MutableList<Stream> = mutableListOf(),
val title: String = "",
val posterUrl: String = "",
val description: String = "",
var shortDesc: String = "",
val number: Int = 0,
var watched: Boolean = false,
var watchedCallback: String = ""
) {
/**
* get the preferred stream
* @return the preferred stream, if not present use the first stream
*/
fun getPreferredStream(language: Locale) =
streams.firstOrNull { it.language == language } ?: streams.first()
fun hasDub() = streams.any { it.language == Locale.GERMAN }
}
data class Stream(
val url: String,
val language : Locale
)
/**
* this class is used to represent the aod json API?
*/

View File

@ -9,9 +9,9 @@ import com.bumptech.glide.request.RequestOptions
import jp.wasabeef.glide.transformations.RoundedCornersTransformation
import org.mosad.teapod.R
import org.mosad.teapod.databinding.ItemEpisodePlayerBinding
import org.mosad.teapod.util.Episode
import org.mosad.teapod.util.AoDEpisode
class PlayerEpisodeItemAdapter(private val episodes: List<Episode>) : RecyclerView.Adapter<PlayerEpisodeItemAdapter.EpisodeViewHolder>() {
class PlayerEpisodeItemAdapter(private val episodes: List<AoDEpisode>) : RecyclerView.Adapter<PlayerEpisodeItemAdapter.EpisodeViewHolder>() {
var onImageClick: ((String, Int) -> Unit)? = null
var currentSelected: Int = -1 // -1, since position should never be < 0
@ -33,8 +33,8 @@ class PlayerEpisodeItemAdapter(private val episodes: List<Episode>) : RecyclerVi
holder.binding.textEpisodeTitle2.text = titleText
holder.binding.textEpisodeDesc2.text = ep.shortDesc
if (episodes[position].posterUrl.isNotEmpty()) {
Glide.with(context).load(ep.posterUrl)
if (ep.imageURL.isNotEmpty()) {
Glide.with(context).load(ep.imageURL)
.apply(RequestOptions.bitmapTransform(RoundedCornersTransformation(10, 0)))
.into(holder.binding.imageEpisode)
}