新增直播Tab顶部历史记录列表
This commit is contained in:
@@ -9,6 +9,7 @@ import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTagInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.ResourceInfo
|
||||
import com.yizhuan.xchat_android_core.home.model.HomeModel
|
||||
import com.yizhuan.xchat_android_core.room.bean.HomeLiveTopInfo
|
||||
import com.yizhuan.xchat_android_core.room.bean.SingleRoomSortInfo
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -54,6 +55,9 @@ class HomeViewModel : BaseViewModel() {
|
||||
val singleRoomSortInfoLiveData: LiveData<ListResult<SingleRoomSortInfo>> =
|
||||
_singleRoomSortInfoLiveData
|
||||
|
||||
private val _homeLiveTopInfoLiveData = MutableLiveData<HomeLiveTopInfo>()
|
||||
val homeLiveTopInfoLiveData: LiveData<HomeLiveTopInfo> = _homeLiveTopInfoLiveData
|
||||
|
||||
fun getBannerInfo() {
|
||||
safeLaunch {
|
||||
_bannerLiveData.value = HomeModel.getHomeBanner("9")
|
||||
@@ -187,4 +191,16 @@ class HomeViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
fun requestHomeLiveTopInfo() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_homeLiveTopInfoLiveData.value = null
|
||||
},
|
||||
block = {
|
||||
_homeLiveTopInfoLiveData.value = HomeModel.requestHomeLiveTopInfo()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.yizhuan.erban.home.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
import com.yizhuan.erban.ui.utils.load
|
||||
import com.yizhuan.xchat_android_core.room.bean.HomeLiveTopInfo
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol
|
||||
|
||||
|
||||
class HomeLiveTopAdapter :
|
||||
BaseQuickAdapter<HomeLiveTopInfo.SingleRoom, BaseViewHolder>(R.layout.item_home_live_top) {
|
||||
|
||||
private var onceLookStatus: Boolean = false
|
||||
|
||||
fun setOnceLookStatus(onceLookStatus: Boolean) {
|
||||
this.onceLookStatus = onceLookStatus
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: HomeLiveTopInfo.SingleRoom) {
|
||||
helper.apply {
|
||||
getView<ImageView>(R.id.iv_room_image).load(item.avatar)
|
||||
setText(R.id.tv_room_title, item.title)
|
||||
setGone(R.id.iv_room_tag, item.isRecommend && onceLookStatus)
|
||||
}
|
||||
|
||||
helper.itemView.setOnClickListener {
|
||||
AVRoomActivity.start(mContext, item.uid)
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_SCFJ_ROOM_SUCCESS, "成功进入收藏的房间")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -21,15 +21,13 @@ import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.indic
|
||||
import java.util.List;
|
||||
|
||||
public class PartyMagicIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
private final Context mContext;
|
||||
private final List<? extends CharSequence> mTitleList;
|
||||
|
||||
private int textSize = 14;
|
||||
private float minScale = 1f;
|
||||
private OnItemSelectListener mOnItemSelectListener;
|
||||
|
||||
public PartyMagicIndicatorAdapter(Context context, List<? extends CharSequence> charSequences) {
|
||||
this.mContext = context;
|
||||
public PartyMagicIndicatorAdapter(List<? extends CharSequence> charSequences) {
|
||||
this.mTitleList = charSequences;
|
||||
}
|
||||
|
||||
@@ -59,9 +57,7 @@ public class PartyMagicIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
WrapPagerIndicator indicator = new WrapPagerIndicator(context);
|
||||
indicator.setFillColor(Color.parseColor("#FFFFCB47"));
|
||||
return indicator;
|
||||
return new WrapPagerIndicator(context);
|
||||
}
|
||||
|
||||
public int getTextSize() {
|
||||
|
@@ -10,6 +10,7 @@ import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.coorchice.library.utils.LogUtils
|
||||
import com.scwang.smartrefresh.layout.internal.ProgressDrawable
|
||||
import com.yizhuan.erban.R
|
||||
@@ -17,25 +18,28 @@ import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
import com.yizhuan.erban.avroom.adapter.RoomVPAdapter
|
||||
import com.yizhuan.erban.base.BaseFragment
|
||||
import com.yizhuan.erban.base.BaseViewBindingFragment
|
||||
import com.yizhuan.erban.common.EmptyViewHelper
|
||||
import com.yizhuan.erban.databinding.FragmentLiveBinding
|
||||
import com.yizhuan.erban.databinding.FragmentRecommendBinding
|
||||
import com.yizhuan.erban.home.HomeViewModel
|
||||
import com.yizhuan.erban.home.adapter.HomeSingleAnchorAdapter
|
||||
import com.yizhuan.erban.home.adapter.MainMagicIndicatorAdapter
|
||||
import com.yizhuan.erban.home.adapter.PartyMagicIndicatorAdapter
|
||||
import com.yizhuan.erban.home.adapter.*
|
||||
import com.yizhuan.erban.home.dialog.RecommendRoomDialog
|
||||
import com.yizhuan.erban.home.helper.BannerHelper
|
||||
import com.yizhuan.erban.ui.utils.RVDelegate
|
||||
import com.yizhuan.erban.ui.utils.load
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTagInfo
|
||||
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel
|
||||
import com.yizhuan.xchat_android_core.room.bean.HomeLiveTopInfo
|
||||
import com.yizhuan.xchat_android_core.room.bean.SingleRoomSortInfo
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol
|
||||
import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
@@ -50,7 +54,10 @@ class LiveFragment : BaseViewBindingFragment<FragmentLiveBinding>(),
|
||||
private val mFragments: ArrayList<Fragment> = ArrayList()
|
||||
private val mTabInfoList: ArrayList<CharSequence> = ArrayList()
|
||||
private var currentIndex = 0
|
||||
private var lastLoadDataTime = 0L
|
||||
|
||||
private lateinit var mAdapter: HomeLiveTopAdapter
|
||||
private lateinit var rvDelegate: RVDelegate<HomeLiveTopInfo.SingleRoom>
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
companion object {
|
||||
@@ -62,8 +69,13 @@ class LiveFragment : BaseViewBindingFragment<FragmentLiveBinding>(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun init() {
|
||||
mAdapter = HomeLiveTopAdapter()
|
||||
rvDelegate = RVDelegate.Builder<HomeLiveTopInfo.SingleRoom>()
|
||||
.setAdapter(mAdapter)
|
||||
.setLayoutManager(LinearLayoutManager(mContext, RecyclerView.HORIZONTAL, false))
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.build()
|
||||
initRefreshView()
|
||||
homeViewModel.singleRoomSortInfoLiveData.observe(
|
||||
viewLifecycleOwner
|
||||
@@ -72,6 +84,14 @@ class LiveFragment : BaseViewBindingFragment<FragmentLiveBinding>(),
|
||||
it.data?.let { date -> onGetSingleRoomSortInfoSuccess(date) }
|
||||
}
|
||||
}
|
||||
|
||||
homeViewModel.homeLiveTopInfoLiveData.observe(viewLifecycleOwner) {
|
||||
it?.let {
|
||||
mAdapter.setOnceLookStatus(it.onceLookStatus)
|
||||
rvDelegate.loadData(it.singleRoomList, true)
|
||||
binding.tvTitle.text = if (it.onceLookStatus) "曾经看过的人" else "Top热播"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@@ -79,7 +99,6 @@ class LiveFragment : BaseViewBindingFragment<FragmentLiveBinding>(),
|
||||
loadData()
|
||||
}
|
||||
|
||||
|
||||
private fun onGetSingleRoomSortInfoSuccess(info: List<SingleRoomSortInfo>) {
|
||||
var changed = false
|
||||
val oldTabInfoList: List<CharSequence> = ArrayList<CharSequence>(mTabInfoList)
|
||||
@@ -93,15 +112,15 @@ class LiveFragment : BaseViewBindingFragment<FragmentLiveBinding>(),
|
||||
if (changed) {
|
||||
mTabInfoList.clear()
|
||||
mFragments.clear()
|
||||
for (i in info.indices) {
|
||||
mTabInfoList.add(info[i].sortName)
|
||||
val fragment = RoomSingleFragment.newInstance(info[i].id)
|
||||
for (tagInfo in info) {
|
||||
mTabInfoList.add(tagInfo.sortName)
|
||||
val fragment = RoomSingleFragment.newInstance(tagInfo.id)
|
||||
mFragments.add(fragment)
|
||||
}
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(true)
|
||||
commonNavigator.titleMargin = 8
|
||||
val magicIndicatorAdapter = PartyMagicIndicatorAdapter(context, mTabInfoList)
|
||||
val magicIndicatorAdapter = PartyMagicIndicatorAdapter(mTabInfoList)
|
||||
magicIndicatorAdapter.textSize = 12
|
||||
magicIndicatorAdapter.setOnItemSelectListener(this)
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
@@ -145,7 +164,10 @@ class LiveFragment : BaseViewBindingFragment<FragmentLiveBinding>(),
|
||||
}
|
||||
|
||||
private fun loadData() {
|
||||
if (CurrentTimeUtils.getCurrentTime() - lastLoadDataTime < 15 * 1000) return
|
||||
lastLoadDataTime = CurrentTimeUtils.getCurrentTime()
|
||||
homeViewModel.requestSingleRoomSortList()
|
||||
homeViewModel.requestHomeLiveTopInfo()
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@@ -111,7 +111,7 @@ class PartyFragment : BaseFragment(), PartyMagicIndicatorAdapter.OnItemSelectLis
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(true)
|
||||
commonNavigator.titleMargin = 8
|
||||
val magicIndicatorAdapter = PartyMagicIndicatorAdapter(context, mTabInfoList)
|
||||
val magicIndicatorAdapter = PartyMagicIndicatorAdapter(mTabInfoList)
|
||||
magicIndicatorAdapter.textSize = 14
|
||||
magicIndicatorAdapter.setOnItemSelectListener(this)
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
|
BIN
app/src/main/res/drawable-xhdpi/home_live_bg_recommend.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/home_live_bg_recommend.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xhdpi/home_live_bg_top_history.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/home_live_bg_top_history.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
app/src/main/res/drawable-xhdpi/home_live_ic_top_like.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/home_live_ic_top_like.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@@ -30,33 +30,58 @@
|
||||
app:contentScrim="@color/transparent"
|
||||
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="15dp"
|
||||
android:paddingBottom="15dp">
|
||||
|
||||
<View
|
||||
android:id="@+id/view_bg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="@drawable/home_live_bg_top_history"
|
||||
app:layout_constraintDimensionRatio="690:254"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="14dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:drawableStart="@drawable/home_live_ic_top_like"
|
||||
android:drawablePadding="4dp"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:text="曾经看过的人"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="14sp" />
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintStart_toStartOf="@id/view_bg"
|
||||
app:layout_constraintTop_toTopOf="@id/view_bg" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_single_anchor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:clipToPadding="false"
|
||||
android:overScrollMode="never"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingTop="@dimen/dp_10"
|
||||
android:paddingEnd="5dp"
|
||||
android:paddingBottom="@dimen/dp_10"
|
||||
android:paddingStart="7dp"
|
||||
android:paddingEnd="7dp"
|
||||
android:scrollbars="none"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
app:layout_constraintBottom_toBottomOf="@id/view_bg"
|
||||
app:layout_constraintEnd_toEndOf="@id/view_bg"
|
||||
app:layout_constraintStart_toStartOf="@id/view_bg"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_title" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
@@ -77,7 +102,6 @@
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="match_parent"
|
||||
|
50
app/src/main/res/layout/item_home_live_top.xml
Normal file
50
app/src/main/res/layout/item_home_live_top.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp">
|
||||
|
||||
<com.makeramen.roundedimageview.RoundedImageView
|
||||
android:id="@+id/iv_room_image"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="1dp"
|
||||
android:src="@drawable/default_cover"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:riv_corner_radius="8dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/iv_room_tag"
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="13dp"
|
||||
android:background="@drawable/home_live_bg_recommend"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="推荐"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="8sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_room_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="10sp"
|
||||
app:layout_constraintEnd_toEndOf="@id/iv_room_image"
|
||||
app:layout_constraintStart_toStartOf="@id/iv_room_image"
|
||||
app:layout_constraintTop_toBottomOf="@id/iv_room_image"
|
||||
tools:text="余生点唱歌曲交友房间" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@@ -6,6 +6,7 @@ import com.yizhuan.xchat_android_core.bean.response.ServiceResult
|
||||
import com.yizhuan.xchat_android_core.community.CommunityConstant
|
||||
import com.yizhuan.xchat_android_core.community.bean.UnReadCountInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.*
|
||||
import com.yizhuan.xchat_android_core.room.bean.HomeLiveTopInfo
|
||||
import com.yizhuan.xchat_android_core.room.bean.SingleRoomSortInfo
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper
|
||||
@@ -156,6 +157,12 @@ object HomeModel : BaseModel() {
|
||||
api.requestSingleRoomSortList()
|
||||
}
|
||||
|
||||
suspend fun requestHomeLiveTopInfo(): HomeLiveTopInfo? =
|
||||
launchRequest {
|
||||
api.requestHomeLiveTopInfo()
|
||||
}
|
||||
|
||||
|
||||
private interface Api {
|
||||
/**
|
||||
* 提交反馈
|
||||
@@ -326,6 +333,12 @@ object HomeModel : BaseModel() {
|
||||
@GET("single/broadcast/sort")
|
||||
suspend fun requestSingleRoomSortList(): ServiceResult<List<SingleRoomSortInfo>>
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@GET("single/broadcast/onceLook")
|
||||
suspend fun requestHomeLiveTopInfo(): ServiceResult<HomeLiveTopInfo>
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.yizhuan.xchat_android_core.room.bean
|
||||
|
||||
data class HomeLiveTopInfo(
|
||||
val onceLookStatus: Boolean = false,
|
||||
val singleRoomList: List<SingleRoom> = listOf()
|
||||
) {
|
||||
data class SingleRoom(
|
||||
val avatar: String = "",
|
||||
val isRecommend: Boolean = false,
|
||||
val title: String = "",
|
||||
val uid: Long = 0
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user