Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] 시야 등록뷰 로딩바 추가 #182

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
}