资源位点击处理
This commit is contained in:
@@ -19,7 +19,7 @@ abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
|
||||
private var onDismissListener: (() -> Unit)? = null
|
||||
val binding get() = _binding!!
|
||||
open var width = ScreenUtil.getDialogWidth()
|
||||
var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
open var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
open var gravity = Gravity.CENTER
|
||||
|
||||
override fun onStart() {
|
||||
|
@@ -43,8 +43,8 @@ class HomeViewModel : BaseViewModel() {
|
||||
private val _resourceLiveData = MutableLiveData<List<ResourceInfo>>()
|
||||
val resourceLiveData: LiveData<List<ResourceInfo>> = _resourceLiveData
|
||||
|
||||
private val _resourceJumpLiveData = MutableLiveData<List<ResourceInfo>>()
|
||||
val resourceJumpLiveData: LiveData<List<ResourceInfo>> = _resourceJumpLiveData
|
||||
private val _resourceJumpLiveData = MutableLiveData<HomeRoomInfo>()
|
||||
val resourceJumpLiveData: LiveData<HomeRoomInfo> = _resourceJumpLiveData
|
||||
|
||||
fun getBannerInfo() {
|
||||
safeLaunch {
|
||||
|
@@ -0,0 +1,45 @@
|
||||
package com.yizhuan.erban.home.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.DialogRecommendRoomBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
|
||||
|
||||
class RecommendRoomDialog : BaseDialog<DialogRecommendRoomBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
fun newInstance(roomInfo: HomeRoomInfo): RecommendRoomDialog {
|
||||
val args = Bundle()
|
||||
args.putSerializable("roomInfo", roomInfo)
|
||||
val fragment = RecommendRoomDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private val roomInfo: HomeRoomInfo by lazy { requireArguments().getSerializable("roomInfo") as HomeRoomInfo }
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding.ivClose.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
binding.tvGo.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
AVRoomActivity.start(context, roomInfo.uid)
|
||||
|
||||
}
|
||||
binding.tvRoomTitle.text = roomInfo.title
|
||||
ImageLoadUtils.loadImage(context, roomInfo.avatar, binding.ivAvatar)
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -11,12 +11,17 @@ import androidx.fragment.app.activityViewModels
|
||||
import com.scwang.smartrefresh.layout.internal.ProgressDrawable
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.adapter.RoomVPAdapter
|
||||
import com.yizhuan.erban.base.BaseActivity
|
||||
import com.yizhuan.erban.base.BaseFragment
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager
|
||||
import com.yizhuan.erban.databinding.FragmentRecommendBinding
|
||||
import com.yizhuan.erban.home.HomeViewModel
|
||||
import com.yizhuan.erban.home.adapter.MainMagicIndicatorAdapter
|
||||
import com.yizhuan.erban.home.dialog.RecommendRoomDialog
|
||||
import com.yizhuan.erban.home.helper.BannerHelper
|
||||
import com.yizhuan.erban.home.helper.OpenRoomHelper
|
||||
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.home.event.RefreshHomeDataEvent
|
||||
@@ -88,16 +93,38 @@ class RecommendFragment : BaseFragment(),
|
||||
for (i in resourceViews.indices) {
|
||||
resourceViews[i].load(it[i].icon)
|
||||
resourceViews[i].setOnClickListener { _ ->
|
||||
if (it[i].resourceType == 5) {
|
||||
CommonWebViewActivity.start(context, it[i].resourceContent)
|
||||
} else {
|
||||
dialogManager.showProgressDialog(mContext)
|
||||
homeViewModel.getResourceJumpInfo(it[i].id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
homeViewModel.resourceJumpLiveData.observe(this) {
|
||||
dialogManager.dismissDialog()
|
||||
it?.let {
|
||||
if (it.isPick) {
|
||||
RecommendRoomDialog.newInstance(it).show(context)
|
||||
} else {
|
||||
dialogManager.showOkCancelDialog(
|
||||
it.failContext,
|
||||
"新建游戏房间",
|
||||
"交友畅聊",
|
||||
true,
|
||||
object : DialogManager.OkCancelDialogListener {
|
||||
override fun onOk() {
|
||||
OpenRoomHelper.openHomePartyRoom(requireActivity() as BaseActivity)
|
||||
}
|
||||
|
||||
override fun onCancel() {
|
||||
OpenRoomHelper.openRoom(requireActivity() as BaseActivity)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
BIN
app/src/main/res/drawable-xhdpi/bg_recommend_room_dialog.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/bg_recommend_room_dialog.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
BIN
app/src/main/res/drawable-xhdpi/ic_recommend_room_close.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_recommend_room_close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 964 B |
78
app/src/main/res/layout/dialog_recommend_room.xml
Normal file
78
app/src/main/res/layout/dialog_recommend_room.xml
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
tools:visibility="visible">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="299dp"
|
||||
android:background="@drawable/bg_recommend_room_dialog">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="暂无合适房间,为你推荐其他房间~"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.makeramen.roundedimageview.RoundedImageView
|
||||
android:id="@+id/iv_avatar"
|
||||
android:layout_width="108dp"
|
||||
android:layout_height="108dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/default_cover"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_title"
|
||||
app:riv_corner_radius="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_room_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/iv_avatar"
|
||||
tools:text="余生点唱歌曲大尚" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_go"
|
||||
android:layout_width="180dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:background="@drawable/bg_common_confirm"
|
||||
android:gravity="center"
|
||||
android:text="去看看"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_room_title" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:src="@drawable/ic_recommend_room_close" />
|
||||
|
||||
|
||||
</LinearLayout>
|
@@ -76,14 +76,22 @@
|
||||
android:layout_marginEnd="15dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_resource_0"
|
||||
<com.yizhuan.erban.ui.widget.RectLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="176"
|
||||
android:adjustViewBounds="true"
|
||||
app:hw_ratio="0.285">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_resource_0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_resource_0" />
|
||||
|
||||
</com.yizhuan.erban.ui.widget.RectLayout>
|
||||
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
@@ -92,9 +100,9 @@
|
||||
<ImageView
|
||||
android:id="@+id/iv_resource_1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="82"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_resource_1" />
|
||||
|
||||
<View
|
||||
@@ -105,9 +113,9 @@
|
||||
<ImageView
|
||||
android:id="@+id/iv_resource_2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="82"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_resource_2" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -122,12 +130,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableStart="@drawable/ic_home_recommend_tag"
|
||||
android:drawablePadding="4dp"
|
||||
android:includeFontPadding="false"
|
||||
android:paddingStart="16dp"
|
||||
android:text="最新推荐"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="16sp"
|
||||
android:drawablePadding="4dp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
@@ -139,8 +147,8 @@
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:drawableRight="@drawable/arrow_right"
|
||||
android:gravity="center"
|
||||
android:drawablePadding="2dp"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:text="更多"
|
||||
android:textColor="#b3333333"
|
||||
|
@@ -2,12 +2,13 @@ package com.yizhuan.xchat_android_core.home.bean;
|
||||
|
||||
import com.chad.library.adapter.base.entity.MultiItemEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HomeRoomInfo implements MultiItemEntity {
|
||||
public class HomeRoomInfo implements MultiItemEntity, Serializable {
|
||||
|
||||
public static final int TYPE_ROOM = 1;
|
||||
public static final int TYPE_BANNER = 2;
|
||||
@@ -40,6 +41,9 @@ public class HomeRoomInfo implements MultiItemEntity {
|
||||
private int roomOnlineNum;
|
||||
private String roomAvatar;
|
||||
|
||||
private String failContext;
|
||||
private boolean isPick;
|
||||
|
||||
@Override
|
||||
public int getItemType() {
|
||||
return isBanner ? TYPE_BANNER : TYPE_ROOM;
|
||||
|
@@ -5,6 +5,6 @@ data class ResourceInfo(
|
||||
val id: Int = 0,
|
||||
val posSeq: Int? = null,
|
||||
val resourceContent: String? = null,
|
||||
val resourceType: Int? = null,
|
||||
val resourceType: Int = 0,
|
||||
val strategySeq: Int? = null
|
||||
)
|
@@ -119,7 +119,7 @@ object HomeModel : BaseModel() {
|
||||
api.getHomeResource()
|
||||
}
|
||||
|
||||
suspend fun getResourceJumpInfo(id: Int): List<ResourceInfo>? =
|
||||
suspend fun getResourceJumpInfo(id: Int): HomeRoomInfo? =
|
||||
launchRequest {
|
||||
api.getResourceJumpInfo(id)
|
||||
}
|
||||
@@ -248,7 +248,7 @@ object HomeModel : BaseModel() {
|
||||
* @return
|
||||
*/
|
||||
@GET("/home/pickResource")
|
||||
suspend fun getResourceJumpInfo(@Query("id") id: Int): ServiceResult<List<ResourceInfo>>
|
||||
suspend fun getResourceJumpInfo(@Query("id") id: Int): ServiceResult<HomeRoomInfo>
|
||||
|
||||
/**
|
||||
* 首页热门房间
|
||||
|
Submodule xplan-flutter updated: d45d49f637...11d027780d
Reference in New Issue
Block a user