|
|
@@ -1,26 +1,30 @@
|
|
|
package com.adealink.weparty.level
|
|
|
|
|
|
-import android.animation.AnimatorSet
|
|
|
-import android.animation.ObjectAnimator
|
|
|
-import android.graphics.Color
|
|
|
import android.os.Bundle
|
|
|
-import android.view.View
|
|
|
-import android.view.animation.AccelerateDecelerateInterpolator
|
|
|
-import androidx.core.view.isVisible
|
|
|
+import com.adealink.frame.aab.util.getCompatColor
|
|
|
import com.adealink.frame.aab.util.getCompatString
|
|
|
import com.adealink.frame.mvvm.view.viewBinding
|
|
|
import com.adealink.frame.router.Router
|
|
|
import com.adealink.frame.router.annotation.BindExtra
|
|
|
import com.adealink.frame.router.annotation.RouterUri
|
|
|
+import com.adealink.frame.util.onClick
|
|
|
import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
|
|
|
-import com.adealink.weparty.commonui.ext.hide
|
|
|
-import com.adealink.weparty.commonui.ext.isSVGAImage
|
|
|
+import com.adealink.weparty.commonui.ext.gone
|
|
|
import com.adealink.weparty.commonui.ext.show
|
|
|
-import com.adealink.weparty.commonui.shimmer.Shimmer
|
|
|
+import com.adealink.weparty.commonui.recycleview.adapter.MultiTypeListAdapter
|
|
|
+import com.adealink.weparty.commonui.recycleview.diffutil.BaseListDiffUtil
|
|
|
+import com.adealink.weparty.commonui.recycleview.itemdecoration.HorizontalItemDecoration
|
|
|
+import com.adealink.weparty.effect.AnimExtraConfig
|
|
|
+import com.adealink.weparty.effect.EffectAnimType
|
|
|
+import com.adealink.weparty.level.adapter.itembinder.SVipReward
|
|
|
+import com.adealink.weparty.level.adapter.itembinder.SVipRewardItemViewBinder
|
|
|
+import com.adealink.weparty.level.constants.WealthLevelOSS.Companion.SVIP_LEVEL_UP_BG
|
|
|
+import com.adealink.weparty.level.data.LEVEL_DROP
|
|
|
+import com.adealink.weparty.level.data.LEVEL_KEEP
|
|
|
+import com.adealink.weparty.level.data.LEVEL_UP
|
|
|
import com.adealink.weparty.level.databinding.DialogSvipLevelUpgradeBinding
|
|
|
import com.adealink.weparty.module.level.Level
|
|
|
import com.adealink.weparty.module.level.data.SVIPLevelChangeNotify
|
|
|
-import com.adealink.frame.util.onClick
|
|
|
import com.adealink.weparty.module.webview.Web
|
|
|
import com.adealink.weparty.url.H5Page
|
|
|
import com.adealink.weparty.url.urlConfigService
|
|
|
@@ -34,25 +38,20 @@ class SVIPLevelUpgradeDialog : BaseDialogFragment(R.layout.dialog_svip_level_upg
|
|
|
@BindExtra(Level.SVIPUpgrade.EXTRA_UPGRADE_DATA)
|
|
|
var upgradeData: SVIPLevelChangeNotify? = null
|
|
|
|
|
|
- private var animatorSet1: AnimatorSet? = null
|
|
|
- private var animatorSet2: AnimatorSet? = null
|
|
|
+ private val listAdapter by lazy{ MultiTypeListAdapter(BaseListDiffUtil()) }
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
setStyle(STYLE_NO_TITLE, APP_R.style.FullScreenDialogTheme)
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
Router.bind(this)
|
|
|
- super.onViewCreated(view, savedInstanceState)
|
|
|
}
|
|
|
|
|
|
override fun initViews() {
|
|
|
- binding.ivDialogClose.onClick {
|
|
|
+ val data = upgradeData ?: return
|
|
|
+ binding.ivClose.onClick {
|
|
|
dismiss()
|
|
|
}
|
|
|
- binding.tvViewPrivileges.onClick {
|
|
|
+ binding.tvGoPrivileges.onClick {
|
|
|
activity?.let {
|
|
|
Router.build(it, Web.FullScreen.PATH)
|
|
|
.putExtra(Web.Common.EXTRA_URL, urlConfigService.getH5Url(H5Page.SVIP))
|
|
|
@@ -60,168 +59,44 @@ class SVIPLevelUpgradeDialog : BaseDialogFragment(R.layout.dialog_svip_level_upg
|
|
|
}
|
|
|
dismiss()
|
|
|
}
|
|
|
- upgradeData?.let { updateData ->
|
|
|
- var stateSvgaPath = ""
|
|
|
- var bgSvgaPath = ""
|
|
|
- when (updateData.type) {
|
|
|
- //保级
|
|
|
- 0 -> {
|
|
|
- stateSvgaPath = "svip_relegation_title.svga"
|
|
|
- bgSvgaPath = "svip_upgrade_light_bg.svga"
|
|
|
- }
|
|
|
- //升级
|
|
|
- 1 -> {
|
|
|
- stateSvgaPath = "svip_upgrade_title.svga"
|
|
|
- bgSvgaPath = "svip_upgrade_light_bg.svga"
|
|
|
- }
|
|
|
- //降级
|
|
|
- 2 -> {
|
|
|
- stateSvgaPath = "svip_downgrade_title.svga"
|
|
|
- bgSvgaPath = ""
|
|
|
- }
|
|
|
+ listAdapter.register(SVipRewardItemViewBinder(data.nextLevel))
|
|
|
+ binding.rvRewards.apply {
|
|
|
+ adapter = listAdapter
|
|
|
+ addItemDecoration(HorizontalItemDecoration(28f, 14f, 14f))
|
|
|
+ }
|
|
|
+ listAdapter.submitList(data.rewards?.map { SVipReward(it) } ?: emptyList())
|
|
|
+ when(data.type) {
|
|
|
+ LEVEL_KEEP -> {
|
|
|
+ binding.ivBg.setImageResource(R.drawable.svip_level_up_bg)
|
|
|
+ binding.tvTitle.text = getCompatString(R.string.level_keep_title, data.nextLevel.toString())
|
|
|
+ binding.levelUpDecorGroup.gone()
|
|
|
+ binding.tvSvipTips.text = getCompatString(R.string.level_up_tips)
|
|
|
}
|
|
|
- binding.wsvSvipLevelState.setAsset(stateSvgaPath)
|
|
|
- if (bgSvgaPath.isBlank()) {
|
|
|
- binding.wsvLigthBg.hide()
|
|
|
- } else {
|
|
|
- binding.wsvLigthBg.setAsset(bgSvgaPath)
|
|
|
+ LEVEL_UP -> {
|
|
|
+ binding.ivBg.setImageResource(R.drawable.svip_level_up_bg)
|
|
|
+ binding.wavBg.show()
|
|
|
+ binding.wavBg.setUrl(SVIP_LEVEL_UP_BG, EffectAnimType.MP4, AnimExtraConfig(-1))
|
|
|
+ binding.tvTitle.text = getCompatString(R.string.level_up_title, data.nextLevel.toString())
|
|
|
+ binding.levelUpDecorGroup.show()
|
|
|
+ binding.tvSvipTips.text = getCompatString(R.string.level_up_tips)
|
|
|
}
|
|
|
-
|
|
|
- if (isSVGAImage(updateData.svipMedalUrl)) {
|
|
|
- binding.ivSvipMedal.show()
|
|
|
- binding.ivSvipMedal.setUrl(updateData.svipMedalUrl)
|
|
|
- } else {
|
|
|
- binding.ivSvipMedal.hide()
|
|
|
- binding.ivSvipZeroMedal.show()
|
|
|
- binding.ivSvipZeroMedal.setImageUrl(updateData.svipMedalUrl)
|
|
|
+ LEVEL_DROP -> {
|
|
|
+ binding.ivBg.setImageResource(R.drawable.svip_level_drop_bg)
|
|
|
+ val colorList = listOf(
|
|
|
+ getCompatColor(APP_R.color.color_FFEAEFEF),
|
|
|
+ getCompatColor(APP_R.color.color_FFB8CACB)
|
|
|
+ )
|
|
|
+ binding.tvTitle.setVerticalLinearGradient(colorList, listOf(0f, 1f))
|
|
|
+ binding.tvTitle.text = getCompatString(R.string.level_drop_title, data.nextLevel.toString())
|
|
|
+ binding.levelUpDecorGroup.gone()
|
|
|
+ binding.tvSvipTips.text = getCompatString(R.string.level_drop_tips)
|
|
|
}
|
|
|
- binding.tvSvipLevel.setImageUrl(updateData.svipLabelUrl)
|
|
|
- binding.tvSvipLevelTips.text =
|
|
|
- getCompatString(APP_R.string.profile_svip_level_upgrade_tip)
|
|
|
- startAnimation(if (binding.ivSvipMedal.visibility == View.INVISIBLE) binding.ivSvipZeroMedal else binding.ivSvipMedal, binding.sflSvipLevel, binding.wsvLigthBg)
|
|
|
- binding.sflSvipLevel.shimmer = generateShimmer(1000)
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- private fun generateShimmer(delay: Long): Shimmer {
|
|
|
- return Shimmer.ColorHighlightBuilder().apply {
|
|
|
- setBaseAlpha(0f)
|
|
|
- setBaseColor(Color.TRANSPARENT)
|
|
|
- setHighlightColor(Color.parseColor("#80FFFFFF"))
|
|
|
- setRepeatCount(0)
|
|
|
- setDropoff(0.1f)
|
|
|
- setDuration(2000)
|
|
|
- setStartDelay(delay)
|
|
|
- setIntensity(0.1f)
|
|
|
- }.build()
|
|
|
- }
|
|
|
-
|
|
|
- override fun onResume() {
|
|
|
- super.onResume()
|
|
|
- if (binding.wsvLigthBg.isVisible) {
|
|
|
- binding.wsvLigthBg.startAnimation()
|
|
|
+ //0级特殊样式
|
|
|
+ if(data.nextLevel == 0) {
|
|
|
+ binding.ivBg.setImageResource(R.drawable.svip_level_0_bg)
|
|
|
+ binding.tvGoPrivileges.gone()
|
|
|
}
|
|
|
- binding.wsvSvipLevelState.startAnimation()
|
|
|
- binding.sflSvipLevel.startShimmer()
|
|
|
- binding.ivSvipMedal.startAnimation()
|
|
|
- }
|
|
|
-
|
|
|
- override fun onPause() {
|
|
|
- super.onPause()
|
|
|
- if (binding.wsvLigthBg.isVisible) {
|
|
|
- binding.wsvLigthBg.stopAnimation()
|
|
|
- }
|
|
|
- binding.wsvSvipLevelState.stopAnimation()
|
|
|
- binding.ivSvipMedal.stopAnimation()
|
|
|
- animatorSet1?.end()
|
|
|
- animatorSet2?.end()
|
|
|
- }
|
|
|
-
|
|
|
- private fun startAnimation(view1: View, view2: View, view3: View) {
|
|
|
- // 缩放和透明度动画1(0%-110%)
|
|
|
- val scaleUpX1 = ObjectAnimator.ofFloat(view1, "scaleX", 0f, 1.1f)
|
|
|
- val scaleUpY1 = ObjectAnimator.ofFloat(view1, "scaleY", 0f, 1.1f)
|
|
|
- val alphaUp1 = ObjectAnimator.ofFloat(view1, "alpha", 0f, 1f)
|
|
|
-
|
|
|
- val scaleUpX2 = ObjectAnimator.ofFloat(view2, "scaleX", 0f, 1.1f)
|
|
|
- val scaleUpY2 = ObjectAnimator.ofFloat(view2, "scaleY", 0f, 1.1f)
|
|
|
- val alphaUp2 = ObjectAnimator.ofFloat(view2, "alpha", 0f, 1f)
|
|
|
-
|
|
|
- val scaleUpX3 = ObjectAnimator.ofFloat(view3, "scaleX", 0f, 1.1f)
|
|
|
- val scaleUpY3 = ObjectAnimator.ofFloat(view3, "scaleY", 0f, 1.1f)
|
|
|
- val alphaUp3 = ObjectAnimator.ofFloat(view3, "alpha", 0f, 1f)
|
|
|
-
|
|
|
- // 设置动画1的时间
|
|
|
- scaleUpX1.duration = 750
|
|
|
- scaleUpY1.duration = 750
|
|
|
- alphaUp1.duration = 750
|
|
|
-
|
|
|
- scaleUpX2.duration = 750
|
|
|
- scaleUpY2.duration = 750
|
|
|
- alphaUp2.duration = 750
|
|
|
-
|
|
|
- scaleUpX3.duration = 750
|
|
|
- scaleUpY3.duration = 750
|
|
|
- alphaUp3.duration = 750
|
|
|
-
|
|
|
- // 设置动画1的插值器
|
|
|
- scaleUpX1.interpolator = AccelerateDecelerateInterpolator()
|
|
|
- scaleUpY1.interpolator = AccelerateDecelerateInterpolator()
|
|
|
- alphaUp1.interpolator = AccelerateDecelerateInterpolator()
|
|
|
-
|
|
|
- scaleUpX2.interpolator = AccelerateDecelerateInterpolator()
|
|
|
- scaleUpY2.interpolator = AccelerateDecelerateInterpolator()
|
|
|
- alphaUp2.interpolator = AccelerateDecelerateInterpolator()
|
|
|
-
|
|
|
- scaleUpX3.interpolator = AccelerateDecelerateInterpolator()
|
|
|
- scaleUpY3.interpolator = AccelerateDecelerateInterpolator()
|
|
|
- alphaUp3.interpolator = AccelerateDecelerateInterpolator()
|
|
|
-
|
|
|
- // 缩放和透明度动画2(110%-100%)
|
|
|
- val scaleDownX1 = ObjectAnimator.ofFloat(view1, "scaleX", 1.1f, 1f)
|
|
|
- val scaleDownY1 = ObjectAnimator.ofFloat(view1, "scaleY", 1.1f, 1f)
|
|
|
-
|
|
|
- val scaleDownX2 = ObjectAnimator.ofFloat(view2, "scaleX", 1.1f, 1f)
|
|
|
- val scaleDownY2 = ObjectAnimator.ofFloat(view2, "scaleY", 1.1f, 1f)
|
|
|
-
|
|
|
- val scaleDownX3 = ObjectAnimator.ofFloat(view3, "scaleX", 1.1f, 1f)
|
|
|
- val scaleDownY3 = ObjectAnimator.ofFloat(view3, "scaleY", 1.1f, 1f)
|
|
|
-
|
|
|
- // 设置动画2的时间
|
|
|
- scaleDownX1.duration = 500
|
|
|
- scaleDownY1.duration = 500
|
|
|
-
|
|
|
- scaleDownX2.duration = 500
|
|
|
- scaleDownY2.duration = 500
|
|
|
-
|
|
|
- scaleDownX3.duration = 500
|
|
|
- scaleDownY3.duration = 500
|
|
|
-
|
|
|
- // 设置动画2的插值器
|
|
|
- scaleDownX1.interpolator = AccelerateDecelerateInterpolator()
|
|
|
- scaleDownY1.interpolator = AccelerateDecelerateInterpolator()
|
|
|
-
|
|
|
- scaleDownX2.interpolator = AccelerateDecelerateInterpolator()
|
|
|
- scaleDownY2.interpolator = AccelerateDecelerateInterpolator()
|
|
|
-
|
|
|
- scaleDownX3.interpolator = AccelerateDecelerateInterpolator()
|
|
|
- scaleDownY3.interpolator = AccelerateDecelerateInterpolator()
|
|
|
-
|
|
|
- // 创建动画集合
|
|
|
- animatorSet1 = AnimatorSet()
|
|
|
- animatorSet2 = AnimatorSet()
|
|
|
-
|
|
|
- // 添加动画到集合
|
|
|
- animatorSet1?.playTogether(scaleUpX1, scaleUpY1, alphaUp1)
|
|
|
- animatorSet1?.playTogether(scaleUpX2, scaleUpY2, alphaUp2)
|
|
|
- animatorSet1?.playTogether(scaleUpX3, scaleUpY3, alphaUp3)
|
|
|
-
|
|
|
- animatorSet2?.play(scaleDownX1)?.with(scaleDownY1)?.with(scaleDownX2)?.with(scaleDownX3)?.with(scaleDownY3)
|
|
|
- ?.with(scaleDownY2)?.after(animatorSet1)
|
|
|
-
|
|
|
- // 开始动画
|
|
|
- animatorSet1?.start()
|
|
|
- animatorSet2?.start()
|
|
|
+ binding.animMdeal.setUrl(data.svipMedalUrl, EffectAnimType.MP4, AnimExtraConfig(-1))
|
|
|
}
|
|
|
-
|
|
|
}
|