-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature/#725] poke ananymous #732
Changes from 16 commits
52117e4
1609210
d9d401a
3212487
6674c3c
401898d
c5fae64
3ea8480
3a2c1ab
3a5acce
7a1564a
6010b94
b8bea26
f47ddea
d8a7f2e
b2f908e
2536869
885f815
dcf93fb
d2a0421
1d43000
4b0d31d
b30a930
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,16 +24,21 @@ | |
*/ | ||
package org.sopt.official.feature.poke.friend.detail | ||
|
||
import android.animation.Animator | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.os.Handler | ||
import android.os.Looper | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.lifecycle.ViewModelProvider | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import coil.load | ||
import coil.transform.CircleCropTransformation | ||
import com.google.android.material.bottomsheet.BottomSheetBehavior | ||
import com.google.android.material.bottomsheet.BottomSheetDialog | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
|
@@ -58,6 +63,7 @@ import org.sopt.official.feature.poke.user.ItemDecorationDivider | |
import org.sopt.official.feature.poke.user.PokeUserListAdapter | ||
import org.sopt.official.feature.poke.user.PokeUserListClickListener | ||
import org.sopt.official.feature.poke.user.PokeUserListItemViewType | ||
import org.sopt.official.feature.poke.util.setRelationStrokeColor | ||
import org.sopt.official.feature.poke.util.showPokeToast | ||
|
||
@AndroidEntryPoint | ||
|
@@ -111,11 +117,52 @@ class FriendListDetailBottomSheetFragment : BottomSheetDialogFragment() { | |
) | ||
} | ||
|
||
initLottieListener() | ||
initRecyclerView() | ||
launchPokeMessageListUiStateFlow() | ||
launchPokeUserUiStateFlow() | ||
} | ||
|
||
private fun initLottieListener() { | ||
with(binding) { | ||
animationFriendViewLottie.addAnimatorListener( | ||
object : Animator.AnimatorListener { | ||
override fun onAnimationStart(animation: Animator) {} | ||
|
||
override fun onAnimationEnd(animation: Animator) { | ||
if (viewModel.anonymousFriend.value != null) { // 천생연분 -> 정체 공개 | ||
// 로티 | ||
layoutAnonymousFriendLottie.visibility = View.GONE | ||
layoutAnonymousFriendOpen.visibility = View.VISIBLE | ||
|
||
val anonymousFriend = viewModel.anonymousFriend.value | ||
anonymousFriend?.let { | ||
tvAnonymousFreindName.text = getString(R.string.anonymous_user_identity, it.anonymousName) | ||
tvAnonymousFreindInfo.text = getString(R.string.anonymous_user_info, it.generation, it.part, it.name) | ||
imgAnonymousFriendOpen.load(it.profileImage.ifEmpty { R.drawable.ic_empty_profile }) { | ||
transformations(CircleCropTransformation()) | ||
} | ||
|
||
imgAnonymousFriendOpenOutline.setRelationStrokeColor(it.mutualRelationMessage) | ||
} | ||
|
||
Handler(Looper.getMainLooper()).postDelayed({ | ||
layoutAnonymousFriendOpen.visibility = View.GONE | ||
viewModel.setAnonymousFriend(null) | ||
}, 2000) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 또 막 중복해서 하면 취소하고 해야돼서 그래가지고 안한건가...근데 그렇게 해도 중복해서 실행된다면(따닥) 취소해야하는건 매한가지일텐데 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 음... 둘의 차이점을 찾아보니 lifecycleScope를 쓰는게 더 좋을 것 같습니다! 수정하도록 하겠습니다 :) |
||
} else { | ||
layoutAnonymousFriendLottie.visibility = View.GONE | ||
} | ||
} | ||
|
||
override fun onAnimationCancel(animation: Animator) {} | ||
|
||
override fun onAnimationRepeat(animation: Animator) {} | ||
}, | ||
) | ||
} | ||
} | ||
|
||
private fun initRecyclerView() { | ||
binding.includeFriendListBlock.apply { | ||
pokeFriendType?.let { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,19 @@ | |
*/ | ||
package org.sopt.official.feature.poke.friend.summary | ||
|
||
import android.animation.Animator | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.os.Handler | ||
import android.os.Looper | ||
import android.view.View | ||
import androidx.activity.viewModels | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.lifecycle.lifecycleScope | ||
import coil.load | ||
import coil.transform.CircleCropTransformation | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import java.io.Serializable | ||
import javax.inject.Inject | ||
|
@@ -57,6 +63,7 @@ import org.sopt.official.feature.poke.user.ItemDecorationDivider | |
import org.sopt.official.feature.poke.user.PokeUserListAdapter | ||
import org.sopt.official.feature.poke.user.PokeUserListClickListener | ||
import org.sopt.official.feature.poke.user.PokeUserListItemViewType | ||
import org.sopt.official.feature.poke.util.setRelationStrokeColor | ||
import org.sopt.official.feature.poke.util.showPokeToast | ||
|
||
@AndroidEntryPoint | ||
|
@@ -89,6 +96,7 @@ class FriendListSummaryActivity : AppCompatActivity() { | |
setContentView(binding.root) | ||
|
||
initAppBar() | ||
initLottieListener() | ||
initFriendListBlock() | ||
launchFriendListSummaryUiStateFlow() | ||
launchPokeUserUiStateFlow() | ||
|
@@ -106,6 +114,46 @@ class FriendListSummaryActivity : AppCompatActivity() { | |
} | ||
} | ||
|
||
private fun initLottieListener() { | ||
with(binding) { | ||
animationFriendViewLottie.addAnimatorListener( | ||
object : Animator.AnimatorListener { | ||
override fun onAnimationStart(animation: Animator) {} | ||
|
||
override fun onAnimationEnd(animation: Animator) { | ||
if (viewModel.anonymousFriend.value != null) { // 천생연분 -> 정체 공개 | ||
// 로티 | ||
layoutAnonymousFriendLottie.visibility = View.GONE | ||
layoutAnonymousFriendOpen.visibility = View.VISIBLE | ||
|
||
val anonymousFriend = viewModel.anonymousFriend.value | ||
anonymousFriend?.let { | ||
tvAnonymousFreindName.text = getString(R.string.anonymous_user_identity, it.anonymousName) | ||
tvAnonymousFreindInfo.text = getString(R.string.anonymous_user_info, it.generation, it.part, it.name) | ||
imgAnonymousFriendOpen.load(it.profileImage.ifEmpty { R.drawable.ic_empty_profile }) { | ||
transformations(CircleCropTransformation()) | ||
} | ||
|
||
imgAnonymousFriendOpenOutline.setRelationStrokeColor(it.mutualRelationMessage) | ||
} | ||
|
||
Handler(Looper.getMainLooper()).postDelayed({ | ||
layoutAnonymousFriendOpen.visibility = View.GONE | ||
viewModel.setAnonymousFriend(null) | ||
}, 2000) | ||
} else { | ||
layoutAnonymousFriendLottie.visibility = View.GONE | ||
} | ||
} | ||
|
||
override fun onAnimationCancel(animation: Animator) {} | ||
|
||
override fun onAnimationRepeat(animation: Animator) {} | ||
}, | ||
) | ||
} | ||
} | ||
|
||
private fun initFriendListBlock() { | ||
binding.swipeRefreshLayout.setOnRefreshListener { | ||
viewModel.getFriendListSummary() | ||
|
@@ -283,7 +331,29 @@ class FriendListSummaryActivity : AppCompatActivity() { | |
is UiState.Success<PokeUser> -> { | ||
messageListBottomSheet?.dismiss() | ||
viewModel.getFriendListSummary() | ||
showPokeToast(getString(R.string.toast_poke_user_success)) | ||
|
||
if ((it.data.pokeNum == 5 || it.data.pokeNum == 6) && it.data.isAnonymous) { // 익명 베스트 프랜드 + 힌트 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Magic Number 지양해주세요, 그리고 이 조건이 무슨 조건인지는 주석만으로는 파악하기 힘들 수 있으니 조건 자체를 property나 함수로 빼는걸 권장합니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 알겠습니다. 함수로 빼서 진행하도록 하겠습니다! |
||
with(binding) { | ||
layoutAnonymousFriendLottie.visibility = View.VISIBLE | ||
tvFreindLottie.text = getString(R.string.anonymous_to_friend, it.data.anonymousName, "단짝친구가") | ||
tvFreindLottieHint.text = | ||
getString(R.string.anonymous_user_info_part, it.data.generation, it.data.part) | ||
animationFriendViewLottie.apply { | ||
setAnimation(R.raw.friendtobestfriend) | ||
}.playAnimation() | ||
} | ||
} else if ((it.data.pokeNum == 11 || it.data.pokeNum == 12) && it.data.isAnonymous) { // 익명 소울메이트 + 정체 공개 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이것도 마찬가지 |
||
viewModel.setAnonymousFriend(it.data) | ||
with(binding) { | ||
layoutAnonymousFriendLottie.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)) | ||
} | ||
} | ||
|
||
is UiState.ApiError -> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 확장함수 만들어서
View.doOnAnimationEnd { }
같은걸로 사용하면 좋을듯There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 이건 생각 못해봤는데 좋을 것 같네요!! 반영하겠습니다 :)