-
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
[REFACTOR] 출발지 모드 세팅 / SearchResultEntity에서 mode 제거 및 리팩토링 #274
base: develop
Are you sure you want to change the base?
Conversation
SearchActivity에서 유사한 기능을 수행하는 함수들과 이름에 통일성을 부여하기 위함
위의 글들 외에도 DAO, DTO, VO, Entity의 차이점이 무엇인지 정리한 글이 많더라구요! 참고하면 좋을 거 같습니다! |
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.
디벨롭 브랜치와의 충돌 해결 부탁드립니다! :)
@@ -108,7 +110,10 @@ class DrawActivity : | |||
|
|||
private fun getSearchIntent() { | |||
searchResult = | |||
intent.getParcelableExtra(EXTRA_SEARCH_RESULT) ?: throw Exception("데이터가 존재하지 않습니다.") | |||
intent.getParcelableExtra(EXTRA_SEARCH_RESULT) | |||
?: throw Exception("unknown-search-result") |
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.
제가 pr 올린 코드에 아래 확장함수들 추가해뒀어요!
/** Retrieve parcelable extra data from the intent and support app compatibility */
inline fun <reified T : Parcelable> Intent.getCompatibleParcelableExtra(key: String): T? = when {
SDK_INT >= TIRAMISU -> getParcelableExtra(key, T::class.java)
else -> getParcelableExtra(key) as? T
}
inline fun <reified T : Serializable> Intent.getCompatibleSerializableExtra(key: String): T? = when {
SDK_INT >= TIRAMISU -> getSerializableExtra(key, T::class.java)
else -> getSerializableExtra(key) as? T
}
SDK 버전에 따라 다르게 대응해주는 게 좋을 거 같습니다!
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.
혹시 여기서 던진 Exception은 어디서 예외처리 해주는지 알 수 있을까요?
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.
위에 가이드 주신 확장함수 둘 다 SDK_INT >= TIRAMISU로 돼있는데 sdk 버전에 따라 분기 처리가 된 것이 맞을까요?
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.
예외 시 특정 처리를 해주는 코드는 작성하지 않았고 단순히 LogCat에서 로그 확인 목적으로만 저렇게 작성했습니다! 혹시 문제 되는 부분이 있을까요? (몰라서 물어보는 것)
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.
throw로 강제 Exception을 던지게 되면 런타임 에러가 발생하지 않을까 싶은데요!
여기서 던진 예외를 try-catch문이나 runCatching 등으로 받아서 따로 처리해주는 로직이 필요할 거 같습니다!
private fun initMode() { | ||
when (searchResult.mode) { | ||
when (departureSetMode) { | ||
"searchLocation" -> initSearchLocationMode() | ||
"currentLocation" -> initCurrentLocationMode() | ||
"customLocation" -> initCustomLocationMode() | ||
} |
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.
현재 디벨롭에 머지된 코드와 충돌되는 부분인 거 같아요! 충돌 해결하고 다시 푸시 부탁드립니다 :)
SearchResultEntity(fullAddress = "", name = "", locationLatLng = null, mode = "currentLocation") | ||
) | ||
putExtra(EXTRA_SEARCH_RESULT, item) | ||
putExtra(EXTRA_DEPARTURE_SET_MODE, mode) | ||
} | ||
) |
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.
DrawActivity
로 화면 전환이 이루어지는 코드이므로
navigateToCourseDrawScreen
또는 navigateToCourseDrawScreenWinthBundle
이런 함수명은 어떨지 제안해봅니다!
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.
반영했습니다!
|
||
private fun startCustomLocation() { | ||
val emptyItem = SearchResultEntity(fullAddress = "", name = "", locationLatLng = null) | ||
setDeparture("customLocation", emptyItem) |
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.
현위치에서 시작하는 currentLocation 모드, 출발지를 지도 상에서 선택하는 customLocation 모드에서도
SearchResultEntity 데이터 클래스를 넘겨줘야 하는 이유가 있을까요??
private fun navigateToCourseDrawScreen(mode: String, searchResult: SearchResultEntity? = null) {
startActivity(
Intent(this, DrawActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
putExtra(EXTRA_DEPARTURE_SET_MODE, mode)
putExtra(EXTRA_SEARCH_RESULT, searchResult)
}
)
}
// 검색 모드
navigateToCourseDrawScreen(mode = DepartureMode.SEARCH, searchResult = SearchResultEntity)
// 현위치 모드
navigateToCourseDrawScreen(mode = DepartureMode.CURRENT)
// 커스텀 위치 모드
navigateToCourseDrawScreen(mode = DepartureMode.CUSTOM)
이런 식으로 현위치 모드, 커스텀 위치 모드에서는 default arguments 이용해서 SearchResultEntity를 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.
하나의 함수로 묶어서 중복 코드를 줄이는 것에만 신경을 썼었는데 말씀해주신 방향이 깔끔하겠네요. 반영하겠습니다! 땡큐!
9538b84
to
55b4ded
Compare
fb1f98f
to
f8525c2
Compare
📌 개요
closed #258
매직 리터럴은 #272 PR merge 후 Enum Class를 활용하여 제거해줄 예정입니다!
✨ 작업 내용
✨ PR 포인트
📸 스크린샷/동영상