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