Skip to content

Commit

Permalink
[MOD] #258 SearchResultEntity에서 mode 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
unam98 committed Nov 7, 2023
1 parent cdf5b8c commit f14f3b3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ data class SearchResultEntity(
val fullAddress: String,
val name: String,
val locationLatLng: LatLng?,
val mode: String
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ import com.runnect.runnect.databinding.BottomsheetRequireCourseNameBinding
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.search.SearchActivity.Companion.EXTRA_DEPARTURE_SET_MODE
import com.runnect.runnect.presentation.state.UiState
import com.runnect.runnect.util.multipart.ContentUriRequestBody
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 @@ -77,6 +78,7 @@ class DrawActivity :
private lateinit var animDown: Animation
private lateinit var animUp: Animation
private lateinit var searchResult: SearchResultEntity
private lateinit var departureSetMode: String
private lateinit var captureUri: Uri

private val coords = mutableListOf<LatLng>()
Expand Down Expand Up @@ -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")
departureSetMode = intent.getStringExtra(EXTRA_DEPARTURE_SET_MODE)
?: throw Exception("unknown-departure-set-mode")
}

private fun initMapView() {
Expand All @@ -135,17 +140,19 @@ class DrawActivity :
setLocationChangedListener()
setCameraFinishedListener()
}

private fun initMode() {
when (searchResult.mode) {
when (departureSetMode) {
"searchLocation" -> initSearchLocationMode()
"currentLocation" -> initCurrentLocationMode()
"customLocation" -> initCustomLocationMode()
}
}

private fun initSearchLocationMode() {
isSearchLocationMode = true

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

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

private fun initCustomLocationMode() {
isCustomLocationMode = true

Expand Down Expand Up @@ -245,6 +254,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 +266,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
Expand Up @@ -81,15 +81,6 @@ class SearchActivity :
binding.recyclerViewSearch.adapter = searchAdapter
}

override fun selectItem(item: SearchResultEntity) {
startActivity(
Intent(this, DrawActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
putExtra(EXTRA_SEARCH_RESULT, item) //mode == "searchLocation"
}
)
}

private fun showEmptyView() {
with(binding) {
ivNoSearchResult.isVisible = true
Expand Down Expand Up @@ -187,26 +178,38 @@ class SearchActivity :
}
}

fun startCurrentLocation() {
override fun startSearchLocation(item: SearchResultEntity) {
startActivity(
Intent(this, DrawActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
putExtra(EXTRA_SEARCH_RESULT, item)
putExtra(EXTRA_DEPARTURE_SET_MODE, "searchLocation")
}
)
}

private fun startCurrentLocation() {
startActivity(
Intent(this, DrawActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
putExtra(
EXTRA_SEARCH_RESULT,
SearchResultEntity(fullAddress = "", name = "", locationLatLng = null, mode = "currentLocation")
SearchResultEntity(fullAddress = "", name = "", locationLatLng = null)
)
putExtra(EXTRA_DEPARTURE_SET_MODE, "currentLocation")
}
)
}

fun startCustomLocation() {
private fun startCustomLocation() {
startActivity(
Intent(this, DrawActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
putExtra(
EXTRA_SEARCH_RESULT,
SearchResultEntity(fullAddress = "", name = "", locationLatLng = null, mode = "customLocation")
SearchResultEntity(fullAddress = "", name = "", locationLatLng = null)
)
putExtra(EXTRA_DEPARTURE_SET_MODE, "customLocation")
}
)
}
Expand All @@ -228,6 +231,7 @@ class SearchActivity :

companion object {
const val EXTRA_SEARCH_RESULT = "searchResult"
const val EXTRA_DEPARTURE_SET_MODE = "departureSetMode"
}

}

0 comments on commit f14f3b3

Please sign in to comment.