适配返回数据
This commit is contained in:
parent
dc65bd0562
commit
2e2f37c586
|
|
@ -5,92 +5,20 @@ import com.ama.core.model.BaseFragmentStateDiffItem
|
|||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
data class ResYoutubeChannel(
|
||||
val id: String,
|
||||
val name: String,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@Serializable
|
||||
data class ResYoutubePlayList (
|
||||
val kind: String,
|
||||
val etag: String, // TODO - this is Etag type
|
||||
val nextPageToken: String,
|
||||
val prevPageToken: String,
|
||||
val pageInfo: PageInfo,
|
||||
val items: List<YoutubeVideo>,
|
||||
val videos: List<YoutubeVideo>,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class PageInfo(
|
||||
val totalResults: Int,
|
||||
val resultsPerPage: Int,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class YoutubeVideo(
|
||||
val kind: String,
|
||||
val etag: String,
|
||||
val id: String,
|
||||
val snippet: Snippet,
|
||||
val status: Status,
|
||||
|
||||
val contentDetails: ContentDetails,
|
||||
val player: Player,
|
||||
val localizations: Localizations,
|
||||
val channel_title: String,
|
||||
val description: String,
|
||||
) : BaseFragmentStateDiffItem {
|
||||
override fun getPrimaryKey() = id
|
||||
override fun getItemId() = id.hashCode().toLong()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Serializable
|
||||
data class ContentDetails(
|
||||
val itemCount: Int,
|
||||
)
|
||||
@Serializable
|
||||
data class Player(
|
||||
val embedHtml: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Localizations(
|
||||
val title: String,
|
||||
val description: String,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@Serializable
|
||||
data class Snippet(
|
||||
val publishedAt: String,
|
||||
val channelId: String,
|
||||
val title: String,
|
||||
val description: String,
|
||||
//val thumbnails: Thumbnail,
|
||||
val channelTitle: String,
|
||||
val defaultLanguage: String,
|
||||
val localized: Localized,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Localized(
|
||||
val title: String,
|
||||
val description: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Thumbnail(
|
||||
val standard: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Status(
|
||||
val privacyStatus: String,
|
||||
val podcastStatus: Int,
|
||||
)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package com.gamedog.vididin.beans
|
||||
|
||||
|
||||
import com.ama.core.model.BaseFragmentStateDiffItem
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
data class ResYoutubeChannel(
|
||||
val id: String,
|
||||
val name: String,
|
||||
)
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
@Serializable
|
||||
data class ResYoutubePlayList (
|
||||
val kind: String,
|
||||
val etag: String, // TODO - this is Etag type
|
||||
val nextPageToken: String,
|
||||
val prevPageToken: String,
|
||||
val pageInfo: PageInfo,
|
||||
val items: List<YoutubeVideo>,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class PageInfo(
|
||||
val totalResults: Int,
|
||||
val resultsPerPage: Int,
|
||||
)
|
||||
@Serializable
|
||||
data class YoutubeVideo(
|
||||
val kind: String,
|
||||
val etag: String,
|
||||
val id: String,
|
||||
val snippet: Snippet,
|
||||
val status: Status,
|
||||
|
||||
val contentDetails: ContentDetails,
|
||||
val player: Player,
|
||||
val localizations: Localizations,
|
||||
) : BaseFragmentStateDiffItem {
|
||||
override fun getPrimaryKey() = id
|
||||
override fun getItemId() = id.hashCode().toLong()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Serializable
|
||||
data class ContentDetails(
|
||||
val itemCount: Int,
|
||||
)
|
||||
@Serializable
|
||||
data class Player(
|
||||
val embedHtml: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Localizations(
|
||||
val title: String,
|
||||
val description: String,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@Serializable
|
||||
data class Snippet(
|
||||
val publishedAt: String,
|
||||
val channelId: String,
|
||||
val title: String,
|
||||
val description: String,
|
||||
//val thumbnails: Thumbnail,
|
||||
val channelTitle: String,
|
||||
val defaultLanguage: String,
|
||||
val localized: Localized,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Localized(
|
||||
val title: String,
|
||||
val description: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Thumbnail(
|
||||
val standard: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Status(
|
||||
val privacyStatus: String,
|
||||
val podcastStatus: Int,
|
||||
)
|
||||
|
||||
|
||||
*/
|
||||
|
|
@ -20,7 +20,7 @@ class DefaultYoutubeRepository @Inject constructor(
|
|||
page: Int,
|
||||
size: Int
|
||||
): ResYoutubePlayList {
|
||||
return network.getVideoList(mRespPlayList?.nextPageToken)
|
||||
return network.getVideoList(mRespPlayList?.videos?.last()?.id)
|
||||
}
|
||||
|
||||
override suspend fun getChannelList(
|
||||
|
|
@ -35,7 +35,7 @@ class DefaultYoutubeRepository @Inject constructor(
|
|||
pageSize: Int
|
||||
): List<YoutubeVideo>? {
|
||||
mRespPlayList = getVideoList(key, pageSize)
|
||||
return mRespPlayList?.items
|
||||
return mRespPlayList?.videos
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
|||
if (mIsPlaying) mPlayer?.pause() else mPlayer?.play()
|
||||
}
|
||||
|
||||
tvVideoFrom.text = mVideoData?.snippet?.localized?.title
|
||||
tvVideoIntro.text = mVideoData?.snippet?.localized?.description
|
||||
tvVideoFrom.text = mVideoData?.channel_title
|
||||
tvVideoIntro.text = mVideoData?.description
|
||||
|
||||
popMenu.setMenuList(
|
||||
mutableListOf(
|
||||
|
|
|
|||
Loading…
Reference in New Issue