@@ -18,13 +18,10 @@ package com.materialstudies.reply.ui.home
18
18
19
19
import android.view.View
20
20
import androidx.recyclerview.widget.RecyclerView
21
- import com.google.android.material.shape.MaterialShapeDrawable
22
21
import com.materialstudies.reply.R
23
22
import com.materialstudies.reply.data.Email
24
23
import com.materialstudies.reply.databinding.EmailItemLayoutBinding
25
24
import com.materialstudies.reply.ui.common.EmailAttachmentAdapter
26
- import com.materialstudies.reply.util.backgroundShapeDrawable
27
- import com.materialstudies.reply.util.foregroundShapeDrawable
28
25
import com.materialstudies.reply.util.getStyleIdFromAttr
29
26
import com.materialstudies.reply.util.setTextAppearanceCompat
30
27
@@ -38,9 +35,6 @@ class EmailViewHolder(
38
35
= R .layout.email_attachment_preview_item_layout
39
36
}
40
37
41
- private val cardBackground: MaterialShapeDrawable = binding.cardView.backgroundShapeDrawable
42
- private val cardForeground: MaterialShapeDrawable = binding.cardView.foregroundShapeDrawable
43
-
44
38
override val reboundableView: View = binding.cardView
45
39
46
40
init {
@@ -74,17 +68,11 @@ class EmailViewHolder(
74
68
// rounded or squared. Since all other corners are set to 0dp rounded, they are
75
69
// not affected.
76
70
val interpolation = if (email.isStarred) 1F else 0F
77
- setCardShapeInterpolation( interpolation)
71
+ binding.cardView.progress = interpolation
78
72
79
73
binding.executePendingBindings()
80
74
}
81
75
82
- private fun setCardShapeInterpolation (interpolation : Float ) {
83
- cardBackground.interpolation = interpolation
84
- cardForeground.interpolation = interpolation
85
- }
86
-
87
-
88
76
override fun onReboundOffsetChanged (
89
77
currentSwipePercentage : Float ,
90
78
swipeThreshold : Float ,
@@ -100,7 +88,7 @@ class EmailViewHolder(
100
88
// Animate the top left corner radius of the email card as swipe happens.
101
89
val interpolation = (currentSwipePercentage / swipeThreshold).coerceIn(0F , 1F )
102
90
val adjustedInterpolation = Math .abs((if (isStarred) 1F else 0F ) - interpolation)
103
- setCardShapeInterpolation( adjustedInterpolation)
91
+ binding.cardView.progress = adjustedInterpolation
104
92
105
93
// Start the background animation once the threshold is met.
106
94
val thresholdMet = currentSwipePercentage >= swipeThreshold
0 commit comments