use Gson in TMDBApiController, adapt tmdb types to api documentation

* use gson fromJson() to parse tmdb response
* adapt tmd types to documentation (nullable/non nullable)
This commit is contained in:
2021-07-17 13:15:14 +02:00
parent c66c725ee3
commit 26d2da923b
5 changed files with 176 additions and 98 deletions

View File

@ -86,9 +86,9 @@ class MediaFragment(private val mediaId: Int) : Fragment() {
*/
private fun updateGUI() = with(model) {
// generic gui
val backdropUrl = tmdbResult.backdropPath?.let { TMDBApiController.imageUrl + it }
val backdropUrl = tmdbResult?.backdropPath?.let { TMDBApiController.imageUrl + it }
?: media.info.posterUrl
val posterUrl = tmdbResult.posterPath?.let { TMDBApiController.imageUrl + it }
val posterUrl = tmdbResult?.posterPath?.let { TMDBApiController.imageUrl + it }
?: media.info.posterUrl
// load poster and backdrop
@ -138,9 +138,9 @@ class MediaFragment(private val mediaId: Int) : Fragment() {
fragments.add(MediaFragmentEpisodes())
pagerAdapter.notifyDataSetChanged()
} else if (media.type == MediaType.MOVIE) {
val tmdbMovie = (tmdbResult as Movie)
val tmdbMovie = (tmdbResult as Movie?)
if (tmdbMovie.runtime != null) {
if (tmdbMovie?.runtime != null) {
binding.textEpisodesOrRuntime.text = resources.getQuantityString(
R.plurals.text_runtime,
tmdbMovie.runtime,