1
1
package com.stop.ui.mission
2
2
3
3
import android.Manifest
4
- import android.animation.Animator
5
- import android.animation.AnimatorListenerAdapter
6
4
import android.content.ContextWrapper
7
5
import android.os.Bundle
8
6
import android.view.LayoutInflater
@@ -122,32 +120,26 @@ class MissionFragment : Fragment(), TMapHandler {
122
120
123
121
private fun setObserve () {
124
122
val shortAnimationDuration =
125
- resources.getInteger(android.R .integer.config_shortAnimTime)
123
+ resources.getInteger(android.R .integer.config_shortAnimTime).toLong()
126
124
127
125
viewModel.timeIncreased.observe(viewLifecycleOwner) {
128
126
val sign = if (it > 0 ) {
129
127
PLUS
130
128
} else {
131
129
MINUS
132
130
}
133
- binding.textViewChangedTime.text =
134
- resources.getString(R .string.number_format).format(sign, it)
135
- binding.textViewChangedTime.apply {
136
- alpha = 0f
131
+ with (binding.textViewChangedTime) {
132
+ text = resources.getString(R .string.number_format).format(sign, it)
137
133
visibility = View .VISIBLE
138
- animate().alpha(1f )
139
- .setDuration(shortAnimationDuration.toLong())
140
- .setListener(object : AnimatorListenerAdapter () {
141
- override fun onAnimationEnd (animation : Animator ? ) {
142
- animate().alpha(0f )
143
- .setDuration(shortAnimationDuration.toLong())
144
- .setListener(object : AnimatorListenerAdapter () {
145
- override fun onAnimationEnd (animation : Animator ? ) {
146
- binding.textViewChangedTime.visibility = View .GONE
147
- }
148
- })
149
- }
150
- })
134
+ this .animate().alpha(ALPHA_VISIBLE )
135
+ .setDuration(shortAnimationDuration)
136
+ .withEndAction {
137
+ animate().alpha(ALPHA_INVISIBLE )
138
+ .setDuration(shortAnimationDuration)
139
+ .withEndAction {
140
+ visibility = View .INVISIBLE
141
+ }
142
+ }
151
143
}
152
144
}
153
145
}
@@ -159,5 +151,8 @@ class MissionFragment : Fragment(), TMapHandler {
159
151
private const val LEFT_TIME = 60
160
152
161
153
private const val FAKE_USER_FILE_PATH = " fake_user_path.txt"
154
+
155
+ private const val ALPHA_VISIBLE = 1f
156
+ private const val ALPHA_INVISIBLE = 0f
162
157
}
163
158
}
0 commit comments