Skip to content

Commit 402506c

Browse files
committed
chore: 시간 변화 textView animation 로직 변경
1 parent cb7f689 commit 402506c

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

presentation/src/main/java/com/stop/ui/mission/MissionFragment.kt

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.stop.ui.mission
22

33
import android.Manifest
4-
import android.animation.Animator
5-
import android.animation.AnimatorListenerAdapter
64
import android.content.ContextWrapper
75
import android.os.Bundle
86
import android.view.LayoutInflater
@@ -122,32 +120,26 @@ class MissionFragment : Fragment(), TMapHandler {
122120

123121
private fun setObserve() {
124122
val shortAnimationDuration =
125-
resources.getInteger(android.R.integer.config_shortAnimTime)
123+
resources.getInteger(android.R.integer.config_shortAnimTime).toLong()
126124

127125
viewModel.timeIncreased.observe(viewLifecycleOwner) {
128126
val sign = if (it > 0) {
129127
PLUS
130128
} else {
131129
MINUS
132130
}
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)
137133
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+
}
151143
}
152144
}
153145
}
@@ -159,5 +151,8 @@ class MissionFragment : Fragment(), TMapHandler {
159151
private const val LEFT_TIME = 60
160152

161153
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
162157
}
163158
}

presentation/src/main/res/layout/fragment_mission.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
android:layout_height="wrap_content"
5555
android:layout_marginStart="16dp"
5656
android:textSize="32sp"
57-
android:visibility="gone"
57+
android:visibility="invisible"
5858
app:layout_constraintStart_toEndOf="@id/text_view_time_left"
5959
app:layout_constraintTop_toTopOf="@id/text_view_time_left"
6060
tools:text="+1" />

0 commit comments

Comments
 (0)