home动画,金币progress动画
This commit is contained in:
parent
58e3bde0c4
commit
adc0a451b7
|
|
@ -58,6 +58,10 @@ class TaskManager private constructor() {
|
|||
initialized = true
|
||||
}
|
||||
}
|
||||
|
||||
fun getHomeWatchDurationRewardNum(): Int {
|
||||
return 28; // TODO - mTaskConfigBean.xxxx
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
package com.gamedog.vididin.widget
|
||||
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorSet
|
||||
import android.animation.ObjectAnimator
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.view.isVisible
|
||||
import com.gamedog.vididin.databinding.LayoutDragIconViewBinding
|
||||
import kotlin.run
|
||||
import com.gamedog.vididin.manager.TaskManager
|
||||
|
||||
class HomeDragIconView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
|
@ -14,16 +18,78 @@ class HomeDragIconView @JvmOverloads constructor(
|
|||
defStyleAttr: Int = 0
|
||||
) : LinearLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private var mBinding: LayoutDragIconViewBinding? = null
|
||||
private var mBinding: LayoutDragIconViewBinding
|
||||
|
||||
|
||||
init {
|
||||
mBinding = LayoutDragIconViewBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
mBinding?.run {
|
||||
mBinding.run {
|
||||
progressBar.setProgressListener { progress->
|
||||
if (progress >= 100) {
|
||||
tvGoldNum.text = buildString {
|
||||
append("+")
|
||||
append(TaskManager.instance().getHomeWatchDurationRewardNum())
|
||||
}
|
||||
|
||||
executeGoldNumAnim()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun executeGoldNumAnim() {
|
||||
val animView = mBinding.llGoldRoot
|
||||
|
||||
val alphaAnimator = ObjectAnimator.ofFloat(
|
||||
animView,
|
||||
"alpha",
|
||||
0.5f, 1.0f, 0.5f
|
||||
).apply {
|
||||
duration = 500
|
||||
}
|
||||
|
||||
val scaleXAnimator = ObjectAnimator.ofFloat(
|
||||
animView,
|
||||
"scaleX",
|
||||
0.5f, 1.0f, 0.5f
|
||||
).apply {
|
||||
duration = 500
|
||||
}
|
||||
|
||||
val scaleYAnimator = ObjectAnimator.ofFloat(
|
||||
animView,
|
||||
"scaleY",
|
||||
0.5f, 1.0f, 0.5f
|
||||
).apply {
|
||||
duration = 500
|
||||
}
|
||||
|
||||
|
||||
val animatorSet = AnimatorSet()
|
||||
animatorSet.playTogether(alphaAnimator, scaleXAnimator, scaleYAnimator)
|
||||
animatorSet.addListener(object : Animator.AnimatorListener {
|
||||
override fun onAnimationCancel(animation: Animator) {
|
||||
animView.isVisible = false
|
||||
mBinding.progressBar.setProgress(0)
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
animView.isVisible = false
|
||||
mBinding.progressBar.setProgress(0)
|
||||
}
|
||||
|
||||
override fun onAnimationRepeat(animation: Animator) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationStart(animation: Animator) {
|
||||
|
||||
}
|
||||
})
|
||||
animatorSet.start()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,14 +15,15 @@
|
|||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_menu_container"
|
||||
android:id="@+id/ll_gold_root"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@mipmap/home_gold"
|
||||
android:layout_gravity="center"
|
||||
|
|
@ -30,6 +31,7 @@
|
|||
android:layout_marginTop="2dp"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/tv_gold_num"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textStyle="bold"
|
||||
|
|
@ -40,23 +42,6 @@
|
|||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<!--<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_bar"
|
||||
android:layout_width="75dp"
|
||||
android:layout_height="75dp"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@mipmap/home_envelope"
|
||||
android:layout_gravity="center"
|
||||
android:paddingVertical="7dp"
|
||||
/>
|
||||
</FrameLayout>-->
|
||||
<com.ama.core.architecture.widget.CircleProgressBar
|
||||
android:id="@+id/progress_bar"
|
||||
android:layout_width="50dp"
|
||||
|
|
|
|||
|
|
@ -155,10 +155,17 @@ class CircleProgressBar @JvmOverloads constructor(
|
|||
canvas.drawBitmap(icon, null, dstRect, null)
|
||||
}
|
||||
|
||||
private var progressListener: ((progress: Int) -> Unit)? = null
|
||||
|
||||
fun setProgressListener(progressListener: (progress: Int) -> Unit) {
|
||||
this.progressListener = progressListener
|
||||
}
|
||||
|
||||
|
||||
fun setProgress(progress: Int) {
|
||||
this.currentProgress = progress.coerceIn(0, maxProgress)
|
||||
invalidate()
|
||||
progressListener?.invoke(currentProgress)
|
||||
}
|
||||
|
||||
fun setCenterIcon(@DrawableRes iconRes: Int) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue