parent
5d42e2b16e
commit
a9511dcb51
|
@ -49,7 +49,8 @@ class CreatorCommunityWriteActivity : BaseActivity<ActivityCreatorCommunityWrite
|
|||
placeholder(R.drawable.ic_place_holder)
|
||||
transformations(RoundedCornersTransformation(8f.dpToPx()))
|
||||
}
|
||||
viewModel.imageUri = fileUri
|
||||
|
||||
viewModel.setImageUri(fileUri)
|
||||
} else {
|
||||
Toast.makeText(
|
||||
this,
|
||||
|
@ -223,6 +224,14 @@ class CreatorCommunityWriteActivity : BaseActivity<ActivityCreatorCommunityWrite
|
|||
}
|
||||
}
|
||||
|
||||
viewModel.isShowPriceUiLiveData.observe(this) {
|
||||
binding.llPrice.visibility = if (it) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
if (SharedPreferenceManager.isAuth) {
|
||||
binding.llAgeAll.setOnClickListener {
|
||||
viewModel.setAdult(false)
|
||||
|
|
|
@ -41,11 +41,15 @@ class CreatorCommunityWriteViewModel(
|
|||
val isPriceFreeLiveData: LiveData<Boolean>
|
||||
get() = _isPriceFreeLiveData
|
||||
|
||||
private val _isShowPriceUiLiveData = MutableLiveData(false)
|
||||
val isShowPriceUiLiveData: LiveData<Boolean>
|
||||
get() = _isShowPriceUiLiveData
|
||||
|
||||
lateinit var getRealPathFromURI: (Uri) -> String?
|
||||
|
||||
var price = 0
|
||||
var content = ""
|
||||
var imageUri: Uri? = null
|
||||
private var imageUri: Uri? = null
|
||||
|
||||
fun setAdult(isAdult: Boolean) {
|
||||
_isAdultLiveData.postValue(isAdult)
|
||||
|
@ -59,6 +63,11 @@ class CreatorCommunityWriteViewModel(
|
|||
_isPriceFreeLiveData.postValue(isPriceFree)
|
||||
}
|
||||
|
||||
fun setImageUri(uri: Uri) {
|
||||
this.imageUri = uri
|
||||
_isShowPriceUiLiveData.postValue(true)
|
||||
}
|
||||
|
||||
fun createCommunityPost(onSuccess: () -> Unit) {
|
||||
if (!_isLoading.value!! && validateData()) {
|
||||
_isLoading.postValue(true)
|
||||
|
@ -143,10 +152,17 @@ class CreatorCommunityWriteViewModel(
|
|||
}
|
||||
|
||||
try {
|
||||
if (!isPriceFreeLiveData.value!! && price < 5) {
|
||||
if (!isPriceFreeLiveData.value!!) {
|
||||
if (price < 5) {
|
||||
_toastLiveData.postValue("최소금액은 5캔 입니다.")
|
||||
return false
|
||||
}
|
||||
|
||||
if (imageUri == null) {
|
||||
_toastLiveData.postValue("유료 게시글 등록을 위해서는 이미지가 필요합니다.")
|
||||
return false
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
_toastLiveData.postValue("가격은 숫자만 입력 가능 합니다.")
|
||||
return false
|
||||
|
|
Loading…
Reference in New Issue