Skip to content

Commit

Permalink
feat #725: pokeNum에 따른 lottie 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
chattymin committed Jun 5, 2024
1 parent c5fae64 commit 3ea8480
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 3,922 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ class PokeMainActivity : AppCompatActivity() {
},
)

animationFriendViewLottie.addAnimatorListener(
object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator) {}

override fun onAnimationEnd(animation: Animator) {
layoutFreindLottie.visibility = View.GONE
}

override fun onAnimationCancel(animation: Animator) {}

override fun onAnimationRepeat(animation: Animator) {}
},
)

layoutLottie.setOnClickListener {
// do nothing
}
Expand Down Expand Up @@ -199,12 +213,35 @@ class PokeMainActivity : AppCompatActivity() {
viewModel.updatePokeUserState(it.data.userId)
when (it.isFirstMeet && !it.data.isFirstMeet) {
true -> {
binding.layoutLottie.visibility = View.VISIBLE
binding.tvLottie.text = binding.root.context.getString(R.string.friend_complete, it.data.name)
binding.animationViewLottie.playAnimation()
with(binding) {
layoutLottie.visibility = View.VISIBLE
tvLottie.text = binding.root.context.getString(R.string.friend_complete, it.data.name)
animationViewLottie.playAnimation()
}
}

false -> showPokeToast(getString(R.string.toast_poke_user_success))
false -> {
if (it.data.pokeNum == 5 && it.data.isAnonymous) {
with(binding) {
layoutFreindLottie.visibility = View.VISIBLE
tvFreindLottie.text = getString(R.string.anonymous_to_friend, it.data.anonymousName, "단짝친구가")
tvFreindLottieHint.text = getString(R.string.poke_user_info_part, it.data.generation, it.data.part)
animationFriendViewLottie.apply {
setAnimation(R.raw.friendtobestfriend)
}.playAnimation()
}
} else if (it.data.pokeNum == 11 && it.data.isAnonymous) {
with(binding) {
layoutFreindLottie.visibility = View.VISIBLE
tvFreindLottie.text = getString(R.string.anonymous_to_friend, it.data.anonymousName, "천생연분이")
animationFriendViewLottie.apply {
setAnimation(R.raw.bestfriendtosoulmate)
}.playAnimation()
}
} else {
showPokeToast(getString(R.string.toast_poke_user_success))
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import dagger.hilt.android.AndroidEntryPoint
import java.io.Serializable
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.official.analytics.AmplitudeTracker
Expand All @@ -53,6 +51,8 @@ import org.sopt.official.feature.poke.databinding.ActivityPokeNotificationBindin
import org.sopt.official.feature.poke.message.MessageListBottomSheetFragment
import org.sopt.official.feature.poke.user.PokeUserListClickListener
import org.sopt.official.feature.poke.util.showPokeToast
import java.io.Serializable
import javax.inject.Inject

@AndroidEntryPoint
class PokeNotificationActivity : AppCompatActivity() {
Expand Down Expand Up @@ -113,6 +113,20 @@ class PokeNotificationActivity : AppCompatActivity() {
},
)

animationFriendViewLottie.addAnimatorListener(
object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator) {}

override fun onAnimationEnd(animation: Animator) {
layoutFreindLottie.visibility = View.GONE
}

override fun onAnimationCancel(animation: Animator) {}

override fun onAnimationRepeat(animation: Animator) {}
},
)

layoutLottie.setOnClickListener {
// do nothing
}
Expand Down Expand Up @@ -212,12 +226,35 @@ class PokeNotificationActivity : AppCompatActivity() {
pokeNotificationAdapter.updatePokeUserItemPokeState(it.data.userId)
when (it.isFirstMeet && !it.data.isFirstMeet) {
true -> {
binding.layoutLottie.visibility = View.VISIBLE
binding.tvLottie.text = binding.root.context.getString(R.string.friend_complete, it.data.name)
binding.animationViewLottie.playAnimation()
with(binding) {
layoutLottie.visibility = View.VISIBLE
tvLottie.text = binding.root.context.getString(R.string.friend_complete, it.data.name)
animationViewLottie.playAnimation()
}
}

false -> showPokeToast(getString(R.string.toast_poke_user_success))
false -> {
if (it.data.pokeNum == 5 && it.data.isAnonymous) {
with(binding) {
layoutFreindLottie.visibility = View.VISIBLE
tvFreindLottie.text = getString(R.string.anonymous_to_friend, it.data.anonymousName, "단짝친구가")
tvFreindLottieHint.text = getString(R.string.poke_user_info_part, it.data.generation, it.data.part)
animationFriendViewLottie.apply {
setAnimation(R.raw.friendtobestfriend)
}.playAnimation()
}
} else if(it.data.pokeNum == 11 && it.data.isAnonymous) {
with(binding) {
layoutFreindLottie.visibility = View.VISIBLE
tvFreindLottie.text = getString(R.string.anonymous_to_friend, it.data.anonymousName, "천생연분이")
animationFriendViewLottie.apply {
setAnimation(R.raw.bestfriendtosoulmate)
}.playAnimation()
}
} else {
showPokeToast(getString(R.string.toast_poke_user_success))
}
}
}
}

Expand Down
56 changes: 56 additions & 0 deletions feature/poke/src/main/res/layout/activity_poke_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,62 @@
android:layout_height="match_parent"
tools:context=".main.PokeMainActivity">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_freind_lottie"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/mds_gray_950_alpha80"
android:elevation="@dimen/cardview_compat_inset_shadow"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:id="@+id/tv_freind_lottie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="@font/suit_bold"
android:gravity="center"
android:lineSpacingExtra="6dp"
android:textColor="@color/mds_gray_10"
android:textFontWeight="600"
android:textSize="18dp"
app:layout_constraintEnd_toEndOf="@id/animation_friend_view_lottie"
app:layout_constraintStart_toStartOf="@id/animation_friend_view_lottie"
app:layout_constraintBottom_toTopOf="@id/animation_friend_view_lottie"
tools:text="익명의 사자님과\n단짝친구가 되었어요" />

<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animation_friend_view_lottie"
android:layout_width="200dp"
android:layout_height="200dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_rawRes="@raw/bestfriendtosoulmate" />

<TextView
android:id="@+id/tv_freind_lottie_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="34dp"
android:fontFamily="@font/suit_bold"
android:gravity="center"
android:lineSpacingExtra="6dp"
android:textColor="@color/mds_gray_10"
android:textFontWeight="600"
android:textSize="18dp"
app:layout_constraintEnd_toEndOf="@id/animation_friend_view_lottie"
app:layout_constraintStart_toStartOf="@id/animation_friend_view_lottie"
app:layout_constraintTop_toBottomOf="@id/animation_friend_view_lottie"
tools:text="34기 디자인파트" />

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_lottie"
android:layout_width="match_parent"
Expand Down
56 changes: 56 additions & 0 deletions feature/poke/src/main/res/layout/activity_poke_notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,62 @@
android:layout_height="match_parent"
tools:context=".notification.PokeNotificationActivity">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_freind_lottie"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/mds_gray_950_alpha80"
android:elevation="@dimen/cardview_compat_inset_shadow"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:id="@+id/tv_freind_lottie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="@font/suit_bold"
android:gravity="center"
android:lineSpacingExtra="6dp"
android:textColor="@color/mds_gray_10"
android:textFontWeight="600"
android:textSize="18dp"
app:layout_constraintEnd_toEndOf="@id/animation_friend_view_lottie"
app:layout_constraintStart_toStartOf="@id/animation_friend_view_lottie"
app:layout_constraintBottom_toTopOf="@id/animation_friend_view_lottie"
tools:text="익명의 사자님과\n단짝친구가 되었어요" />

<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animation_friend_view_lottie"
android:layout_width="200dp"
android:layout_height="200dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_rawRes="@raw/bestfriendtosoulmate" />

<TextView
android:id="@+id/tv_freind_lottie_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="34dp"
android:fontFamily="@font/suit_bold"
android:gravity="center"
android:lineSpacingExtra="6dp"
android:textColor="@color/mds_gray_10"
android:textFontWeight="600"
android:textSize="18dp"
app:layout_constraintEnd_toEndOf="@id/animation_friend_view_lottie"
app:layout_constraintStart_toStartOf="@id/animation_friend_view_lottie"
app:layout_constraintTop_toBottomOf="@id/animation_friend_view_lottie"
tools:text="34기 디자인파트" />

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_lottie"
android:layout_width="match_parent"
Expand Down
2,032 changes: 0 additions & 2,032 deletions feature/poke/src/main/res/raw/bestfriendtosoulmate.json

This file was deleted.

Binary file not shown.
1,880 changes: 0 additions & 1,880 deletions feature/poke/src/main/res/raw/friendtobestfreind.json

This file was deleted.

Binary file not shown.
2 changes: 2 additions & 0 deletions feature/poke/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@

<!-- 친구 아이템 -->
<string name="poke_user_info">%1$d기 %2$s</string>
<string name="poke_user_info_part">%1$d기 %2$s파트</string>
<string name="poke_user_poke_count">%1$d콕</string>
<string name="poke_user_profile_url">https://playground.sopt.org/members/%1$d</string>
<string name="poke_user_alert_exceeded">오늘은 콕 찌르기를 다 썼어요.</string>
<string name="friend_complete">찌르기 답장으로\n%s님과 친구가 되었어요!</string>
<string name="anonymous_to_friend">%s님과\n%s 되었어요!</string>

<!-- 찌르기 알림 -->
<string name="poke_notification_title">찌르기 알림</string>
Expand Down

0 comments on commit 3ea8480

Please sign in to comment.