Skip to content

Commit

Permalink
chore: pretter code
Browse files Browse the repository at this point in the history
  • Loading branch information
HI-JIN2 committed Oct 10, 2024
1 parent 73f60f3 commit eb19b20
Showing 1 changed file with 41 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ class ReviewActivity :
lodeData()
bindData()
setClickListener()
}

override fun onResume() {
super.onResume()


//todo ์ด๊ฑฐ ์•ˆํ•˜๋ฉด ๋ฐ”๋กœ๋ฐ”๋กœ ๊ฐฑ์‹ ์ด ์•ˆ๋˜๋Š”๋””
lodeData()
bindData()
}


Expand All @@ -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(
Expand All @@ -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
Expand All @@ -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("์ž˜๋ชป๋œ ์‹๋‹น ์ •๋ณด์ž…๋‹ˆ๋‹ค.")
}
}
}
}

0 comments on commit eb19b20

Please sign in to comment.