feat: 更新资源,调整布局
@@ -50,6 +50,11 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import com.youth.banner.listener.OnPageChangeListener
|
||||
import java.text.SimpleDateFormat
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
||||
|
||||
class VipCenterActivity : BaseViewBindingActivity<ActivityVipCenterBinding>(),
|
||||
@@ -141,9 +146,6 @@ class VipCenterActivity : BaseViewBindingActivity<ActivityVipCenterBinding>(),
|
||||
|
||||
recyclerView = findViewById(R.id.recycler_view)
|
||||
recyclerView.layoutManager = GridLayoutManager(this, 2)
|
||||
|
||||
val exclusivePrivilegesTitle = findViewById<TextView>(R.id.center_title_2)
|
||||
exclusivePrivilegesTitle.text = R.string.vip_center_4.toString()
|
||||
}
|
||||
|
||||
override fun initWhiteTitleBar(title: String?) {
|
||||
@@ -207,22 +209,24 @@ class VipCenterActivity : BaseViewBindingActivity<ActivityVipCenterBinding>(),
|
||||
it?.let { // 当前显示的 index
|
||||
// TODO 处理轮播组件 index 更新
|
||||
currentIndex = it
|
||||
handleIdentificationAreaContent(it)
|
||||
}
|
||||
}
|
||||
|
||||
vipViewModel.vipInfosLiveData.observe(this) {
|
||||
it?.let { // ArrayList[VipInfo] 每个等级的 VIP 内容
|
||||
// TODO 初始化轮播组件
|
||||
val adapter = VipCenterBannerAdapter(this, it)
|
||||
banner.setAdapter(adapter, false)
|
||||
handleIdentificationAreaContent(0)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
vipViewModel.myVipInfoLiveData.observe(this) {
|
||||
it?.let {
|
||||
banner.setCurrentItem(it.currLevel - 1)
|
||||
val adapter = vipViewModel.vipInfosLiveData.value?.let { it1 ->
|
||||
VipCenterBannerAdapter(this,
|
||||
it1, it)
|
||||
}
|
||||
banner.setAdapter(adapter, false)
|
||||
//TODO 处理有 VIP 的情况,banner 要跳转到对应 index
|
||||
// bannerView.visibility = View.VISIBLE
|
||||
// bannerView.post {
|
||||
@@ -253,7 +257,7 @@ class VipCenterActivity : BaseViewBindingActivity<ActivityVipCenterBinding>(),
|
||||
// TODO 根据当前显示的 VIP 信息更新 UI
|
||||
authAdapter.setVipInfo(it)
|
||||
authAdapter.notifyDataSetChanged()
|
||||
// handleIdentificationAreaContent(it.vipLevel)
|
||||
handleIdentificationAreaContent(it)
|
||||
vipIdentificationsAdapter.setVipInfo(it)
|
||||
refreshOpenVipState()
|
||||
}
|
||||
@@ -270,8 +274,12 @@ class VipCenterActivity : BaseViewBindingActivity<ActivityVipCenterBinding>(),
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleIdentificationAreaContent(position: Int) {
|
||||
// 条件:
|
||||
private fun handleIdentificationAreaContent(vipInfo: VipInfo) {
|
||||
val exclusivePrivilegesTitle = findViewById<TextView>(R.id.center_title_2)
|
||||
"${getString(R.string.vip_center_4)}\n(${vipInfo.ownAuthTypes?.size}/13)".also {
|
||||
binding.centerTitle2.text = it
|
||||
}
|
||||
// exclusivePrivilegesTitle.text = R.string.vip_center_4.toString()
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@@ -386,25 +394,29 @@ class VipCenterActivity : BaseViewBindingActivity<ActivityVipCenterBinding>(),
|
||||
}
|
||||
|
||||
if (currentChargeInfo != null){
|
||||
"${currentChargeInfo?.getMoney()?.times(1000)} ${
|
||||
"${currentChargeInfo?.getMoney()?.times(1000)?.toInt()} ${
|
||||
getString(R.string.vip_center_5).format(
|
||||
" / 30"
|
||||
)
|
||||
}".also { binding.tvOpenVip.text = it }
|
||||
}
|
||||
|
||||
// if (currentChargeInfo != null && (myVipInfo == null || myVipInfo.vipLevel < currentVipInfo.vipLevel)) {
|
||||
// // TODO: 處理新增的 金幣返回
|
||||
// "${currentChargeInfo?.getMoney()} ${
|
||||
// getString(R.string.vip_center_5).format(
|
||||
// // TODO: 計算剩餘時間
|
||||
// " / 30"
|
||||
// )
|
||||
// }".also { binding.tvOpenVip.text = it }
|
||||
// binding.layoutOpenVip.isVisible = true
|
||||
// } else {
|
||||
// binding.layoutOpenVip.isVisible = false
|
||||
// }
|
||||
// 获取当前时间
|
||||
val calendar = Calendar.getInstance()
|
||||
|
||||
// 计算30天后的时间
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 30)
|
||||
|
||||
// 定义输出格式
|
||||
val dateFormat = SimpleDateFormat("yyyy/MM/dd 00:00", Locale.getDefault())
|
||||
|
||||
// 格式化日期时间
|
||||
val formattedDate = dateFormat.format(calendar.time)
|
||||
|
||||
// 输出结果
|
||||
val result = "$formattedDate Expires"
|
||||
binding.tvAdditionalText.text = result
|
||||
|
||||
} else {
|
||||
currentChargeInfo = null
|
||||
// binding.layoutOpenVip.isVisible = false
|
||||
|
@@ -4,6 +4,7 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.loadAnim
|
||||
@@ -14,16 +15,21 @@ import com.chwl.library.download.DownloadRequest.Companion.build
|
||||
import com.chwl.library.download.DownloadTask
|
||||
import com.chwl.library.download.FileDownloadListener
|
||||
import com.chwl.library.utils.PathHelper.generateResourcesFilePath
|
||||
import com.chwl.library.utils.ResUtil.getString
|
||||
import com.tencent.qgame.animplayer.AnimConfig
|
||||
import com.tencent.qgame.animplayer.AnimView
|
||||
import com.tencent.qgame.animplayer.inter.IAnimListener
|
||||
import com.tencent.qgame.animplayer.util.ScaleType
|
||||
import com.youth.banner.adapter.BannerAdapter
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
||||
class VipCenterBannerAdapter(
|
||||
private val context: Context,
|
||||
private val vipInfos: List<VipInfo>
|
||||
private val vipInfos: List<VipInfo>,
|
||||
private val myVipInfo: VipInfo?
|
||||
) : BannerAdapter<VipInfo, VipCenterBannerAdapter.BannerViewHolder>(vipInfos) {
|
||||
|
||||
private val DOWNLOAD_TAG = "gift_effect_download"
|
||||
@@ -38,17 +44,34 @@ class VipCenterBannerAdapter(
|
||||
|
||||
override fun onBindView(holder: BannerViewHolder, data: VipInfo, position: Int, size: Int) {
|
||||
|
||||
// 加载本地背景图片
|
||||
holder.dueText.visibility = View.GONE
|
||||
myVipInfo?.let {
|
||||
if (it.vipLevel == data.vipLevel) {
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.add(Calendar.SECOND, it.remainSeconds)
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
||||
val formattedDate = dateFormat.format(calendar.time)
|
||||
val result = "${getString(R.string.vip_center_2)}$formattedDate"
|
||||
holder.dueText.text = result
|
||||
holder.dueText.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
var colorHex = ""
|
||||
var resourceName = "vip_center_level_${position+1}"
|
||||
val resourceId = context.resources.getIdentifier(resourceName, "drawable", context.packageName)
|
||||
holder.imgBackground.setImageResource(resourceId)
|
||||
|
||||
when(position) {
|
||||
0->holder.imgBackground.setImageResource(R.drawable.vip_center_level_1)
|
||||
1->holder.imgBackground.setImageResource(R.drawable.vip_center_level_2)
|
||||
2->holder.imgBackground.setImageResource(R.drawable.vip_center_level_3)
|
||||
3->holder.imgBackground.setImageResource(R.drawable.vip_center_level_4)
|
||||
4->holder.imgBackground.setImageResource(R.drawable.vip_center_level_5)
|
||||
5->holder.imgBackground.setImageResource(R.drawable.vip_center_level_6)
|
||||
6->holder.imgBackground.setImageResource(R.drawable.vip_center_level_7)
|
||||
7->holder.imgBackground.setImageResource(R.drawable.vip_center_level_8)
|
||||
8->holder.imgBackground.setImageResource(R.drawable.vip_center_level_9)
|
||||
0-> holder.dueText.setTextColor(context.resources.getColor(R.color.color_3A4D14))
|
||||
1-> holder.dueText.setTextColor(context.resources.getColor(R.color.color_4D143A))
|
||||
2-> holder.dueText.setTextColor(context.resources.getColor(R.color.color_4D2C14))
|
||||
3-> holder.dueText.setTextColor(context.resources.getColor(R.color.color_44144D))
|
||||
4-> holder.dueText.setTextColor(context.resources.getColor(R.color.color_1C344D))
|
||||
5-> holder.dueText.setTextColor(context.resources.getColor(R.color.color_1C4D35))
|
||||
6-> holder.dueText.setTextColor(context.resources.getColor(R.color.color_44144D))
|
||||
7-> holder.dueText.setTextColor(context.resources.getColor(R.color.color_4D371C))
|
||||
8-> holder.dueText.setTextColor(context.resources.getColor(R.color.color_4D1C1C))
|
||||
}
|
||||
|
||||
// holder.svgaImage.loadFromUrl(data.vipLogo)
|
||||
@@ -94,30 +117,12 @@ class VipCenterBannerAdapter(
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
inner class BannerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val imgBackground: ImageView = view.findViewById(R.id.img_background)
|
||||
// val svgaImage: SVGAImageView = view.findViewById(R.id.iv_vip_icon)
|
||||
val vapAnimView: AnimView = view.findViewById(R.id.vap_anim_view)
|
||||
val dueText: TextView = view.findViewById(R.id.due_date_textview)
|
||||
}
|
||||
|
||||
// private fun drawVAPEffect(url: String) {
|
||||
//// log("drawVAPEffect url:$url")
|
||||
// val filePath = generateResourcesFilePath(url)
|
||||
// val request = build(url, filePath, DOWNLOAD_TAG, null, 60000L)
|
||||
// download(request, object : FileDownloadListener() {
|
||||
// override fun onDownloadCompleted(task: DownloadTask) {
|
||||
// val path = task.getRequest().getPath()
|
||||
//// log("drawVAPEffect onDownloadCompleted url:$url path:$path")
|
||||
// holder.vapAnimView.startPlay(File(path))
|
||||
// }
|
||||
//
|
||||
// override fun onDownloadError(exception: DownloadException) {
|
||||
//// log("drawVAPEffect onDownloadError url:$url")
|
||||
// exception.printStackTrace()
|
||||
//// effectHandler.sendEmptyMessageDelayed(0, 4000)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
}
|
@@ -7,7 +7,6 @@ import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.chwl.app.R
|
||||
import com.chwl.core.vip.bean.VipAuthInfo
|
||||
import com.chwl.core.vip.bean.VipInfo
|
||||
@@ -36,27 +35,45 @@ class VipCenterIdentificationsAdapter(
|
||||
holder: VipCenterIdentificationsAdapter.ItemViewHolder,
|
||||
position: Int
|
||||
) {
|
||||
val item = items[position]
|
||||
|
||||
// 加载内容图片
|
||||
Glide.with(context)
|
||||
.load(item.authIcon)
|
||||
.into(holder.contentImageView)
|
||||
|
||||
// 设置标题
|
||||
holder.titleTextView.text = item.authName
|
||||
|
||||
holder.itemView.setOnClickListener {
|
||||
listener.onItemClick(position)
|
||||
var targetIndex = 0
|
||||
when(position) {
|
||||
0 -> targetIndex = 0
|
||||
1 -> targetIndex = 1
|
||||
2 -> targetIndex = 4
|
||||
3 -> targetIndex = 7
|
||||
4 -> targetIndex = 11
|
||||
}
|
||||
val item = items[targetIndex]
|
||||
vipInfo?.let {
|
||||
holder.titleTextView.text = item.authName
|
||||
|
||||
val lv = it.vipLevel
|
||||
var resourceName = "null"
|
||||
|
||||
when (position) {
|
||||
0 -> resourceName = "vip_center_identification_vipidentity_lv$lv"
|
||||
1 -> resourceName = "vip_center_identification_roomcard_lv$lv"
|
||||
2 -> resourceName = "vip_center_identification_mic_lv$lv"
|
||||
3 -> resourceName = "vip_center_identification_bubble_lv$lv"
|
||||
4 -> resourceName = "vip_center_identification_entry_lv$lv"
|
||||
}
|
||||
|
||||
val resourceId = context.resources
|
||||
.getIdentifier(resourceName, "drawable", context.packageName)
|
||||
holder.contentImageView.setImageResource(resourceId)
|
||||
}
|
||||
|
||||
// holder.itemView.setOnClickListener {
|
||||
// listener.onItemClick(position)
|
||||
// }
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return vipInfo?.let {
|
||||
when (it.vipLevel) {
|
||||
1, 2 -> 3
|
||||
3 -> 4
|
||||
else -> 6
|
||||
1, 2 -> 2
|
||||
3 -> 3
|
||||
else -> 5
|
||||
}
|
||||
} ?: 0 // items.size
|
||||
}
|
||||
@@ -69,7 +86,6 @@ class VipCenterIdentificationsAdapter(
|
||||
}
|
||||
|
||||
inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
// val backgroundImageView: ImageView = view.findViewById(R.id.background_image)
|
||||
val contentImageView: ImageView = view.findViewById(R.id.item_image)
|
||||
val titleTextView: TextView = view.findViewById(R.id.item_title)
|
||||
}
|
||||
|
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 71 KiB |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 81 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 117 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 107 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 75 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 110 KiB |
After Width: | Height: | Size: 111 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 65 KiB |
After Width: | Height: | Size: 74 KiB |
After Width: | Height: | Size: 81 KiB |
@@ -7,7 +7,6 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="#150c00"
|
||||
android:orientation="vertical"
|
||||
android:clipChildren="false"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<View
|
||||
@@ -31,9 +30,10 @@
|
||||
<com.youth.banner.Banner
|
||||
android:id="@+id/banner_view"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginTop="@dimen/dp_30"
|
||||
app:layout_constraintTop_toBottomOf="@id/title_bar"
|
||||
android:visibility="visible"
|
||||
app:bvp_auto_play="false"
|
||||
@@ -236,19 +236,6 @@
|
||||
android:text="@string/vip_center_5"/>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/tv_open_vip"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:drawablePadding="4dp"-->
|
||||
<!-- android:gravity="start|center_vertical"-->
|
||||
<!-- android:textColor="@color/color_FFE3AF"-->
|
||||
<!-- android:textSize="@dimen/sp_13"-->
|
||||
<!-- android:textStyle="bold"-->
|
||||
<!-- app:drawableLeftCompat="@drawable/vip_center_purchase_coin"-->
|
||||
<!-- tools:text="19.99 / 30Days"-->
|
||||
<!-- android:text="@string/vip_center_5"/>-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_additional_text"
|
||||
android:layout_width="match_parent"
|
||||
|
@@ -5287,7 +5287,7 @@
|
||||
<string name="vip_center_1">Activate VIP</string>
|
||||
<string name="vip_center_2">Due on:</string>
|
||||
<string name="vip_center_3">Identification</string>
|
||||
<string name="vip_center_4">Exclusive Privileges/n($s/$s)</string>
|
||||
<string name="vip_center_4">Exclusive Privileges</string>
|
||||
<string name="vip_center_5">%sDays</string>
|
||||
<string name="vip_center_6"> Expires</string>
|
||||
<string name="vip_center_7">Renew</string>
|
||||
|
@@ -750,4 +750,13 @@
|
||||
|
||||
<color name="color_FFE3AF">#FFE3AF</color>
|
||||
<color name="color_633000">#633000</color>
|
||||
|
||||
<color name="color_3A4D14">#3A4D14</color>
|
||||
<color name="color_4D2C14">#4D2C14</color>
|
||||
<color name="color_44144D">#44144D</color>
|
||||
<color name="color_4D143A">#4D143A</color>
|
||||
<color name="color_1C344D">#1C344D</color>
|
||||
<color name="color_1C4D35">#1C4D35</color>
|
||||
<color name="color_4D371C">#4D371C</color>
|
||||
<color name="color_4D1C1C">#4D1C1C</color>
|
||||
</resources>
|
||||
|
@@ -5326,7 +5326,7 @@ You cannot join again within 24 hours after leaving</string>
|
||||
<string name="vip_center_1">Activate VIP</string>
|
||||
<string name="vip_center_2">Due on:</string>
|
||||
<string name="vip_center_3">Identification</string>
|
||||
<string name="vip_center_4">Exclusive Privileges/n</string>
|
||||
<string name="vip_center_4">Exclusive Privileges</string>
|
||||
<string name="vip_center_5">%sDays</string>
|
||||
<string name="vip_center_6"> Expires</string>
|
||||
<string name="vip_center_7">Renew</string>
|
||||
|