适配返回数据
This commit is contained in:
parent
dc65bd0562
commit
2e2f37c586
|
|
@ -5,92 +5,20 @@ import com.ama.core.model.BaseFragmentStateDiffItem
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class ResYoutubeChannel(
|
|
||||||
val id: String,
|
|
||||||
val name: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ResYoutubePlayList (
|
data class ResYoutubePlayList (
|
||||||
val kind: String,
|
val videos: List<YoutubeVideo>,
|
||||||
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
|
@Serializable
|
||||||
data class YoutubeVideo(
|
data class YoutubeVideo(
|
||||||
val kind: String,
|
|
||||||
val etag: String,
|
|
||||||
val id: String,
|
val id: String,
|
||||||
val snippet: Snippet,
|
val channel_title: String,
|
||||||
val status: Status,
|
val description: String,
|
||||||
|
|
||||||
val contentDetails: ContentDetails,
|
|
||||||
val player: Player,
|
|
||||||
val localizations: Localizations,
|
|
||||||
) : BaseFragmentStateDiffItem {
|
) : BaseFragmentStateDiffItem {
|
||||||
override fun getPrimaryKey() = id
|
override fun getPrimaryKey() = id
|
||||||
override fun getItemId() = id.hashCode().toLong()
|
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,
|
page: Int,
|
||||||
size: Int
|
size: Int
|
||||||
): ResYoutubePlayList {
|
): ResYoutubePlayList {
|
||||||
return network.getVideoList(mRespPlayList?.nextPageToken)
|
return network.getVideoList(mRespPlayList?.videos?.last()?.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getChannelList(
|
override suspend fun getChannelList(
|
||||||
|
|
@ -35,7 +35,7 @@ class DefaultYoutubeRepository @Inject constructor(
|
||||||
pageSize: Int
|
pageSize: Int
|
||||||
): List<YoutubeVideo>? {
|
): List<YoutubeVideo>? {
|
||||||
mRespPlayList = getVideoList(key, pageSize)
|
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()
|
if (mIsPlaying) mPlayer?.pause() else mPlayer?.play()
|
||||||
}
|
}
|
||||||
|
|
||||||
tvVideoFrom.text = mVideoData?.snippet?.localized?.title
|
tvVideoFrom.text = mVideoData?.channel_title
|
||||||
tvVideoIntro.text = mVideoData?.snippet?.localized?.description
|
tvVideoIntro.text = mVideoData?.description
|
||||||
|
|
||||||
popMenu.setMenuList(
|
popMenu.setMenuList(
|
||||||
mutableListOf(
|
mutableListOf(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue