Skip to content

Commit

Permalink
[Merge] feature/refactor-departure-set-enum -> develop
Browse files Browse the repository at this point in the history
[REFACTOR] 출발지 모드 세팅 / Enum Class 활용
  • Loading branch information
unam98 authored Nov 9, 2023
2 parents c8a8fdb + 5eabffe commit 66c20f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ import com.runnect.runnect.presentation.MainActivity
import com.runnect.runnect.presentation.countdown.CountDownActivity
import com.runnect.runnect.presentation.login.LoginActivity
import com.runnect.runnect.presentation.state.UiState
import com.runnect.runnect.util.multipart.ContentUriRequestBody
import com.runnect.runnect.util.DepartureSetMode
import com.runnect.runnect.util.extension.setActivityDialog
import com.runnect.runnect.util.multipart.ContentUriRequestBody
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.custom_dialog_make_course.view.btn_run
import kotlinx.android.synthetic.main.custom_dialog_make_course.view.btn_storage
Expand Down Expand Up @@ -135,17 +136,21 @@ class DrawActivity :
setLocationChangedListener()
setCameraFinishedListener()
}

private fun initMode() {
when (searchResult.mode) {
"searchLocation" -> initSearchLocationMode()
"currentLocation" -> initCurrentLocationMode()
"customLocation" -> initCustomLocationMode()
DepartureSetMode.SEARCH.mode -> initSearchLocationMode()
DepartureSetMode.CURRENT.mode -> initCurrentLocationMode()
DepartureSetMode.CUSTOM.mode -> initCustomLocationMode()
else -> throw IllegalArgumentException("Unknown mode: ${searchResult.mode}")
}
}


private fun initSearchLocationMode() {
isSearchLocationMode = true

with(binding){
with(binding) {
tvGuide.isVisible = false
btnDraw.text = CREATE_COURSE
}
Expand All @@ -168,6 +173,7 @@ class DrawActivity :
}
}
}

private fun initCurrentLocationMode() {
isCurrentLocationMode = true
isMarkerAvailable = true
Expand All @@ -180,6 +186,7 @@ class DrawActivity :
hideDeparture()
showDrawCourse()
}

private fun initCustomLocationMode() {
isCustomLocationMode = true

Expand Down Expand Up @@ -245,6 +252,7 @@ class DrawActivity :
val cameraPosition = naverMap.cameraPosition
return cameraPosition.target // 중심 좌표
}

private fun setLocationChangedListener() {
naverMap.addOnLocationChangeListener { location ->
currentLocation = LatLng(location.latitude, location.longitude)
Expand All @@ -256,7 +264,7 @@ class DrawActivity :
//같은 scope 안에 넣었으니 setDepartureLatLng 다음에 drawCourse가 실행되는 것이 보장됨
//이때 isFirstInit의 초기값을 true로 줘서 최초 1회는 실행되게 하고 이후 drawCourse 내에서 isFirstInit 값을 false로 바꿔줌
//뒤의 조건을 안 달아주면 다른 mode에서는 버튼을 클릭하기도 전에 drawCourse()가 돌 거라 안 됨.
if(isFirstInit && isCurrentLocationMode){
if (isFirstInit && isCurrentLocationMode) {
drawCourse(departureLatLng = departureLatLng)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.runnect.runnect.util

enum class DepartureSetMode(val mode: String) {
SEARCH("searchLocation"),
CURRENT("currentLocation"),
CUSTOM("customLocation")
}

0 comments on commit 66c20f1

Please sign in to comment.