@@ -92,7 +92,6 @@ class DrawActivity :
9292
9393 var isFirstInit: Boolean = true
9494
95- private lateinit var bottomSheetBinding: BottomsheetRequireCourseNameBinding // Bottom Sheet 바인딩
9695 override fun onCreate (savedInstanceState : Bundle ? ) {
9796 super .onCreate(savedInstanceState)
9897
@@ -287,7 +286,7 @@ class DrawActivity :
287286 }
288287
289288 private fun requireCourseNameDialog (): BottomSheetDialog {
290- bottomSheetBinding = BottomsheetRequireCourseNameBinding .inflate(layoutInflater)
289+ val bottomSheetBinding = BottomsheetRequireCourseNameBinding .inflate(layoutInflater)
291290 val bottomSheetView = bottomSheetBinding.root
292291 val etCourseName = bottomSheetBinding.etCourseName
293292 val btnCreateCourse = bottomSheetBinding.btnCreateCourse
@@ -449,21 +448,28 @@ class DrawActivity :
449448
450449 with (dialogLayout) {
451450 this .btn_run.setOnClickListener {
452- val intent = Intent (this @DrawActivity, CountDownActivity ::class .java).apply {
453- putExtra(
454- EXTRA_COURSE_DATA , CourseData (
455- courseId = viewModel.uploadResult.value!! .data.id,
456- publicCourseId = null ,
457- touchList = touchList,
458- startLatLng = departureLatLng,
459- departure = viewModel.departureName.value!! ,
460- distance = viewModel.distanceSum.value!! ,
461- image = captureUri.toString(),
462- dataFrom = " fromDrawCourse"
463- )
464- )
451+ val courseData = CourseData (
452+ courseId = viewModel.uploadResult.value?.data?.id,
453+ publicCourseId = null ,
454+ touchList = touchList,
455+ startLatLng = departureLatLng,
456+ departure = viewModel.departureName.value,
457+ distance = viewModel.distanceSum.value,
458+ image = captureUri.toString(),
459+ dataFrom = " fromDrawCourse"
460+ )
461+ if (courseData.courseId == null || courseData.departure == null || courseData.distance == null ) {
462+ Toast .makeText(
463+ this @DrawActivity,
464+ ERROR_COURSE_NULL ,
465+ Toast .LENGTH_LONG
466+ ).show()
467+ } else {
468+ val intent = Intent (this @DrawActivity, CountDownActivity ::class .java).apply {
469+ putExtra(EXTRA_COURSE_DATA , courseData)
470+ }
471+ startActivity(intent)
465472 }
466- startActivity(intent)
467473 dialog.dismiss()
468474 }
469475
@@ -746,5 +752,7 @@ class DrawActivity :
746752 const val EXTRA_FRAGMENT_REPLACEMENT_DIRECTION = " fragmentReplacementDirection"
747753 const val CUSTOM_DEPARTURE = " 내가 설정한 출발지"
748754 const val NOTIFY_LIMIT_MARKER_NUM = " 마커는 20개까지 생성 가능합니다"
755+
756+ const val ERROR_COURSE_NULL = " Error: Course data is incomplete"
749757 }
750758}
0 commit comments