feat:首页开放榜单入口、banner、房间标签展示 改为读取接口
This commit is contained in:
@@ -17,8 +17,8 @@ class HomeViewModel : BaseViewModel() {
|
||||
// private val _tabHomeLiveData = MutableLiveData<List<HomeTabMapInfo>?>()
|
||||
// val tabHomeLiveData: MutableLiveData<List<HomeTabMapInfo>?> = _tabHomeLiveData
|
||||
//
|
||||
// private val _bannerLiveData = MutableLiveData<List<BannerInfo>?>()
|
||||
// val bannerLiveData: MutableLiveData<List<BannerInfo>?> = _bannerLiveData
|
||||
private val _bannerLiveData = MutableLiveData<List<BannerInfo>?>()
|
||||
val bannerLiveData: MutableLiveData<List<BannerInfo>?> = _bannerLiveData
|
||||
//
|
||||
// private val _currentResourceLiveData = MutableLiveData<List<CurrentResourceInfo>?>()
|
||||
// val currentResourceLiveData: MutableLiveData<List<CurrentResourceInfo>?> = _currentResourceLiveData
|
||||
@@ -111,16 +111,16 @@ class HomeViewModel : BaseViewModel() {
|
||||
// )
|
||||
// }
|
||||
|
||||
// fun getBannerInfo() {
|
||||
// safeLaunch(
|
||||
// onError = {
|
||||
// _bannerLiveData.value = null
|
||||
// },
|
||||
// block = {
|
||||
// _bannerLiveData.value = HomeModel.getHomeBanner("1")
|
||||
// }
|
||||
// )
|
||||
// }
|
||||
fun getBannerInfo() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_bannerLiveData.value = null
|
||||
},
|
||||
block = {
|
||||
_bannerLiveData.value = HomeModel.getHomeBanner("1")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getTagInfo() {
|
||||
safeLaunch {
|
||||
|
@@ -5,6 +5,7 @@ import androidx.core.view.isGone
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.home.bean.HomeRoomInfo
|
||||
|
||||
@@ -21,6 +22,13 @@ class HomeHotAdapter :
|
||||
setText(R.id.tv_room_title, item.title)
|
||||
}
|
||||
|
||||
if (item.tagPict.isNullOrEmpty()) {
|
||||
helper.setGone(R.id.iv_room_tag, false)
|
||||
} else {
|
||||
helper.setGone(R.id.iv_room_tag, true)
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_room_tag), item.tagPict)
|
||||
}
|
||||
|
||||
val avatars: Array<ImageView> = arrayOf(
|
||||
helper.getView(R.id.iv_avatar_0),
|
||||
helper.getView(R.id.iv_avatar_1),
|
||||
|
@@ -1,59 +1,67 @@
|
||||
package com.chwl.app.home.fragment
|
||||
|
||||
import android.view.View
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.application.IReportConstants
|
||||
import com.chwl.app.application.ReportManager
|
||||
import com.chwl.app.base.BaseViewBindingFragment
|
||||
import com.chwl.app.databinding.FragmentHomeBinding
|
||||
import com.chwl.app.home.HomeViewModel
|
||||
import com.chwl.app.home.adapter.HomeBannerAdapter
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.app.ui.search.SearchActivity
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.chwl.app.utils.CommonJumpHelper
|
||||
import com.chwl.core.DemoCache
|
||||
import com.chwl.core.UriProvider
|
||||
import com.chwl.core.home.bean.BannerInfo
|
||||
import com.chwl.library.utils.ListUtils
|
||||
import com.zhpan.bannerview.BannerViewPager
|
||||
|
||||
/**
|
||||
首页
|
||||
*/
|
||||
class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClickListener {
|
||||
|
||||
// private val mFragments = mutableListOf<Class<out Fragment>>()
|
||||
// private val mTabInfoList = mutableListOf<HomeTagInfo>()
|
||||
// private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
// private var mBanner: BannerViewPager<BannerInfo>? = null
|
||||
private var mBanner: BannerViewPager<BannerInfo>? = null
|
||||
|
||||
override fun init() {
|
||||
// mBanner = view?.findViewById(R.id.banner)
|
||||
mBanner = view?.findViewById(R.id.banner)
|
||||
// initTitleTab()
|
||||
initListener()
|
||||
childFragmentManager.beginTransaction()
|
||||
.replace(R.id.frameLayout, RecommendFragment(), "RECOMMEND").commitAllowingStateLoss()
|
||||
// homeViewModel.bannerLiveData.observe(this) {
|
||||
// it?.let {
|
||||
// if (ListUtils.isListEmpty(it)) {
|
||||
// mBanner?.visibility = View.GONE
|
||||
// return@let
|
||||
// }
|
||||
// mBanner?.visibility = View.VISIBLE
|
||||
// mBanner?.adapter = HomeBannerAdapter()
|
||||
// mBanner?.post {
|
||||
// mBanner?.apply {
|
||||
// this.setPageMargin(UIUtil.dip2px(mContext, 8.0))
|
||||
// .setScrollDuration(800)
|
||||
// .setOnPageClickListener { _: View?, position: Int ->
|
||||
// //首页_banner
|
||||
// ReportManager.get().reportEvent(
|
||||
// IReportConstants.MODULE_HOMEPAGE_CLICK, mapOf(
|
||||
// Pair(IReportConstants.HOMEPAGE_TYPE, IReportConstants.SIX),
|
||||
// Pair(IReportConstants.MODULE, IReportConstants.PEKO_HOMEPAGE)
|
||||
// )
|
||||
// )
|
||||
// CommonJumpHelper.bannerJump(context, it[position])
|
||||
// }
|
||||
// .create(it)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
homeViewModel.bannerLiveData.observe(this) {
|
||||
it?.let {
|
||||
if (ListUtils.isListEmpty(it)) {
|
||||
mBanner?.visibility = View.GONE
|
||||
return@let
|
||||
}
|
||||
mBanner?.visibility = View.VISIBLE
|
||||
mBanner?.adapter = HomeBannerAdapter()
|
||||
mBanner?.post {
|
||||
mBanner?.apply {
|
||||
this.setPageMargin(UIUtil.dip2px(mContext, 8.0))
|
||||
.setScrollDuration(800)
|
||||
.setOnPageClickListener { _: View?, position: Int ->
|
||||
//首页_banner
|
||||
ReportManager.get().reportEvent(
|
||||
IReportConstants.MODULE_HOMEPAGE_CLICK, mapOf(
|
||||
Pair(IReportConstants.HOMEPAGE_TYPE, IReportConstants.SIX),
|
||||
Pair(IReportConstants.MODULE, IReportConstants.PEKO_HOMEPAGE)
|
||||
)
|
||||
)
|
||||
CommonJumpHelper.bannerJump(context, it[position])
|
||||
}
|
||||
.create(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// homeViewModel.currentResourceLiveData.observe(this) {
|
||||
// it?.let {
|
||||
// if(it.size != 2){
|
||||
@@ -104,13 +112,13 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// homeViewModel.getBannerInfo()
|
||||
homeViewModel.getBannerInfo()
|
||||
// homeViewModel.getCurrentResourceInfo()
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
binding.ivSearch.setOnClickListener(this)
|
||||
// binding.ivRanking.setOnClickListener(this)
|
||||
binding.ivRanking.setOnClickListener(this)
|
||||
binding.ivMyRoom.setOnClickListener(this)
|
||||
}
|
||||
|
||||
@@ -130,16 +138,16 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
DemoCache.saveAnchorCardView(1)
|
||||
}
|
||||
}
|
||||
// R.id.iv_ranking -> {
|
||||
// //首页_排行榜
|
||||
// ReportManager.get().reportEvent(
|
||||
// IReportConstants.MODULE_HOMEPAGE_CLICK, mapOf(
|
||||
// Pair(IReportConstants.HOMEPAGE_TYPE, IReportConstants.THREE),
|
||||
// Pair(IReportConstants.MODULE, IReportConstants.PEKO_HOMEPAGE)
|
||||
// )
|
||||
// )
|
||||
// CommonWebViewActivity.start(mContext, UriProvider.getRanking())
|
||||
// }
|
||||
R.id.iv_ranking -> {
|
||||
//首页_排行榜
|
||||
ReportManager.get().reportEvent(
|
||||
IReportConstants.MODULE_HOMEPAGE_CLICK, mapOf(
|
||||
Pair(IReportConstants.HOMEPAGE_TYPE, IReportConstants.THREE),
|
||||
Pair(IReportConstants.MODULE, IReportConstants.PEKO_HOMEPAGE)
|
||||
)
|
||||
)
|
||||
CommonWebViewActivity.start(mContext, UriProvider.getRanking())
|
||||
}
|
||||
R.id.iv_my_room -> {
|
||||
//首页_创建房间
|
||||
ReportManager.get().reportEvent(
|
||||
|
@@ -3,7 +3,6 @@ package com.chwl.app.home.fragment
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
|
@@ -64,11 +64,77 @@
|
||||
app:layout_constraintStart_toStartOf="@id/tv_title"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_title" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/frameLayout"
|
||||
<ImageView
|
||||
android:id="@+id/iv_ranking"
|
||||
android:layout_width="@dimen/dp_30"
|
||||
android:layout_height="@dimen/dp_30"
|
||||
android:layout_marginStart="5dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_home_rank"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_title"
|
||||
app:layout_constraintStart_toEndOf="@id/tv_title"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_title" />
|
||||
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/coordinator_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="@dimen/dp_14"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_title" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_title">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/transparent"
|
||||
app:elevation="0dp"
|
||||
app:layout_behavior="com.chwl.app.ui.widget.AppBarLayoutBehavior">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cs_resource"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/dp_14"
|
||||
android:paddingEnd="@dimen/dp_14">
|
||||
|
||||
<com.zhpan.bannerview.BannerViewPager
|
||||
android:id="@+id/banner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_80"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:visibility="gone"
|
||||
app:bvp_auto_play="true"
|
||||
app:bvp_can_loop="true"
|
||||
app:bvp_indicator_checked_color="@color/color_9168FA"
|
||||
app:bvp_indicator_normal_color="@color/color_B3B3C3"
|
||||
app:bvp_indicator_radius="@dimen/dp_4"
|
||||
app:bvp_indicator_visibility="visible"
|
||||
app:bvp_page_style="multi_page_scale"
|
||||
app:layout_constraintDimensionRatio="345:80"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/frameLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@@ -19,12 +19,11 @@
|
||||
|
||||
<com.chwl.library.common.widget.VpRecyclerView
|
||||
android:id="@+id/mRecyclerRoom"
|
||||
android:layout_marginTop="@dimen/dp_6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none"
|
||||
app:spanCount="2"
|
||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" />
|
||||
android:scrollbars="none" />
|
||||
|
||||
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
|
||||
|
||||
|
@@ -20,30 +20,26 @@
|
||||
android:id="@+id/iv_room_image"
|
||||
android:layout_width="@dimen/dp_88"
|
||||
android:layout_height="@dimen/dp_88"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/default_cover"
|
||||
app:borderRadius="@dimen/dp_8"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@id/v_bg"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:shapeAppearance="@style/shape_home_recommend_item" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_tag"
|
||||
<ImageView
|
||||
android:id="@+id/iv_room_tag"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_marginStart="@dimen/dp_12"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:drawableEnd="@drawable/home_ic_tag"
|
||||
android:drawablePadding="@dimen/dp_2"
|
||||
android:gravity="center"
|
||||
android:text="熱門"
|
||||
android:textColor="#FFB02C"
|
||||
android:textSize="@dimen/dp_11"
|
||||
app:layout_constraintBottom_toTopOf="@id/tv_room_title"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_room_image"
|
||||
app:layout_constraintTop_toTopOf="@id/v_bg"
|
||||
app:layout_constraintVertical_chainStyle="packed" />
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:src="@drawable/tag_101" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_room_title"
|
||||
@@ -59,7 +55,7 @@
|
||||
app:layout_constraintBottom_toTopOf="@id/fl_avatar"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tv_online_number"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_room_image"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_tag"
|
||||
app:layout_constraintTop_toBottomOf="@id/iv_room_tag"
|
||||
tools:text="@string/layout_item_room_common_02" />
|
||||
|
||||
<FrameLayout
|
||||
|
@@ -3,6 +3,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:minHeight="600dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
|
Reference in New Issue
Block a user