-
Notifications
You must be signed in to change notification settings - Fork 1
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/myPage] myPage 진행상황 공유 #57
Conversation
} | ||
} | ||
|
||
override suspend fun getPhotos(): Result<PhotoListResponse> { | ||
TODO("Not yet implemented") | ||
} | ||
} |
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.
MyPage관련 Repository Interface를 따로 작성하는 것이 좋아보입니다.
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.
확인하였고 반영하였습니다 감사합니다!
private var myPageAdapter: MyPageAdapter? = null | ||
|
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.
onDestroyView에서 null로 다시 리소스 해제를 해주시면 좋을 것 같습니다.
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.
감사합니다 👍
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
initObserver() | ||
initRecyclerView() | ||
} | ||
|
||
private fun initObserver() { | ||
viewModel.photoList.observe(viewLifecycleOwner) { myPageInfoState -> | ||
when (myPageInfoState) { | ||
is MyPageInfoState.Uninitialized -> { | ||
viewModel.getMyPageInfo() | ||
} |
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.
Uninitialized 내에서 initRecyclerView를 선언하는 것이 좋아보입니다.
순서는
initRecyclerView()
viewModel.getMyPageInfo()
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.
반영하였습니다!!
|
||
myPageAdapter = MyPageAdapter(ItemDiffCallback( | ||
onItemsTheSame = { old, new -> old == new }, | ||
onContentsTheSame = { old, new -> old == new } | ||
)) { position -> | ||
val photoList = viewModel.photoList.value | ||
if (photoList is MyPageInfoState.SuccessPhotos) { |
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.
ItemDiffCallback 을 Adapter의 생성자로 외부에서 주입받는 것이 아닌 super의 생성자에서 생성해주어도 괜찮을 것 같습니다.
@l2hyunwoo 좋은 방법 맞을까요?
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.
네 그게 좀더 가독성에 좋을 것 같습니당. @KwakEuiJin cc. @librarywon
|
||
init { | ||
getMyPageInfo() | ||
} | ||
} |
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.
@l2hyunwoo
Fragment단의 state 구독의 Uninitiialize 에서 getMyPageInfo를 부르는게 좋을까요? 아니면 init 블럭 내에 있는게 좋을까요? 일단 지금은 중복되어있어서 하나는 제거해야하는데 뭐가 좋은지 잘모르겠습니다
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.
init {
getMyPageInfo()
}
를 제거하였습니다 !
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.
오호 이유가 무엇인가요!?
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.
오류를 수정하던 도중 현우형이 지우셔서 이유를 물어보겠습니다!
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.
일단 레이아웃 에러 해결 도중에 지운거여서 별 이유는 딱히 없습니다.
data class MyPageInfo( | ||
val realName: String, | ||
val photoCount: Int, | ||
val photos: List<Photo>? = null | ||
) { | ||
data class Photo( | ||
val photoId: Long? = null, | ||
val photoUrl: String? = null | ||
) |
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.
mapping되는 부분에서 보니 nonull한 타입으로 반환됩니다. nullable한 타입은 변경해주시면 감사하겠습니다.
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.
네 확인하였습니다!
val fullText = getString(R.string.mypage_picture_count, myPageInfoDataPhotoCount) | ||
val coloredText = myPageInfoDataPhotoCount.toString() | ||
|
||
val spannableStringBuilder = SpannableStringBuilder(fullText) | ||
val start = fullText.indexOf(coloredText) | ||
val end = start + coloredText.length | ||
|
||
if (start != -1) { | ||
spannableStringBuilder.setSpan( | ||
ForegroundColorSpan( | ||
ContextCompat.getColor( | ||
requireContext(), | ||
R.color.pophory_purple | ||
) | ||
), | ||
start, | ||
end, | ||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE | ||
) | ||
} | ||
|
||
binding.tvMypagePictureCount.text = spannableStringBuilder |
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.
로직 정말 잘 구현했어 👍🏻
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.
감사합니다 ㅎㅎ 😄 뿌듯
//Empty List | ||
// myPageInfoRepository.getMyPageEmtpyInfo() | ||
// .onSuccess { | ||
// _myPageUserInfo.value = MyPageInfoState.SuccessPhotos(it.toMyPageInfo()) | ||
// }.onFailure { | ||
// _myPageUserInfo.value = MyPageInfoState.Error(it) | ||
// } |
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.
주석 표기된건 필요 없으면 바로 삭제해줘. 나중에 이게 왜 주석친지 모르는 경우도 발생할 수 있어.
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.
넵 지우도록 하겠습니다!
android:layout_width="180dp" | ||
android:layout_height="180dp" |
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.
고정 dp, 고정 비율이면 dimension_ratio 였나 그거 쓰면 될 것 같음
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.
추가 리뷰
@@ -41,4 +42,5 @@ class FakePhotoRepository : PhotoRepository { | |||
) | |||
} | |||
} | |||
|
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.
빈줄
tvMypageFeedEmpty.visibility = View.VISIBLE | ||
} | ||
} | ||
|
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.
빈줄
ivMypageFeedEmpty.visibility = View.GONE | ||
tvMypageFeedEmpty.visibility = View.GONE |
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.
isVisible = false 뭐 이런식으로 가도 되지 않을까 싶은데...?
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.
진행해보겠습니다!
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.
이렇게 개선했습니다!
val isNotEmpty = myPageInfoState.data.photos.isNotEmpty()
if(isNotEmpty) {
myPageAdapter?.submitList(myPageInfoState.data.photos)
}
rvMypage.isVisible = isNotEmpty
ivMypageFeedEmpty.isVisible = !isNotEmpty
tvMypageFeedEmpty.isVisible = !isNotEmpty
|
||
myPageAdapter = MyPageAdapter(ItemDiffCallback( | ||
onItemsTheSame = { old, new -> old == new }, | ||
onContentsTheSame = { old, new -> old == new } | ||
)) { position -> | ||
val photoList = viewModel.photoList.value | ||
if (photoList is MyPageInfoState.SuccessPhotos) { |
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.
네 그게 좀더 가독성에 좋을 것 같습니당. @KwakEuiJin cc. @librarywon
if (photoList is MyPageInfoState.SuccessPhotos) { | ||
val itemId = photoList.data.photos.getOrNull(position)?.photoId | ||
toast(itemId.toString()); | ||
//TODO intent photo_detail activity |
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.
👍🏻
sealed class MyPageInfoState { | ||
object Uninitialized : MyPageInfoState() | ||
object Loading : MyPageInfoState() | ||
data class SuccessPhotos(val data: MyPageInfo) : MyPageInfoState() | ||
data class Error(val error: Throwable) : MyPageInfoState() |
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.
의진이거 보고 참고 한 것 같은데 성공했을때의 data class 네이밍이 저게 들어가는게 맞나 다시 한번 생각해봐. 그리고 이 구조를 사용하는게 좋은지도 생각을 해보고. 왜 내가 Ui State를 이렇게 사용하고 유지보수할 때 어떤 장점이 생기는지에 대해 생각을 해보면 좋을 것 같아
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.
참고해서 진행하다보니 간과하고 지나간 면이 있었던 것 같습니다. Ui State에 대해서 더 고민해보겠습니다!
class GridSpacingItemDecoration(private val spanCount: Int, private val spacing: Int, private val includeEdge: Boolean) : ItemDecoration() { | ||
|
||
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: State) { | ||
val position = parent.getChildAdapterPosition(view) // item position | ||
val column = position % spanCount // item column | ||
|
||
if (includeEdge) { | ||
outRect.left = spacing - column * spacing / spanCount // spacing - column * ((1f / spanCount) * spacing) | ||
outRect.right = (column + 1) * spacing / spanCount // (column + 1) * ((1f / spanCount) * spacing) | ||
|
||
if (position < spanCount) { // top edge | ||
outRect.top = spacing | ||
} | ||
outRect.bottom = spacing // item bottom | ||
} else { | ||
outRect.left = column * spacing / spanCount // column * ((1f / spanCount) * spacing) | ||
outRect.right = spacing - (column + 1) * spacing / spanCount // spacing - (column + 1) * ((1f / spanCount) * spacing) | ||
if (position >= spanCount) { | ||
outRect.top = spacing // item top | ||
} | ||
} | ||
} | ||
} |
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.
core common 모듈로 빼자
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.
넵 core/common/view/ViewExt에 추가하겠습니다!
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.
LGTM 🥇
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.
한번만...더 수정해줘!
|
||
val isNotEmpty = myPageInfoState.data.photos.isNotEmpty() | ||
val isNotEmpty = myPageInfoState.data.photos.isNotEmpty() | ||
val myPageInfoData = arrayListOf<Any>().apply { |
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.
구두로 리뷰함
|
||
|
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.
빈줄!
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.
제거하였습니다!
) : ListAdapter<Any, RecyclerView.ViewHolder>( | ||
ItemDiffCallback<Any>( |
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.
이것도 MyPageInfoState로!
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.
변경하였습니다!
5ad0c76
to
f916058
Compare
이슈 코드
📸 스크린샷
🍀 관련 이슈