룰렛 설정 - 설정된 적이 없을 때 기본 캔 설정 5 -> 0으로 변경
This commit is contained in:
parent
2883c63e07
commit
29e293e6b5
|
@ -93,7 +93,13 @@ class RouletteSettingsFragment : BaseFragment<FragmentRouletteSettingsBinding>(
|
||||||
|
|
||||||
viewModel.toastLiveData.observe(viewLifecycleOwner) { it?.let { showToast(it) } }
|
viewModel.toastLiveData.observe(viewLifecycleOwner) { it?.let { showToast(it) } }
|
||||||
|
|
||||||
viewModel.canLiveData.observe(viewLifecycleOwner) { binding.etSetPrice.setText("$it") }
|
viewModel.canLiveData.observe(viewLifecycleOwner) {
|
||||||
|
if (it > 0) {
|
||||||
|
binding.etSetPrice.setText("$it")
|
||||||
|
} else {
|
||||||
|
binding.etSetPrice.setText("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
viewModel.isLoading.observe(viewLifecycleOwner) {
|
viewModel.isLoading.observe(viewLifecycleOwner) {
|
||||||
if (it) {
|
if (it) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ class RouletteSettingsViewModel(private val repository: RouletteRepository) : Ba
|
||||||
val isActiveLiveData: LiveData<Boolean>
|
val isActiveLiveData: LiveData<Boolean>
|
||||||
get() = _isActiveLiveData
|
get() = _isActiveLiveData
|
||||||
|
|
||||||
private val _canLiveData = MutableLiveData(5)
|
private val _canLiveData = MutableLiveData(0)
|
||||||
val canLiveData: LiveData<Int>
|
val canLiveData: LiveData<Int>
|
||||||
get() = _canLiveData
|
get() = _canLiveData
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class RouletteSettingsViewModel(private val repository: RouletteRepository) : Ba
|
||||||
get() = _roulettePreviewLiveData
|
get() = _roulettePreviewLiveData
|
||||||
|
|
||||||
private val options = mutableListOf<RouletteOption>()
|
private val options = mutableListOf<RouletteOption>()
|
||||||
var can = 5
|
var can = 0
|
||||||
var isActive = false
|
var isActive = false
|
||||||
|
|
||||||
fun plusWeight(optionIndex: Int) {
|
fun plusWeight(optionIndex: Int) {
|
||||||
|
@ -195,10 +195,10 @@ class RouletteSettingsViewModel(private val repository: RouletteRepository) : Ba
|
||||||
recalculatePercentages(options)
|
recalculatePercentages(options)
|
||||||
} else {
|
} else {
|
||||||
_isActiveLiveData.value = false
|
_isActiveLiveData.value = false
|
||||||
_canLiveData.value = 5
|
_canLiveData.value = 0
|
||||||
|
|
||||||
isActive = false
|
isActive = false
|
||||||
can = 5
|
can = 0
|
||||||
|
|
||||||
options.add(RouletteOption(title = "", weight = 1))
|
options.add(RouletteOption(title = "", weight = 1))
|
||||||
options.add(RouletteOption(title = "", weight = 1))
|
options.add(RouletteOption(title = "", weight = 1))
|
||||||
|
|
Loading…
Reference in New Issue