diff --git a/app/src/main/java/com/eatssu/android/ui/review/list/ReviewActivity.kt b/app/src/main/java/com/eatssu/android/ui/review/list/ReviewActivity.kt index 31317994..ea29c090 100644 --- a/app/src/main/java/com/eatssu/android/ui/review/list/ReviewActivity.kt +++ b/app/src/main/java/com/eatssu/android/ui/review/list/ReviewActivity.kt @@ -39,7 +39,15 @@ class ReviewActivity : lodeData() bindData() setClickListener() + } + + override fun onResume() { + super.onResume() + + //todo 이거 안하면 바로바로 갱신이 안되는디 + lodeData() + bindData() } @@ -58,53 +66,27 @@ class ReviewActivity : reviewViewModel.loadReview(menuType, itemId) } - private fun setClickListener() { - when (menuType) { - "FIXED" -> { - binding.btnNextReview.setOnClickListener { - val intent = Intent(this, ReviewWriteRateActivity::class.java) - intent.putExtra("itemId", itemId) - intent.putExtra("itemName", itemName) - intent.putExtra("menuType", menuType) - startActivity(intent) - } - } - - "VARIABLE" -> { - binding.btnNextReview.setOnClickListener { - val intent = Intent(this, ReviewWriteMenuActivity::class.java) - intent.putExtra("itemId", itemId) - intent.putExtra("menuType", menuType) - startActivity(intent) - } - } - else -> { - Timber.d("잘못된 식당 정보입니다.") - } - } - } private fun bindData() { lifecycleScope.launch { reviewViewModel.uiState.collectLatest { if (!it.error && !it.loading) { if (it.isEmpty) { - //리뷰 없어도 메뉴명은 있음 - it.reviewInfo?.apply { - binding.tvMenu.text = name.replace(Regex("[\\[\\]]"), "") - } - Timber.d("리뷰가 없음") binding.llNonReview.visibility = View.VISIBLE binding.rvReview.visibility = View.INVISIBLE - } else { //리뷰 있다. + it.reviewInfo?.apply { + binding.tvMenu.text = name.replace(Regex("[\\[\\]]"), "") + } + } else { //리뷰 있다. Timber.d("리뷰가 있음") binding.llNonReview.visibility = View.INVISIBLE binding.rvReview.visibility = View.VISIBLE + reviewAdapter = it.reviewList?.let { review -> ReviewAdapter(review) { reviewId -> deleteViewModel.deleteReview( @@ -120,15 +102,13 @@ class ReviewActivity : } it.reviewInfo?.apply { - binding.tvMenu.text = name.replace(Regex("[\\[\\]]"), "") Timber.d(it.reviewInfo.toString()) + binding.tvMenu.text = name.replace(Regex("[\\[\\]]"), "") binding.tvReviewNumCount.text = reviewCnt.toString() - binding.tvRate.text = String.format("%.1f", mainRating) - val totalReviewCount = reviewCnt binding.progressBar1.max = totalReviewCount binding.progressBar2.max = totalReviewCount @@ -147,4 +127,31 @@ class ReviewActivity : } } } + + private fun setClickListener() { + when (menuType) { + "FIXED" -> { + binding.btnNextReview.setOnClickListener { + val intent = Intent(this, ReviewWriteRateActivity::class.java) + intent.putExtra("itemId", itemId) + intent.putExtra("itemName", itemName) + intent.putExtra("menuType", menuType) + startActivity(intent) + } + } + + "VARIABLE" -> { + binding.btnNextReview.setOnClickListener { + val intent = Intent(this, ReviewWriteMenuActivity::class.java) + intent.putExtra("itemId", itemId) + intent.putExtra("menuType", menuType) + startActivity(intent) + } + } + + else -> { + Timber.d("잘못된 식당 정보입니다.") + } + } + } }