Skip to content

Commit

Permalink
Merge pull request #182 from depromeet/fix/#180-seat-review-loading
Browse files Browse the repository at this point in the history
[FEATURE] 시야 등록뷰 로딩바 추가
  • Loading branch information
minju1459 authored Sep 10, 2024
2 parents 3d54906 + 9445652 commit b6e3e0f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ object Constants {
const val compileSdk = 34
const val minSdk = 28
const val targetSdk = 34
var versionCode = 8
var versionName = "1.0.6"
var versionCode = 9
var versionName = "1.0.7"
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.dpm.designsystem.SpotImageSnackBar
import com.dpm.domain.model.seatreview.ReviewMethod
import com.dpm.presentation.extension.setOnSingleClickListener
import com.dpm.presentation.extension.toast
import com.dpm.presentation.global.LoadingDialog
import com.dpm.presentation.home.HomeActivity
import com.dpm.presentation.seatreview.dialog.main.DatePickerDialog
import com.dpm.presentation.seatreview.dialog.main.ImageUploadDialog
Expand Down Expand Up @@ -58,6 +59,7 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({
private const val DIALOG_TYPE = "DIALOG_TYPE"
}

private lateinit var loadingDialog: LoadingDialog
private val viewModel by viewModels<ReviewViewModel>()
private val method by lazy {
intent.getStringExtra(METHOD_KEY)?.let { ReviewMethod.valueOf(it) }
Expand Down Expand Up @@ -160,7 +162,7 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({
updateNextButtonState()
initEventToBack()
}
viewModel.selectedBlock.asLiveData().observe(this){
viewModel.selectedBlock.asLiveData().observe(this) {
initEventToBack()
}
}
Expand Down Expand Up @@ -269,11 +271,11 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({
private fun initUploadDialog() {
binding.btnAddImage.setOnSingleClickListener {
imageUploadResultHandler()
//ImageUploadDialog().show(supportFragmentManager, IMAGE_UPLOAD_DIALOG)
// ImageUploadDialog().show(supportFragmentManager, IMAGE_UPLOAD_DIALOG)
}
binding.llAddImage.setOnSingleClickListener {
imageUploadResultHandler()
//ImageUploadDialog().show(supportFragmentManager, IMAGE_UPLOAD_DIALOG)
// ImageUploadDialog().show(supportFragmentManager, IMAGE_UPLOAD_DIALOG)
}
}

Expand Down Expand Up @@ -524,7 +526,17 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({
private fun observeUploadReview() {
viewModel.postReviewState.asLiveData().observe(this) { state ->
when (state) {
is UiState.Loading -> {
if (!::loadingDialog.isInitialized) {
loadingDialog = LoadingDialog(this)
}
loadingDialog.show()
}
is UiState.Success -> {
if (::loadingDialog.isInitialized && loadingDialog.isShowing) {
loadingDialog.dismiss()
}

val dialogType = when (method) {
ReviewMethod.VIEW -> ReviewMethod.VIEW
ReviewMethod.FEED -> ReviewMethod.FEED
Expand Down Expand Up @@ -555,6 +567,9 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({
}

is UiState.Failure -> {
if (::loadingDialog.isInitialized && loadingDialog.isShowing) {
loadingDialog.dismiss()
}
toast("리뷰 등록 실패: $state")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import android.os.Bundle
import android.view.View
import android.widget.NumberPicker
import androidx.fragment.app.activityViewModels
import com.dpm.core.base.BindingBottomSheetDialog
import com.depromeet.presentation.R
import com.depromeet.presentation.databinding.CustomDatepickerBinding
import com.dpm.core.base.BindingBottomSheetDialog
import com.dpm.presentation.extension.setOnSingleClickListener
import com.dpm.presentation.seatreview.viewmodel.ReviewViewModel
import com.dpm.presentation.util.CalendarUtil
Expand Down Expand Up @@ -61,17 +61,21 @@ class DatePickerDialog : BindingBottomSheetDialog<CustomDatepickerBinding>(
npDay.value = selectedDay
npDay.wrapSelectorWheel = false

updateDateValue()

npMonth.setOnValueChangedListener { _, _, newVal ->
calendarInstance.set(Calendar.MONTH, newVal - 1)
npDay.maxValue = calendarInstance.getActualMaximum(Calendar.DAY_OF_MONTH)
updateDateValue()
}
updateDateValue(npDay.maxValue)
}
}

private fun initEvent() {
binding.npMonth.setOnValueChangedListener { _, _, newVal ->
calendarInstance.set(Calendar.MONTH, newVal - 1)
val maxDay = calendarInstance.getActualMaximum(Calendar.DAY_OF_MONTH)

if (binding.npDay.value > maxDay) {
binding.npDay.value = maxDay
}
updateDateValue(maxDay)
}

binding.tvCancel.setOnSingleClickListener { dismiss() }
binding.tvDone.setOnSingleClickListener {
val selectedYear = binding.npYear.value
Expand All @@ -86,11 +90,12 @@ class DatePickerDialog : BindingBottomSheetDialog<CustomDatepickerBinding>(
}
}

private fun updateDateValue() {
private fun updateDateValue(maxDay: Int = 0) {
with(binding) {
npYear.displayedValues = Array(npYear.maxValue - npYear.minValue + 1) { i -> "${i + npYear.minValue}" }
npMonth.displayedValues = Array(12) { i -> "${i + 1}" }
npDay.displayedValues = Array(npDay.maxValue) { i -> "${i + 1}" }
npDay.displayedValues = Array(maxDay + 1) { i -> "${i + 1}" }
binding.npDay.maxValue = maxDay
}
}
}

0 comments on commit b6e3e0f

Please sign in to comment.