Skip to content
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

Merged
merged 19 commits into from
Jul 4, 2023
Merged

Conversation

librarywon
Copy link
Contributor

@librarywon librarywon commented Jul 3, 2023

이슈 코드

📸 스크린샷

스크린샷 2023-07-03 오후 7 56 19

🍀 관련 이슈

  • 아이템이 3개 밖에 불러와지지 않는 문제가 있음 -> 해결

@librarywon librarywon added 🦈서재원 서재원이 했다 ✨ Feature 기능 개발 labels Jul 3, 2023
@librarywon librarywon requested a review from a team as a code owner July 3, 2023 10:57
@librarywon librarywon self-assigned this Jul 3, 2023
Comment on lines 53 to 108
}
}

override suspend fun getPhotos(): Result<PhotoListResponse> {
TODO("Not yet implemented")
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MyPage관련 Repository Interface를 따로 작성하는 것이 좋아보입니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인하였고 반영하였습니다 감사합니다!

Comment on lines +20 to +24
private var myPageAdapter: MyPageAdapter? = null

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onDestroyView에서 null로 다시 리소스 해제를 해주시면 좋을 것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다 👍

Comment on lines 32 to 52
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()
}
Copy link
Member

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()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영하였습니다!!

Comment on lines 66 to 72

myPageAdapter = MyPageAdapter(ItemDiffCallback(
onItemsTheSame = { old, new -> old == new },
onContentsTheSame = { old, new -> old == new }
)) { position ->
val photoList = viewModel.photoList.value
if (photoList is MyPageInfoState.SuccessPhotos) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ItemDiffCallback 을 Adapter의 생성자로 외부에서 주입받는 것이 아닌 super의 생성자에서 생성해주어도 괜찮을 것 같습니다.
@l2hyunwoo 좋은 방법 맞을까요?

Copy link
Member

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()
}
}
Copy link
Member

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 블럭 내에 있는게 좋을까요? 일단 지금은 중복되어있어서 하나는 제거해야하는데 뭐가 좋은지 잘모르겠습니다

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

init {
        getMyPageInfo()
    }

를 제거하였습니다 !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호 이유가 무엇인가요!?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오류를 수정하던 도중 현우형이 지우셔서 이유를 물어보겠습니다!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일단 레이아웃 에러 해결 도중에 지운거여서 별 이유는 딱히 없습니다.

Comment on lines 4 to 12
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
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mapping되는 부분에서 보니 nonull한 타입으로 반환됩니다. nullable한 타입은 변경해주시면 감사하겠습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 확인하였습니다!

Comment on lines 110 to 131
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로직 정말 잘 구현했어 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다 ㅎㅎ 😄 뿌듯

Comment on lines 31 to 37
//Empty List
// myPageInfoRepository.getMyPageEmtpyInfo()
// .onSuccess {
// _myPageUserInfo.value = MyPageInfoState.SuccessPhotos(it.toMyPageInfo())
// }.onFailure {
// _myPageUserInfo.value = MyPageInfoState.Error(it)
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주석 표기된건 필요 없으면 바로 삭제해줘. 나중에 이게 왜 주석친지 모르는 경우도 발생할 수 있어.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 지우도록 하겠습니다!

Comment on lines 120 to 121
android:layout_width="180dp"
android:layout_height="180dp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고정 dp, 고정 비율이면 dimension_ratio 였나 그거 쓰면 될 것 같음

Copy link
Member

@l2hyunwoo l2hyunwoo left a 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 {
)
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빈줄

tvMypageFeedEmpty.visibility = View.VISIBLE
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빈줄

Comment on lines 67 to 68
ivMypageFeedEmpty.visibility = View.GONE
tvMypageFeedEmpty.visibility = View.GONE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isVisible = false 뭐 이런식으로 가도 되지 않을까 싶은데...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

진행해보겠습니다!

Copy link
Contributor Author

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

Comment on lines 66 to 72

myPageAdapter = MyPageAdapter(ItemDiffCallback(
onItemsTheSame = { old, new -> old == new },
onContentsTheSame = { old, new -> old == new }
)) { position ->
val photoList = viewModel.photoList.value
if (photoList is MyPageInfoState.SuccessPhotos) {
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

Comment on lines 5 to 7
sealed class MyPageInfoState {
object Uninitialized : MyPageInfoState()
object Loading : MyPageInfoState()
data class SuccessPhotos(val data: MyPageInfo) : MyPageInfoState()
data class Error(val error: Throwable) : MyPageInfoState()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

의진이거 보고 참고 한 것 같은데 성공했을때의 data class 네이밍이 저게 들어가는게 맞나 다시 한번 생각해봐. 그리고 이 구조를 사용하는게 좋은지도 생각을 해보고. 왜 내가 Ui State를 이렇게 사용하고 유지보수할 때 어떤 장점이 생기는지에 대해 생각을 해보면 좋을 것 같아

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

참고해서 진행하다보니 간과하고 지나간 면이 있었던 것 같습니다. Ui State에 대해서 더 고민해보겠습니다!

Comment on lines 8 to 30
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
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core common 모듈로 빼자

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 core/common/view/ViewExt에 추가하겠습니다!

Copy link
Member

@kez-lab kez-lab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🥇

Copy link
Member

@l2hyunwoo l2hyunwoo left a 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

구두로 리뷰함

Comment on lines 113 to 112


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빈줄!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제거하였습니다!

Comment on lines 22 to 23
) : ListAdapter<Any, RecyclerView.ViewHolder>(
ItemDiffCallback<Any>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것도 MyPageInfoState로!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변경하였습니다!

@librarywon librarywon merged commit 8d3f365 into develop Jul 4, 2023
1 check passed
@librarywon librarywon deleted the feature/mypage branch July 4, 2023 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature 기능 개발 🦈서재원 서재원이 했다
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature/mypage]: mypage 기능 구현 및 UI 구현
3 participants