Gaana Response Null Issue Fix

This commit is contained in:
Shabinder 2020-11-09 16:39:59 +05:30
parent d97536ee50
commit e62abca957
2 changed files with 12 additions and 12 deletions

View File

@ -23,19 +23,19 @@ import com.squareup.moshi.Json
data class GaanaTrack (
val tags : List<Tags?>?,
val seokey : String,
val albumseokey : String,
val albumseokey : String?,
val track_title : String,
val album_title : String,
val language : String,
val album_title : String?,
val language : String?,
val duration: Int,
@Json(name = "artwork_large") val artworkLink : String,
val artist : List<Artist>,
@Json(name = "gener") val genre : List<Genre>,
val lyrics_url : String,
val youtube_id : String,
val total_favourite_count : Int,
val release_date : String,
val play_ct : String,
val artist : List<Artist?>,
@Json(name = "gener") val genre : List<Genre?>?,
val lyrics_url : String?,
val youtube_id : String?,
val total_favourite_count : Int?,
val release_date : String?,
val play_ct : String?,
val secondary_language : String?,
var downloaded: DownloadStatus? = DownloadStatus.NotDownloaded
)

View File

@ -159,14 +159,14 @@ class GaanaViewModel @ViewModelInject constructor(val databaseDAO: DatabaseDAO)
private fun List<GaanaTrack>.toTrackDetailsList() = this.map {
TrackDetails(
title = it.track_title,
artists = it.artist.map { artist -> artist.name },
artists = it.artist.map { artist -> artist?.name.toString() },
durationSec = it.duration,
albumArt = File(
Environment.getExternalStorageDirectory(),
Provider.defaultDir +".Images/" + (it.artworkLink.substringBeforeLast('/').substringAfterLast('/')) + ".jpeg"),
albumName = it.album_title,
year = it.release_date,
comment = "Genres:${it.genre.map { genre -> genre.name }.reduceOrNull { acc, s -> acc + s }}",
comment = "Genres:${it.genre?.map { genre -> genre?.name }?.reduceOrNull { acc, s -> acc + s }}",
trackUrl = it.lyrics_url,
downloaded = it.downloaded ?: DownloadStatus.NotDownloaded,
source = Source.Gaana,