fix:Vip 頁面支持 MP4 播放,修正佈局問題
This commit is contained in:
@@ -5,18 +5,12 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import androidx.activity.viewModels
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
import com.chwl.app.base.TitleBar
|
||||
@@ -39,6 +33,9 @@ import com.chwl.core.pay.bean.ChargeBean
|
||||
import com.chwl.core.utils.extension.toast
|
||||
import com.chwl.core.vip.bean.VipAuthInfo
|
||||
import com.chwl.core.vip.bean.VipInfo
|
||||
import com.example.lib_utils.AppUtils
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.example.matisse.internal.utils.UIUtils
|
||||
import com.example.module_base.support.billing.IBillingService
|
||||
import com.example.module_base.support.billing.IProductDetails
|
||||
import com.example.module_base.support.billing.IPurchase
|
||||
@@ -120,7 +117,12 @@ class VipCenterActivity : BaseViewBindingActivity<ActivityVipCenterBinding>(),
|
||||
|
||||
private fun initView() {
|
||||
banner = findViewById(R.id.banner_view)
|
||||
banner.setBannerGalleryEffect(25, 25,25)
|
||||
if (UiUtils.isRtl(AppUtils.getApp())) {
|
||||
banner.setBannerGalleryEffect(5, 5, 5)
|
||||
} else {
|
||||
banner.setBannerGalleryEffect(25, 25, 25)
|
||||
}
|
||||
|
||||
banner.addOnPageChangeListener(object : OnPageChangeListener {
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
// 页面滑动中
|
||||
@@ -140,8 +142,6 @@ class VipCenterActivity : BaseViewBindingActivity<ActivityVipCenterBinding>(),
|
||||
recyclerView = findViewById(R.id.recycler_view)
|
||||
recyclerView.layoutManager = GridLayoutManager(this, 2)
|
||||
|
||||
val identificationTitle = findViewById<TextView>(R.id.center_title)
|
||||
identificationTitle.text = R.string.vip_center_2.toString()
|
||||
val exclusivePrivilegesTitle = findViewById<TextView>(R.id.center_title_2)
|
||||
exclusivePrivilegesTitle.text = R.string.vip_center_4.toString()
|
||||
}
|
||||
@@ -222,6 +222,7 @@ class VipCenterActivity : BaseViewBindingActivity<ActivityVipCenterBinding>(),
|
||||
|
||||
vipViewModel.myVipInfoLiveData.observe(this) {
|
||||
it?.let {
|
||||
banner.setCurrentItem(it.currLevel - 1)
|
||||
//TODO 处理有 VIP 的情况,banner 要跳转到对应 index
|
||||
// bannerView.visibility = View.VISIBLE
|
||||
// bannerView.post {
|
||||
@@ -254,6 +255,7 @@ class VipCenterActivity : BaseViewBindingActivity<ActivityVipCenterBinding>(),
|
||||
authAdapter.notifyDataSetChanged()
|
||||
// handleIdentificationAreaContent(it.vipLevel)
|
||||
vipIdentificationsAdapter.setVipInfo(it)
|
||||
refreshOpenVipState()
|
||||
}
|
||||
|
||||
} ?: run {
|
||||
@@ -382,16 +384,27 @@ class VipCenterActivity : BaseViewBindingActivity<ActivityVipCenterBinding>(),
|
||||
currentChargeInfo = chargeList?.firstOrNull {
|
||||
it.prodDesc?.toIntOrNull() == currentVipInfo.vipLevel
|
||||
}
|
||||
if (currentChargeInfo != null && (myVipInfo == null || myVipInfo.vipLevel < currentVipInfo.vipLevel)) {
|
||||
"${currentChargeInfo?.getMoney()} ${
|
||||
getString(R.string.vip_buy_format).format(
|
||||
currentVipInfo.vipName
|
||||
|
||||
if (currentChargeInfo != null){
|
||||
"${currentChargeInfo?.getMoney()?.times(1000)} ${
|
||||
getString(R.string.vip_center_5).format(
|
||||
" / 30"
|
||||
)
|
||||
}".also { binding.tvOpenVip.text = it }
|
||||
binding.layoutOpenVip.isVisible = true
|
||||
} else {
|
||||
binding.layoutOpenVip.isVisible = false
|
||||
}
|
||||
|
||||
// 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
|
||||
// }
|
||||
} else {
|
||||
currentChargeInfo = null
|
||||
// binding.layoutOpenVip.isVisible = false
|
||||
|
@@ -22,6 +22,6 @@ class VipAuthAdapter :
|
||||
helper.setText(R.id.tv_auth_name, item.authName)
|
||||
helper.getView<ImageView>(R.id.iv_auth_icon).load(item.authIcon)
|
||||
helper.itemView.alpha =
|
||||
if (vipInfo?.ownAuthTypes?.contains(item.authType) == true) 1f else 0.5f
|
||||
if (vipInfo?.ownAuthTypes?.contains(item.authType) == true) 1f else 0.7f
|
||||
}
|
||||
}
|
@@ -5,22 +5,29 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.loadFromUrl
|
||||
import com.chwl.app.ui.utils.loadAnim
|
||||
import com.chwl.core.vip.bean.VipInfo
|
||||
import com.opensource.svgaplayer.SVGADrawable
|
||||
import com.opensource.svgaplayer.SVGAImageView
|
||||
import com.opensource.svgaplayer.SVGAParser
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity
|
||||
import com.chwl.library.download.DownloadException
|
||||
import com.chwl.library.download.DownloadManager.download
|
||||
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.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.net.MalformedURLException
|
||||
import java.net.URL
|
||||
import java.io.File
|
||||
|
||||
class VipCenterBannerAdapter(
|
||||
private val context: Context,
|
||||
private val vipInfos: List<VipInfo>
|
||||
) : BannerAdapter<VipInfo, VipCenterBannerAdapter.BannerViewHolder>(vipInfos) {
|
||||
|
||||
private val DOWNLOAD_TAG = "gift_effect_download"
|
||||
|
||||
override fun onCreateHolder(parent: ViewGroup, viewType: Int): BannerViewHolder {
|
||||
val view = LayoutInflater.from(context).inflate(
|
||||
R.layout.banner_vip_center_custom,
|
||||
@@ -30,6 +37,7 @@ class VipCenterBannerAdapter(
|
||||
}
|
||||
|
||||
override fun onBindView(holder: BannerViewHolder, data: VipInfo, position: Int, size: Int) {
|
||||
|
||||
// 加载本地背景图片
|
||||
when(position) {
|
||||
0->holder.imgBackground.setImageResource(R.drawable.vip_center_level_1)
|
||||
@@ -43,28 +51,73 @@ class VipCenterBannerAdapter(
|
||||
8->holder.imgBackground.setImageResource(R.drawable.vip_center_level_9)
|
||||
}
|
||||
|
||||
holder.svgaImage.loadFromUrl(data.vipLogo)
|
||||
// holder.svgaImage.loadFromUrl(data.vipLogo)
|
||||
holder.vapAnimView.setScaleType(ScaleType.CENTER_CROP)
|
||||
holder.vapAnimView.setLoop(Int.MAX_VALUE)
|
||||
holder.vapAnimView.setAnimListener(object : IAnimListener {
|
||||
override fun onFailed(errorType: Int, errorMsg: String?) {
|
||||
println(errorMsg)
|
||||
}
|
||||
|
||||
override fun onVideoComplete() {
|
||||
println("complete")
|
||||
}
|
||||
|
||||
override fun onVideoDestroy() {
|
||||
println("destory")
|
||||
}
|
||||
|
||||
override fun onVideoRender(frameIndex: Int, config: AnimConfig?) {
|
||||
println("rendering")
|
||||
}
|
||||
|
||||
override fun onVideoStart() {
|
||||
println("start")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
val filePath = generateResourcesFilePath(data.vipLogo)
|
||||
val request = build(data.vipLogo, 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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 svgaImage: SVGAImageView = view.findViewById(R.id.iv_vip_icon)
|
||||
val vapAnimView: AnimView = view.findViewById(R.id.vap_anim_view)
|
||||
}
|
||||
|
||||
private fun loadSVGA(svgaImageView: SVGAImageView, svgaUrl: String) {
|
||||
try {
|
||||
SVGAParser.shareParser()
|
||||
.decodeFromURL(URL(svgaUrl), object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
val drawable = SVGADrawable(videoItem)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
svgaImageView.startAnimation()
|
||||
}
|
||||
override fun onError() {
|
||||
}
|
||||
})
|
||||
} catch (e: MalformedURLException) {
|
||||
|
||||
}
|
||||
}
|
||||
// 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,6 +7,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="#150c00"
|
||||
android:orientation="vertical"
|
||||
android:clipChildren="false"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<View
|
||||
@@ -29,6 +30,7 @@
|
||||
|
||||
<com.youth.banner.Banner
|
||||
android:id="@+id/banner_view"
|
||||
android:clipChildren="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:layout_marginTop="20dp"
|
||||
@@ -38,7 +40,6 @@
|
||||
app:bvp_can_loop="false"
|
||||
app:bvp_indicator_visibility="gone"
|
||||
app:bvp_page_style="multi_page_scale"
|
||||
app:layout_constraintDimensionRatio="351:80"
|
||||
app:layout_goneMarginTop="@dimen/dp_16"
|
||||
tools:visibility="visible" />
|
||||
|
||||
@@ -209,18 +210,44 @@
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible">
|
||||
<TextView
|
||||
android:id="@+id/tv_open_vip"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
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"/>
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center_vertical">
|
||||
<ImageView
|
||||
android:id="@+id/tv_icon"
|
||||
android:layout_width="@dimen/dp_20"
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:src="@drawable/vip_center_purchase_coin"
|
||||
android:layout_gravity="center_vertical"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/tv_open_vip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_2"
|
||||
android:drawablePadding="4dp"
|
||||
android:textColor="@color/color_FFE3AF"
|
||||
android:textSize="@dimen/sp_13"
|
||||
android:textStyle="bold"
|
||||
tools:text="19.99 / 30Days"
|
||||
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"
|
||||
|
@@ -4,6 +4,8 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipChildren="false"
|
||||
android:layoutDirection="ltr"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
@@ -22,18 +24,20 @@
|
||||
android:id="@+id/img_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:src="@drawable/vip_center_level_1"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="320:136"
|
||||
android:src="@drawable/vip_center_level_1" />
|
||||
<com.opensource.svgaplayer.SVGAImageView
|
||||
android:id="@+id/iv_vip_icon"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.tencent.qgame.animplayer.AnimView
|
||||
android:id="@+id/vap_anim_view"
|
||||
android:layout_width="@dimen/dp_130"
|
||||
android:layout_height="@dimen/dp_130"
|
||||
android:layout_gravity="end|bottom"
|
||||
app:layout_constraintBottom_toBottomOf="@id/img_background"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_marginBottom="25dp" />
|
||||
android:layout_marginBottom="35dp" />
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/due_date_textview"
|
||||
|
@@ -5287,8 +5287,8 @@
|
||||
<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_5">Days</string>
|
||||
<string name="vip_center_4">Exclusive Privileges/n($s/$s)</string>
|
||||
<string name="vip_center_5">%sDays</string>
|
||||
<string name="vip_center_6"> Expires</string>
|
||||
<string name="vip_center_7">Renew</string>
|
||||
|
||||
|
@@ -5327,7 +5327,7 @@ You cannot join again within 24 hours after leaving</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_5">Days</string>
|
||||
<string name="vip_center_5">%sDays</string>
|
||||
<string name="vip_center_6"> Expires</string>
|
||||
<string name="vip_center_7">Renew</string>
|
||||
|
||||
|
Reference in New Issue
Block a user