介绍和标题
This commit is contained in:
parent
38682f7815
commit
c5153e3a95
|
|
@ -45,7 +45,7 @@ interface YoutubeApi {
|
||||||
|
|
||||||
@GET("/youtube/v3/videos")
|
@GET("/youtube/v3/videos")
|
||||||
suspend fun getVideoList(
|
suspend fun getVideoList(
|
||||||
@Query("part") part: String= URLEncoder.encode("id", "UTF-8"),
|
@Query("part") part: String= URLEncoder.encode("snippet", "UTF-8"),
|
||||||
@Query("key") key: String= VidiConst.YOUTUBE_API_KEY,
|
@Query("key") key: String= VidiConst.YOUTUBE_API_KEY,
|
||||||
@Query("chart") chart: String="mostPopular",
|
@Query("chart") chart: String="mostPopular",
|
||||||
@Query("regionCode") regionCode: String="BR",
|
@Query("regionCode") regionCode: String="BR",
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,7 @@ import kotlinx.serialization.Serializable
|
||||||
data class ResYoutubeChannel(
|
data class ResYoutubeChannel(
|
||||||
val id: String,
|
val id: String,
|
||||||
val name: String,
|
val name: String,
|
||||||
) : BaseFragmentStateDiffItem {
|
)
|
||||||
override fun getPrimaryKey() = id
|
|
||||||
override fun getItemId() = id.hashCode().toLong()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -24,21 +21,13 @@ data class ResYoutubePlayList (
|
||||||
val prevPageToken: String,
|
val prevPageToken: String,
|
||||||
val pageInfo: PageInfo,
|
val pageInfo: PageInfo,
|
||||||
val items: List<YoutubeVideo>,
|
val items: List<YoutubeVideo>,
|
||||||
) /*: BaseFragmentStateDiffItem {
|
)
|
||||||
override fun getPrimaryKey() = pageInfo
|
|
||||||
override fun getItemId() = pageInfo.hashCode().toLong()
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class PageInfo(
|
data class PageInfo(
|
||||||
val totalResults: Int,
|
val totalResults: Int,
|
||||||
val resultsPerPage: Int,
|
val resultsPerPage: Int,
|
||||||
) : BaseFragmentStateDiffItem {
|
)
|
||||||
override fun getPrimaryKey() = totalResults
|
|
||||||
override fun getItemId() = totalResults.hashCode().toLong()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class YoutubeVideo(
|
data class YoutubeVideo(
|
||||||
val kind: String,
|
val kind: String,
|
||||||
|
|
@ -60,27 +49,17 @@ data class YoutubeVideo(
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ContentDetails(
|
data class ContentDetails(
|
||||||
val itemCount: Int,
|
val itemCount: Int,
|
||||||
): BaseFragmentStateDiffItem {
|
)
|
||||||
override fun getPrimaryKey() = itemCount
|
|
||||||
override fun getItemId() = itemCount.hashCode().toLong()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Player(
|
data class Player(
|
||||||
val embedHtml: String,
|
val embedHtml: String,
|
||||||
): BaseFragmentStateDiffItem {
|
)
|
||||||
override fun getPrimaryKey() = embedHtml
|
|
||||||
override fun getItemId() = embedHtml.hashCode().toLong()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Localizations(
|
data class Localizations(
|
||||||
val title: String,
|
val title: String,
|
||||||
val description: String,
|
val description: String,
|
||||||
): BaseFragmentStateDiffItem {
|
)
|
||||||
override fun getPrimaryKey() = title
|
|
||||||
override fun getItemId() = title.hashCode().toLong()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -90,33 +69,28 @@ data class Snippet(
|
||||||
val channelId: String,
|
val channelId: String,
|
||||||
val title: String,
|
val title: String,
|
||||||
val description: String,
|
val description: String,
|
||||||
val thumbnails: String, //
|
//val thumbnails: Thumbnail,
|
||||||
|
|
||||||
val channelTitle: String,
|
val channelTitle: String,
|
||||||
val defaultLanguage: String,
|
val defaultLanguage: String,
|
||||||
val localized: Localized,
|
val localized: Localized,
|
||||||
) : BaseFragmentStateDiffItem {
|
)
|
||||||
override fun getPrimaryKey() = channelId
|
|
||||||
override fun getItemId() = channelId.hashCode().toLong()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Localized(
|
data class Localized(
|
||||||
val title: String,
|
val title: String,
|
||||||
val description: String,
|
val description: String,
|
||||||
) : BaseFragmentStateDiffItem {
|
)
|
||||||
override fun getPrimaryKey() = title
|
|
||||||
override fun getItemId() = title.hashCode().toLong()
|
@Serializable
|
||||||
}
|
data class Thumbnail(
|
||||||
|
val standard: String,
|
||||||
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Status(
|
data class Status(
|
||||||
val privacyStatus: String,
|
val privacyStatus: String,
|
||||||
val podcastStatus: Int,
|
val podcastStatus: Int,
|
||||||
): BaseFragmentStateDiffItem {
|
)
|
||||||
override fun getPrimaryKey() = podcastStatus
|
|
||||||
override fun getItemId() = privacyStatus.hashCode().toLong()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,5 +28,7 @@ class YoutubeViewModel @Inject constructor(
|
||||||
|
|
||||||
data class YoutubeUiState(
|
data class YoutubeUiState(
|
||||||
val playLists: List<YoutubeVideo>? = null,
|
val playLists: List<YoutubeVideo>? = null,
|
||||||
|
val taskRestTime: Long = 0,
|
||||||
|
val starState: Boolean = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package com.gamedog.vididin.main.fragments.home.fragment
|
||||||
|
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.method.MovementMethod
|
||||||
|
import android.text.method.ScrollingMovementMethod
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
|
@ -10,6 +12,7 @@ import android.view.animation.Animation
|
||||||
import android.view.animation.AnimationSet
|
import android.view.animation.AnimationSet
|
||||||
import android.view.animation.ScaleAnimation
|
import android.view.animation.ScaleAnimation
|
||||||
import androidx.annotation.NonNull
|
import androidx.annotation.NonNull
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.ama.core.architecture.appBase.AppViewsEmptyViewModelFragment
|
import com.ama.core.architecture.appBase.AppViewsEmptyViewModelFragment
|
||||||
import com.ama.core.common.widget.PopMenuIconView
|
import com.ama.core.common.widget.PopMenuIconView
|
||||||
import com.gamedog.vididin.R
|
import com.gamedog.vididin.R
|
||||||
|
|
@ -46,8 +49,8 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
if (mIsPlaying) mPlayer?.pause() else mPlayer?.play()
|
if (mIsPlaying) mPlayer?.pause() else mPlayer?.play()
|
||||||
}
|
}
|
||||||
|
|
||||||
tvVideoFrom.text = "@From-" + arguments?.getLong(KEY_ID).toString()
|
tvVideoFrom.text = mVideoData?.snippet?.localized?.title
|
||||||
tvVideoIntro.text = "Introduce-" + arguments?.getLong(KEY_ID).toString()
|
tvVideoIntro.text = mVideoData?.snippet?.localized?.description
|
||||||
|
|
||||||
popMenu.setMenuList(
|
popMenu.setMenuList(
|
||||||
mutableListOf(
|
mutableListOf(
|
||||||
|
|
@ -189,6 +192,10 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
mVideoData!!.id,
|
mVideoData!!.id,
|
||||||
0f
|
0f
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!playerView.isVisible) {
|
||||||
|
youTubePlayer.pause()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,7 +220,6 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
}
|
}
|
||||||
PlayerConstants.PlayerState.ENDED -> {
|
PlayerConstants.PlayerState.ENDED -> {
|
||||||
mIsPlaying = false
|
mIsPlaying = false
|
||||||
showPlayIconAnim()
|
|
||||||
}
|
}
|
||||||
PlayerConstants.PlayerState.BUFFERING -> {
|
PlayerConstants.PlayerState.BUFFERING -> {
|
||||||
mIsPlaying = false
|
mIsPlaying = false
|
||||||
|
|
@ -226,8 +232,22 @@ class HomeItemFragment : AppViewsEmptyViewModelFragment<ViewBinding>() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
mPlayer?.play()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStop() {
|
||||||
|
super.onStop()
|
||||||
|
mPlayer?.pause()
|
||||||
|
}
|
||||||
|
|
||||||
private fun hidePlayIconAnim() {
|
private fun hidePlayIconAnim() {
|
||||||
|
if (!binding?.playIcon!!.isVisible) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
with (binding?.playIcon!!) {
|
with (binding?.playIcon!!) {
|
||||||
val animationSet = AnimationSet(true)
|
val animationSet = AnimationSet(true)
|
||||||
animationSet.duration = 250
|
animationSet.duration = 250
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
android:padding="20dp"
|
android:padding="20dp"
|
||||||
android:src="@mipmap/icon_play"
|
android:src="@mipmap/icon_play"
|
||||||
|
android:visibility="gone"
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -72,7 +73,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginVertical="25dp"
|
android:layout_marginVertical="25dp"
|
||||||
android:layout_marginHorizontal="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
|
android:layout_marginRight="80dp"
|
||||||
android:layout_gravity="bottom">
|
android:layout_gravity="bottom">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
@ -83,14 +85,21 @@
|
||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
android:textColor="@color/white" />
|
android:textColor="@color/white" />
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_video_intro"
|
android:id="@+id/tv_video_intro"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:text="introduce"
|
android:text="introduce"
|
||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
android:textColor="@color/white_al80" />
|
android:textColor="@color/white_al80" />
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ import androidx.fragment.app.Fragment
|
||||||
import com.ama.core.architecture.BaseApp
|
import com.ama.core.architecture.BaseApp
|
||||||
|
|
||||||
|
|
||||||
private fun toast(strRes: Int): Unit {
|
fun showToast(strRes: Int): Unit {
|
||||||
Toast.makeText(BaseApp.appContext(), strRes, Toast.LENGTH_SHORT).show()
|
Toast.makeText(BaseApp.appContext(), strRes, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun View.toast(strRes: Int): Unit = toast(strRes = strRes)
|
fun View.toast(strRes: Int): Unit = showToast(strRes = strRes)
|
||||||
fun Fragment.toast(strRes: Int): Unit = toast(strRes = strRes)
|
fun Fragment.toast(strRes: Int): Unit = showToast(strRes = strRes)
|
||||||
fun Activity.toast(strRes: Int): Unit = toast(strRes = strRes)
|
fun Activity.toast(strRes: Int): Unit = showToast(strRes = strRes)
|
||||||
|
|
@ -1,23 +1,8 @@
|
||||||
package com.ama.core.model
|
package com.ama.core.model
|
||||||
|
|
||||||
|
|
||||||
interface BaseDiffItem {
|
interface BaseDiffItem {
|
||||||
/**
|
|
||||||
* 用于一级的(areItemsTheSame)比较,获取主key。
|
|
||||||
*/
|
|
||||||
fun getPrimaryKey(): Any
|
fun getPrimaryKey(): Any
|
||||||
|
|
||||||
/**
|
|
||||||
* 用于二级的(areContentsTheSame)比较,默认比较整个对象自己,可修改为比较部分属性。
|
|
||||||
*/
|
|
||||||
fun <T> areContentsTheSame(newItem: T): Boolean = this == newItem
|
fun <T> areContentsTheSame(newItem: T): Boolean = this == newItem
|
||||||
|
|
||||||
/**
|
|
||||||
* 用于可选实现(getChangePayload),局部更新时用,获取Item布局局部更新的数据对象。
|
|
||||||
* 说明:
|
|
||||||
* 1、返回null,Item布局更新有动画,否则无动画。
|
|
||||||
* 2、需要配合RecyclerView的onBindViewHolder(holder,position,payloads)使用,在payloads内获取传入的值。
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
fun <T> getChangePayload(newItem: T): Any? = newItem
|
fun <T> getChangePayload(newItem: T): Any? = newItem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.ama.core.model
|
package com.ama.core.model
|
||||||
|
|
||||||
import com.ama.core.model.BaseDiffItem
|
|
||||||
|
|
||||||
interface BaseFragmentStateDiffItem : BaseDiffItem {
|
interface BaseFragmentStateDiffItem : BaseDiffItem {
|
||||||
fun getItemId(): Long
|
fun getItemId(): Long
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue