房间相册 选择解锁礼物UI
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.databinding.DialogChooseGiftRoomAlbumBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.GridSpacingItemNewDecoration
|
||||
import com.yizhuan.xchat_android_core.gift.GiftModel
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftType
|
||||
|
||||
class ChooseGiftRoomAlbumDialogFragment : BottomSheetDialogFragment() {
|
||||
|
||||
private var _binding: DialogChooseGiftRoomAlbumBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
var onPickedListener: OnPickedListener? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(STYLE_NO_TITLE, R.style.ErbanBottomSheetDialog)
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = super.onCreateDialog(savedInstanceState)
|
||||
dialog.window?.attributes?.apply {
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
height = WindowManager.LayoutParams.MATCH_PARENT
|
||||
}
|
||||
|
||||
return dialog
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = DialogChooseGiftRoomAlbumBinding.inflate(layoutInflater, container, false)
|
||||
|
||||
binding.rvGifts.layoutManager = GridLayoutManager(context, 4)
|
||||
binding.rvGifts.addItemDecoration(GridSpacingItemNewDecoration(resources.getDimensionPixelOffset(R.dimen.dp_20), true))
|
||||
|
||||
|
||||
binding.rvGifts.adapter = object : BaseQuickAdapter<GiftInfo, BaseViewHolder>(R.layout.item_gift_room_album){
|
||||
override fun convert(helper: BaseViewHolder, item: GiftInfo) {
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_gift), item.giftUrl)
|
||||
helper.setText(R.id.tv_gift, item.giftName)
|
||||
helper.setText(R.id.tv_value, item.goldPrice.toString())
|
||||
}
|
||||
}.apply {
|
||||
val gifts = GiftModel.get().getGiftInfoList(GiftType.GIFT_TYPE_NORMAL)
|
||||
setNewData(gifts)
|
||||
|
||||
setOnItemClickListener { _, _, position ->
|
||||
onPickedListener?.onPicked(data[position])
|
||||
}
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener { dismiss() }
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
fun interface OnPickedListener {
|
||||
fun onPicked(giftInfo: GiftInfo)
|
||||
}
|
||||
|
||||
}
|
@@ -52,7 +52,13 @@ class UploadRoomAlbumDialogFragment : BottomSheetDialogFragment() {
|
||||
_binding = DialogRoomAlbumUploadBinding.inflate(layoutInflater, container, false)
|
||||
|
||||
binding.rvPhoto.layoutManager = GridLayoutManager(context, 3)
|
||||
binding.rvPhoto.addItemDecoration(GridSpacingItemNewDecoration(resources.getDimensionPixelOffset(R.dimen.dp_18), true))
|
||||
binding.rvPhoto.addItemDecoration(
|
||||
GridSpacingItemNewDecoration(
|
||||
resources.getDimensionPixelOffset(
|
||||
R.dimen.dp_18
|
||||
), true
|
||||
)
|
||||
)
|
||||
|
||||
photoAdapter =
|
||||
object : BaseMultiItemQuickAdapter<PhotoItem, BaseViewHolder>(
|
||||
@@ -101,7 +107,34 @@ class UploadRoomAlbumDialogFragment : BottomSheetDialogFragment() {
|
||||
binding.rvPhoto.adapter = photoAdapter
|
||||
|
||||
binding.rgType.setOnCheckedChangeListener { group, checkedId ->
|
||||
if (checkedId == binding.rbCommon.id) {
|
||||
binding.tvNoGift.visibility = View.VISIBLE
|
||||
binding.groupGift.visibility = View.INVISIBLE
|
||||
} else {
|
||||
binding.tvNoGift.visibility = View.INVISIBLE
|
||||
binding.groupGift.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
binding.vGift.setOnClickListener {
|
||||
val chooseGiftRoomAlbumDialogFragment = ChooseGiftRoomAlbumDialogFragment()
|
||||
chooseGiftRoomAlbumDialogFragment.onPickedListener =
|
||||
ChooseGiftRoomAlbumDialogFragment.OnPickedListener {
|
||||
binding.tvNoGift.visibility = View.INVISIBLE
|
||||
binding.groupGift.visibility = View.VISIBLE
|
||||
|
||||
ImageLoadUtilsV2.loadImage(binding.ivGift, it.giftUrl)
|
||||
binding.tvGiftName.text = it.giftName
|
||||
binding.tvGiftValue.text = it.goldPrice.toString()
|
||||
}
|
||||
chooseGiftRoomAlbumDialogFragment.show(
|
||||
childFragmentManager,
|
||||
UploadRoomAlbumDialogFragment::class.java.simpleName
|
||||
)
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener { dismiss() }
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
41
app/src/main/res/layout/dialog_choose_gift_room_album.xml
Normal file
41
app/src/main/res/layout/dialog_choose_gift_room_album.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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="match_parent"
|
||||
android:background="@drawable/bg_dialog_share">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:text="選擇解鎖禮物"
|
||||
android:textColor="@color/color_1F1B4F"
|
||||
android:textSize="@dimen/sp_18"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_close"
|
||||
android:layout_width="@dimen/dp_24"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:layout_marginEnd="@dimen/dp_12"
|
||||
android:padding="@dimen/dp_4"
|
||||
android:src="@drawable/chat_popup_game_close"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_gifts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_4"
|
||||
android:layout_marginBottom="@dimen/dp_20"
|
||||
app:layout_constrainedHeight="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_title" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@@ -1,6 +1,7 @@
|
||||
<?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="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/bg_dialog_share">
|
||||
@@ -103,6 +104,7 @@
|
||||
app:layout_constraintTop_toTopOf="@id/v_gift" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_no_gift"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_6"
|
||||
@@ -110,6 +112,49 @@
|
||||
android:textSize="@dimen/sp_14"
|
||||
app:layout_constraintBottom_toBottomOf="@id/v_gift"
|
||||
app:layout_constraintEnd_toStartOf="@id/iv_gift_more"
|
||||
app:layout_constraintTop_toTopOf="@id/v_gift"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_gift"
|
||||
android:layout_width="@dimen/dp_24"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:layout_marginEnd="@dimen/dp_4"
|
||||
android:src="@drawable/default_cover"
|
||||
app:layout_constraintBottom_toBottomOf="@id/v_gift"
|
||||
app:layout_constraintEnd_toStartOf="@id/tv_gift_name"
|
||||
app:layout_constraintTop_toTopOf="@id/v_gift" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_gift_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_12"
|
||||
android:textSize="@dimen/sp_14"
|
||||
app:layout_constraintBottom_toBottomOf="@id/v_gift"
|
||||
app:layout_constraintEnd_toStartOf="@id/iv_diamond"
|
||||
app:layout_constraintTop_toTopOf="@id/v_gift"
|
||||
tools:text="gift name" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_diamond"
|
||||
android:layout_width="@dimen/dp_16"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:layout_marginEnd="@dimen/dp_2"
|
||||
android:src="@mipmap/ic_charge_diamond"
|
||||
app:layout_constraintBottom_toBottomOf="@id/v_gift"
|
||||
app:layout_constraintEnd_toStartOf="@id/tv_gift_value"
|
||||
app:layout_constraintTop_toTopOf="@id/v_gift" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_gift_value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
android:text="@string/zero"
|
||||
android:textSize="@dimen/sp_14"
|
||||
app:layout_constraintBottom_toBottomOf="@id/v_gift"
|
||||
app:layout_constraintEnd_toStartOf="@id/iv_gift_more"
|
||||
app:layout_constraintTop_toTopOf="@id/v_gift" />
|
||||
|
||||
<ImageView
|
||||
@@ -122,6 +167,13 @@
|
||||
app:layout_constraintEnd_toEndOf="@id/v_gift"
|
||||
app:layout_constraintTop_toTopOf="@id/v_gift" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/group_gift"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible"
|
||||
app:constraint_referenced_ids="iv_gift, tv_gift_name, iv_diamond, tv_gift_value" />
|
||||
|
||||
<com.lihang.ShadowLayout
|
||||
android:id="@+id/sl_confirm"
|
||||
android:layout_width="match_parent"
|
||||
|
51
app/src/main/res/layout/item_gift_room_album.xml
Normal file
51
app/src/main/res/layout/item_gift_room_album.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_gift"
|
||||
android:layout_width="@dimen/dp_68"
|
||||
android:layout_height="@dimen/dp_68"
|
||||
android:src="@drawable/default_cover"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_gift"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/color_1F1B4F"
|
||||
android:textSize="@dimen/sp_14"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/iv_gift"
|
||||
tools:text="gift" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_diamond"
|
||||
android:layout_width="@dimen/dp_16"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:src="@mipmap/ic_charge_diamond"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_value"
|
||||
app:layout_constraintEnd_toStartOf="@id/tv_value"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_value" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_2"
|
||||
android:text="@string/zero"
|
||||
android:textColor="@color/color_1F1B4F"
|
||||
android:textSize="@dimen/sp_14"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_diamond"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_gift" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Reference in New Issue
Block a user