Merge branch 'dev_4.0.2' of gitlab.ghzhushou.com:halo/assistant-android into dev_4.0.2
This commit is contained in:
@ -60,7 +60,7 @@ object TimeUtils {
|
||||
/**
|
||||
* 判断时间戳是多少天前
|
||||
*/
|
||||
fun getBeforeDays(timestamp: Long):Int{
|
||||
fun getBeforeDays(timestamp: Long): Int {
|
||||
var days: Long = 0
|
||||
val format = SimpleDateFormat("yyyyMMdd HH:mm", Locale.getDefault())
|
||||
try {
|
||||
@ -73,4 +73,15 @@ object TimeUtils {
|
||||
|
||||
return days.toInt()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 格式化视频时长
|
||||
*/
|
||||
@JvmStatic
|
||||
fun formatVideoDuration(length: Long): String {
|
||||
val minute = length / 60
|
||||
val second = length % 60
|
||||
return String.format(Locale.CHINA, "%02d:%02d", minute, second)
|
||||
}
|
||||
}
|
||||
@ -9,14 +9,13 @@ import com.gh.common.util.*
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder
|
||||
import com.gh.gamecenter.baselist.ListAdapter
|
||||
import com.gh.gamecenter.databinding.VideoItemBinding
|
||||
import com.gh.gamecenter.databinding.VideoNewItemBinding
|
||||
import com.gh.gamecenter.entity.MyVideoEntity
|
||||
import com.gh.gamecenter.video.VideoItemViewHolder
|
||||
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
|
||||
|
||||
class VideoAdapter(context: Context,
|
||||
val mViewModel: VideoViewModel, val mVideoStyle: String) : ListAdapter<MyVideoEntity>(context) {
|
||||
val mViewModel: VideoViewModel, val mVideoStyle: String, val mEntrance: String) : ListAdapter<MyVideoEntity>(context) {
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
if (position == itemCount - 1) return ItemViewType.ITEM_FOOTER
|
||||
return ItemViewType.ITEM_BODY
|
||||
@ -44,8 +43,7 @@ class VideoAdapter(context: Context,
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
if (holder is VideoItemViewHolder) {
|
||||
val entity = mEntityList[position]
|
||||
ImageUtils.display(holder.binding.videoCover, entity.poster)
|
||||
holder.binding.videoLikeCount.text = entity.vote.toSimpleCount()
|
||||
holder.binding.video = entity
|
||||
holder.itemView.setOnClickListener {
|
||||
if (mVideoStyle == VideoFragment.VideoStyle.COLLECT.value) {
|
||||
DirectUtils.directToVideoDetail(mContext, entity.id, VideoDetailContainerViewModel.Location.USER_FAVORITE_VIDEO.value, false, path = getPath())
|
||||
@ -65,6 +63,10 @@ class VideoAdapter(context: Context,
|
||||
})
|
||||
}
|
||||
}
|
||||
holder.binding.userIcon.setOnClickListener {
|
||||
DirectUtils.directToHomeActivity(mContext, entity.user.id, mEntrance, getPath())
|
||||
}
|
||||
holder.binding.userName.setOnClickListener { holder.binding.userIcon.performClick() }
|
||||
} else if (holder is FooterViewHolder) {
|
||||
holder.initFooterViewHolder(mViewModel, mIsLoading, mIsNetworkError, mIsOver)
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.gh.gamecenter.collection
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.util.dip2px
|
||||
@ -17,18 +18,19 @@ class VideoFragment : ListFragment<MyVideoEntity, VideoViewModel>() {
|
||||
|
||||
override fun provideListAdapter(): VideoAdapter {
|
||||
if (mAdapter == null) {
|
||||
mAdapter = VideoAdapter(requireContext(), mViewModel!!, mVideoStyle)
|
||||
mAdapter = VideoAdapter(requireContext(), mViewModel!!, mVideoStyle,mEntrance)
|
||||
}
|
||||
return mAdapter!!
|
||||
}
|
||||
|
||||
override fun getItemDecoration(): RecyclerView.ItemDecoration {
|
||||
return GridSpacingItemDecoration(2, 1.5F.dip2px(), false, 8F.dip2px())
|
||||
return GridSpacingItemDecoration(2, 8F.dip2px(), false, 8F.dip2px())
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mVideoStyle = arguments?.getString("videoStyle") ?: ""
|
||||
super.onCreate(savedInstanceState)
|
||||
mListRv.setPadding(8f.dip2px(), 0, 8f.dip2px(), 0)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
||||
@ -277,10 +277,6 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
||||
val slideItem = HomeItemData()
|
||||
slideItem.slides = mHomeSlides
|
||||
mSnapshotItemList.add(slideItem)
|
||||
|
||||
for (slide in mHomeSlides) {
|
||||
if (slide.linkGame != null) addGamePositionAndPackage(slide.linkGame)
|
||||
}
|
||||
}
|
||||
|
||||
if (mHomeRecommends.isNotEmpty()) {
|
||||
@ -318,7 +314,6 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
||||
attachGame.blockPosition = i + 1
|
||||
attachGame.attachGame = homeContent
|
||||
mSnapshotItemList.add(attachGame)
|
||||
if (homeContent.linkGame != null) addGamePositionAndPackage(homeContent.linkGame)
|
||||
} else if (linkType == "top_game_comment") {
|
||||
val head = HomeItemData()
|
||||
head.columnHead = SubjectEntity(type = linkType, name = "安利墙")
|
||||
@ -365,8 +360,6 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
||||
itemDataList.postValue(mSnapshotItemList)
|
||||
}
|
||||
|
||||
|
||||
// todo 部分游戏Item不需要显示下载按钮,去除相关监听
|
||||
private fun addGamePositionAndPackage(game: GameEntity) {
|
||||
var packages = ""
|
||||
for (apkEntity in game.getApk()) {
|
||||
|
||||
@ -22,7 +22,8 @@ object LegacyHomeSubjectTransformer {
|
||||
val gameEntity = data[0]
|
||||
if (gameEntity.id.isEmpty()) gameEntity.id = gameEntity.link ?: ""
|
||||
|
||||
if (data[0].type == "column") {
|
||||
// 图片专题样式(后台操作->只显示(滑动))
|
||||
if (data[0].type == "column" && subjectEntity.type == "image_slide") {
|
||||
itemDataImage.imageSlide = gameEntity
|
||||
itemList.add(itemDataImage)
|
||||
} else {
|
||||
|
||||
@ -6,12 +6,9 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.constant.ItemViewType
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.ImageUtils
|
||||
import com.gh.common.util.toSimpleCount
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder
|
||||
import com.gh.gamecenter.baselist.ListAdapter
|
||||
import com.gh.gamecenter.databinding.VideoItemBinding
|
||||
import com.gh.gamecenter.databinding.VideoNewItemBinding
|
||||
import com.gh.gamecenter.entity.MyVideoEntity
|
||||
import com.gh.gamecenter.video.VideoItemViewHolder
|
||||
@ -51,8 +48,9 @@ class UserVideoHistoryAdapter(context: Context, val mViewModel: UserVideoHistory
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
if (holder is VideoItemViewHolder) {
|
||||
val entity = mEntityList[position]
|
||||
ImageUtils.display(holder.binding.videoCover, entity.poster)
|
||||
holder.binding.videoLikeCount.text = entity.vote.toSimpleCount()
|
||||
holder.binding.video = entity
|
||||
holder.binding.userIcon.visibility = View.GONE
|
||||
holder.binding.userName.visibility = View.GONE
|
||||
holder.itemView.setOnClickListener {
|
||||
DirectUtils.directToVideoDetail(mContext, entity.id, VideoDetailContainerViewModel.Location.USER_VIDEO.value, false, path = "个人主页-视频")
|
||||
}
|
||||
|
||||
@ -47,12 +47,12 @@ class UserVideoHistoryFragment : ListFragment<PersonalHistoryEntity, UserVideoHi
|
||||
}
|
||||
}
|
||||
mListRv.layoutManager = gridLayoutManager
|
||||
mListRv.background = ColorDrawable(ContextCompat.getColor(requireContext(), R.color.white))
|
||||
mListRv.setPadding(DisplayUtils.dip2px(20f), 0, DisplayUtils.dip2px(20f), 0)
|
||||
mListRv.setPadding(8F.dip2px(), 0, 8F.dip2px(), 0)
|
||||
filter.setPadding(8F.dip2px(), 0, 8F.dip2px(), 0)
|
||||
}
|
||||
|
||||
override fun getItemDecoration(): RecyclerView.ItemDecoration? {
|
||||
return GridSpacingItemDecoration(2, 1.5F.dip2px(), false)
|
||||
return GridSpacingItemDecoration(2, 8F.dip2px(), false)
|
||||
}
|
||||
|
||||
override fun provideListViewModel(): UserVideoHistoryViewModel {
|
||||
|
||||
@ -9,7 +9,7 @@ interface VideoHistoryDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun addVideo(video: MyVideoEntity)
|
||||
|
||||
@Query("select * from MyVideoEntity order by time desc limit :pageSize offset :offset ")
|
||||
@Query("select * from MyVideoEntity where user!='' order by time desc limit :pageSize offset :offset ")
|
||||
fun getVideoWithOffset(pageSize: Int, offset: Int): Single<MutableList<MyVideoEntity>>
|
||||
|
||||
@Query("select * from MyVideoEntity where videoStreamRecord=1 order by time desc limit :pageSize offset :offset ")
|
||||
|
||||
@ -22,7 +22,7 @@ class GameVideoAdapter(context: Context,
|
||||
private val mViewModel: NormalListViewModel<MyVideoEntity>,
|
||||
private val mEntrance: String,
|
||||
private val mSortValue: String?,
|
||||
val gameId:String) : ListAdapter<MyVideoEntity>(context) {
|
||||
val gameId: String) : ListAdapter<MyVideoEntity>(context) {
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
if (position == itemCount - 1) return ItemViewType.ITEM_FOOTER
|
||||
@ -51,8 +51,7 @@ class GameVideoAdapter(context: Context,
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
if (holder is VideoItemViewHolder) {
|
||||
val entity = mEntityList[position]
|
||||
ImageUtils.display(holder.binding.videoCover, entity.poster)
|
||||
holder.binding.videoLikeCount.text = entity.vote.toSimpleCount()
|
||||
holder.binding.video = entity
|
||||
holder.itemView.setOnClickListener {
|
||||
var fromLocation = ""
|
||||
var path = ""
|
||||
@ -65,6 +64,11 @@ class GameVideoAdapter(context: Context,
|
||||
path = "视频合集-最新"
|
||||
}
|
||||
DirectUtils.directToVideoDetail(mContext, entity.id, fromLocation, false, gameId = gameId, entrance = mEntrance, path = path)
|
||||
|
||||
holder.binding.userIcon.setOnClickListener {
|
||||
DirectUtils.directToHomeActivity(mContext, entity.user.id, mEntrance, path)
|
||||
}
|
||||
holder.binding.userName.setOnClickListener { holder.binding.userIcon.performClick() }
|
||||
}
|
||||
} else if (holder is FooterViewHolder) {
|
||||
holder.initFooterViewHolder(mViewModel, mIsLoading, mIsNetworkError, mIsOver)
|
||||
|
||||
@ -25,17 +25,18 @@ class GameVideoFragment : ListFragment<MyVideoEntity, NormalListViewModel<MyVide
|
||||
mListViewModel,
|
||||
mEntrance,
|
||||
arguments?.getString(EntranceUtils.KEY_SORT),
|
||||
arguments?.getString(EntranceUtils.KEY_GAMEID)?:"")
|
||||
arguments?.getString(EntranceUtils.KEY_GAMEID) ?: "")
|
||||
}
|
||||
return mAdapter!!
|
||||
}
|
||||
|
||||
override fun getItemDecoration(): RecyclerView.ItemDecoration {
|
||||
return GridSpacingItemDecoration(2, 1.5F.dip2px(), false, 8F.dip2px())
|
||||
return GridSpacingItemDecoration(2, 8F.dip2px(), false, 8F.dip2px())
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mListRv.setPadding(8F.dip2px(), 0, 8F.dip2px(), 0)
|
||||
val gridLayoutManager = GridLayoutManager(requireContext(), 2)
|
||||
gridLayoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||
override fun getSpanSize(position: Int): Int {
|
||||
|
||||
Reference in New Issue
Block a user