游戏房创建引导
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package com.yizhuan.erban.avroom.adapter
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.common.glide.GlideUtils
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.xchat_android_core.room.game.GameInfo
|
||||
|
||||
class CreateRoomGameGuideAdapter :
|
||||
BaseQuickAdapter<GameInfo, BaseViewHolder>(R.layout.item_room_create_game_guide) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: GameInfo) {
|
||||
GlideUtils.instance().load(item.pic,R.drawable.default_cover,helper.getView(R.id.iv_cover))
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package com.yizhuan.erban.avroom.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.adapter.CreateRoomGameAdapter
|
||||
import com.yizhuan.erban.avroom.adapter.CreateRoomGameGuideAdapter
|
||||
import com.yizhuan.erban.base.BaseActivity
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.DialogCreateGameRoomBinding
|
||||
import com.yizhuan.erban.databinding.DialogCreateRoomBinding
|
||||
import com.yizhuan.erban.home.helper.OpenRoomHelper
|
||||
import com.yizhuan.erban.ui.utils.RVDelegate
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo
|
||||
import com.yizhuan.xchat_android_core.room.game.GameInfo
|
||||
import com.yizhuan.xchat_android_core.room.game.GameModel
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
|
||||
class CreateGameRoomDialog : BaseDialog<DialogCreateGameRoomBinding>() {
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<GameInfo>
|
||||
private val gameAdapter = CreateRoomGameGuideAdapter()
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var gravity = Gravity.BOTTOM
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
|
||||
binding.rvGame.itemAnimator = null
|
||||
rvDelegate = RVDelegate.Builder<GameInfo>()
|
||||
.setAdapter(gameAdapter)
|
||||
.setRecyclerView(binding.rvGame)
|
||||
.setLayoutManager(GridLayoutManager(context, 2))
|
||||
.build()
|
||||
|
||||
gameAdapter.setOnItemClickListener { _, _, position ->
|
||||
dismissAllowingStateLoss()
|
||||
OpenRoomHelper.openRoom(
|
||||
requireActivity() as BaseActivity, RoomInfo.ROOMTYPE_GAME,
|
||||
gameAdapter.data[position].mgId.toLong()
|
||||
)
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
GameModel.getGameList()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(
|
||||
{
|
||||
rvDelegate.setNewData(it)
|
||||
}, {
|
||||
rvDelegate.loadErr(true)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
@@ -16,6 +16,7 @@ import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent;
|
||||
import com.yizhuan.xchat_android_core.home.model.GameHomeModel;
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager;
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol;
|
||||
import com.yizhuan.xchat_android_core.utils.Logger;
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
|
@@ -2,25 +2,24 @@ package com.yizhuan.erban.home.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
import com.yizhuan.erban.avroom.dialog.CreateGameRoomDialog
|
||||
import com.yizhuan.erban.base.BaseActivity
|
||||
import com.yizhuan.erban.base.BaseFragment
|
||||
import com.yizhuan.erban.base.BaseViewBindingFragment
|
||||
import com.yizhuan.erban.databinding.FragmentRecommendBinding
|
||||
import com.yizhuan.erban.home.HomeViewModel
|
||||
import com.yizhuan.erban.home.adapter.HomeChatAdapter
|
||||
import com.yizhuan.erban.home.adapter.HomeHotAdapter
|
||||
import com.yizhuan.erban.home.dialog.RecommendRoomDialog
|
||||
import com.yizhuan.erban.home.helper.BannerHelper
|
||||
import com.yizhuan.erban.home.helper.OpenRoomHelper
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
|
||||
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
@@ -29,17 +28,12 @@ import org.greenrobot.eventbus.ThreadMode
|
||||
/**
|
||||
* Peko首页
|
||||
*/
|
||||
class RecommendFragment : BaseFragment() {
|
||||
private lateinit var mBinding: FragmentRecommendBinding
|
||||
class RecommendFragment : BaseViewBindingFragment<FragmentRecommendBinding>() {
|
||||
private lateinit var charAdapter: HomeChatAdapter
|
||||
private lateinit var roomHotAdapter: HomeHotAdapter
|
||||
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
//仅埋点使用,不影响业务逻辑
|
||||
private val abcArray = arrayOf("A", "B", "C")
|
||||
private var currMatchClick = abcArray[0]
|
||||
|
||||
companion object {
|
||||
fun newInstance(): RecommendFragment {
|
||||
val args = Bundle()
|
||||
@@ -49,20 +43,7 @@ class RecommendFragment : BaseFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun getRootLayoutId(): Int {
|
||||
return R.layout.fragment_recommend
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
mBinding = DataBindingUtil.bind(mView)!!
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData()
|
||||
}
|
||||
|
||||
override fun initiate() {
|
||||
override fun init() {
|
||||
initRefreshView()
|
||||
initChatTab()
|
||||
initHotRoomTab()
|
||||
@@ -73,7 +54,7 @@ class RecommendFragment : BaseFragment() {
|
||||
.commitAllowingStateLoss()
|
||||
|
||||
homeViewModel.bannerLiveData.observe(this) {
|
||||
BannerHelper.setBanner(mBinding.rollView, it) { _, _ ->
|
||||
BannerHelper.setBanner(binding.rollView, it) { _, _ ->
|
||||
StatisticManager.Instance()
|
||||
.onEvent(
|
||||
StatisticsProtocol.EVENT_HOME_BANNER_CLICK,
|
||||
@@ -82,31 +63,24 @@ class RecommendFragment : BaseFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
homeViewModel.resourceJumpLiveData.observe(this) {
|
||||
dialogManager.dismissDialog()
|
||||
it?.let {
|
||||
if (it.isPick) {
|
||||
AVRoomActivity.start(context, it.uid)
|
||||
StatisticManager.Instance().onEvent(
|
||||
"${currMatchClick}_match_success",
|
||||
ResUtil.getString(R.string.home_fragment_recommendfragment_03),
|
||||
mapOf("user_id" to AuthModel.get().currentUid.toString())
|
||||
)
|
||||
} else {
|
||||
RecommendRoomDialog.newInstance(it).show(context)
|
||||
}
|
||||
}
|
||||
val userInfo = UserModel.get().cacheLoginUserInfo
|
||||
if ((userInfo?.hallId ?: 0L) > 0L) {
|
||||
binding.ivGameGuide.visibility = View.GONE
|
||||
} else {
|
||||
binding.ivGameGuide.visibility = View.VISIBLE
|
||||
}
|
||||
binding.ivGameGuide.setOnClickListener {
|
||||
CreateGameRoomDialog().show(context)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initRefreshView() {
|
||||
mBinding.refreshLayout.setOnRefreshListener {
|
||||
mBinding.refreshLayout.finishRefresh()
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
binding.refreshLayout.finishRefresh()
|
||||
EventBus.getDefault().post(RefreshHomeDataEvent())
|
||||
}
|
||||
mBinding.refreshLayout.isEnableLoadmore = false
|
||||
mBinding.refreshLayout.isEnableOverScrollBounce = false
|
||||
binding.refreshLayout.isEnableLoadmore = false
|
||||
binding.refreshLayout.isEnableOverScrollBounce = false
|
||||
}
|
||||
|
||||
private fun initChatTab() {
|
||||
@@ -126,19 +100,19 @@ class RecommendFragment : BaseFragment() {
|
||||
)
|
||||
}
|
||||
}
|
||||
mBinding.mRecyclerChat.adapter = charAdapter
|
||||
mBinding.mLiCreateRoom.setOnClickListener {
|
||||
binding.mRecyclerChat.adapter = charAdapter
|
||||
binding.mLiCreateRoom.setOnClickListener {
|
||||
OpenRoomHelper.openRoom(context as BaseActivity?)
|
||||
}
|
||||
homeViewModel.homePlayInfoData.observe(this) {
|
||||
it?.let {
|
||||
if (it.isNotEmpty()) {
|
||||
mBinding.mLiCreateRoom.visibility = View.GONE
|
||||
mBinding.mRecyclerChat.visibility = View.VISIBLE
|
||||
binding.mLiCreateRoom.visibility = View.GONE
|
||||
binding.mRecyclerChat.visibility = View.VISIBLE
|
||||
charAdapter.setNewData(it)
|
||||
} else {
|
||||
mBinding.mLiCreateRoom.visibility = View.VISIBLE
|
||||
mBinding.mRecyclerChat.visibility = View.GONE
|
||||
binding.mLiCreateRoom.visibility = View.VISIBLE
|
||||
binding.mRecyclerChat.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,7 +132,7 @@ class RecommendFragment : BaseFragment() {
|
||||
)
|
||||
}
|
||||
}
|
||||
mBinding.mRecyclerRoom.adapter = roomHotAdapter
|
||||
binding.mRecyclerRoom.adapter = roomHotAdapter
|
||||
homeViewModel.homeHotRoomLiveData.observe(this) {
|
||||
it?.let {
|
||||
roomHotAdapter.setNewData(it)
|
||||
@@ -166,6 +140,17 @@ class RecommendFragment : BaseFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData()
|
||||
}
|
||||
|
||||
private fun loadData() {
|
||||
homeViewModel.getBannerInfo()
|
||||
homeViewModel.getHomePlayV2()
|
||||
homeViewModel.getHotRoom()
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) {
|
||||
@@ -173,15 +158,6 @@ class RecommendFragment : BaseFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData() {
|
||||
homeViewModel.getBannerInfo()
|
||||
homeViewModel.getHomeResource()
|
||||
homeViewModel.getHomeSingleAnchorList()
|
||||
homeViewModel.getHomePlayV2()
|
||||
homeViewModel.getHotRoom()
|
||||
}
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
@@ -192,5 +168,4 @@ class RecommendFragment : BaseFragment() {
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
|
||||
}
|
BIN
app/src/main/res/drawable-xhdpi/ic_game_room_create_close.webp
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_game_room_create_close.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable/ic_game_guide.webp
Normal file
BIN
app/src/main/res/drawable/ic_game_guide.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
10
app/src/main/res/drawable/shape_white_bottom_25dp.xml
Normal file
10
app/src/main/res/drawable/shape_white_bottom_25dp.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/white" />
|
||||
|
||||
<corners
|
||||
android:topLeftRadius="@dimen/dp_25"
|
||||
android:topRightRadius="@dimen/dp_25" />
|
||||
</shape>
|
48
app/src/main/res/layout/dialog_create_game_room.xml
Normal file
48
app/src/main/res/layout/dialog_create_game_room.xml
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/shape_white_bottom_25dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:src="@drawable/ic_game_room_create_close"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_play_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:text="@string/select_game"
|
||||
android:textColor="@color/color_1F1A4E"
|
||||
android:textSize="@dimen/sp_16"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginTop="@dimen/dp_14"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_game"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:minHeight="250dp"
|
||||
android:clipToPadding="true"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
app:layout_constraintTop_toBottomOf="@+id/iv_close"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
@@ -60,46 +60,64 @@
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/mLiCreateRoom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:background="@drawable/bg_home_chat"
|
||||
android:gravity="center_vertical"
|
||||
android:id="@+id/llListChat"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone">
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:layout_marginEnd="@dimen/dp_10"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/mLiCreateRoom"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:background="@drawable/bg_home_chat"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="@dimen/dp_12"
|
||||
android:src="@drawable/ic_home_chat_add" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:text="@string/create_home_play"
|
||||
android:textColor="@color/color_1F1A4E"
|
||||
android:textSize="@dimen/sp_15" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/mRecyclerChat"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:overScrollMode="never"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="@dimen/dp_10"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="@dimen/dp_12"
|
||||
android:src="@drawable/ic_home_chat_add" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:text="@string/create_home_play"
|
||||
android:textColor="@color/color_1F1A4E"
|
||||
android:textSize="@dimen/sp_15" />
|
||||
android:id="@+id/ivGameGuide"
|
||||
android:src="@drawable/ic_game_guide"
|
||||
android:visibility="gone"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="75dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/mRecyclerChat"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:orientation="horizontal"
|
||||
android:overScrollMode="never"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="@dimen/dp_15"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
15
app/src/main/res/layout/item_room_create_game_guide.xml
Normal file
15
app/src/main/res/layout/item_room_create_game_guide.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_15"
|
||||
android:layout_marginStart="@dimen/dp_15">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_cover"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/default_cover" />
|
||||
|
||||
</FrameLayout>
|
@@ -4975,5 +4975,6 @@
|
||||
<string name="no_withdrawal_account_is_attached">未綁定提現賬戶</string>
|
||||
<string name="number_of_withdrawals_in_remaining_weeks">剩餘周提現次數:%d次</string>
|
||||
<string name="immediate_cash_withdrawal">立即提現</string>
|
||||
<string name="select_game">選擇游戲</string>
|
||||
|
||||
</resources>
|
Reference in New Issue
Block a user