콘텐츠 업로드

- 소장만 가능한 콘텐츠 업로드 기능 추가
This commit is contained in:
klaus 2024-11-08 16:11:35 +09:00
parent 6f1dcb4632
commit 140f933db7
5 changed files with 124 additions and 53 deletions

View File

@ -0,0 +1,14 @@
package kr.co.vividnext.sodalive.audio_content
import com.google.gson.annotations.SerializedName
enum class PurchaseOption {
@SerializedName("BOTH")
BOTH,
@SerializedName("BUY_ONLY")
BUY_ONLY,
@SerializedName("RENT_ONLY")
RENT_ONLY,
}

View File

@ -23,6 +23,7 @@ import com.jakewharton.rxbinding4.widget.textChanges
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.audio_content.PurchaseOption
import kr.co.vividnext.sodalive.audio_content.upload.theme.AudioContentThemeFragment
import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.common.LoadingDialog
@ -206,8 +207,11 @@ class AudioContentUploadActivity : BaseActivity<ActivityAudioContentUploadBindin
binding.llPreviewNo.setOnClickListener { viewModel.setGeneratePreview(false) }
binding.llLimited.setOnClickListener { viewModel.setLimited(true) }
binding.llNotLimited.setOnClickListener { viewModel.setLimited(false) }
binding.llRentalAndKeep.setOnClickListener { viewModel.setIsOnlyRental(false) }
binding.llOnlyRental.setOnClickListener { viewModel.setIsOnlyRental(true) }
binding.llBoth.setOnClickListener { viewModel.setPurchaseOption(PurchaseOption.BOTH) }
binding.llBuyOnly.setOnClickListener { viewModel.setPurchaseOption(PurchaseOption.BUY_ONLY) }
binding.llRentOnly.setOnClickListener {
viewModel.setPurchaseOption(PurchaseOption.RENT_ONLY)
}
binding.llCommentNo.setOnClickListener { viewModel.setAvailableComment(false) }
binding.llCommentYes.setOnClickListener { viewModel.setAvailableComment(true) }
binding.llActiveNow.setOnClickListener { viewModel.setActiveReservation(false) }
@ -444,11 +448,11 @@ class AudioContentUploadActivity : BaseActivity<ActivityAudioContentUploadBindin
}
}
viewModel.isOnlyRentalLiveData.observe(this) {
if (it) {
checkOnlyRental()
} else {
checkRentalAndKeep()
viewModel.purchaseOptionLiveData.observe(this) {
when (it) {
PurchaseOption.BOTH -> checkBoth()
PurchaseOption.BUY_ONLY -> checkBuyOnly()
PurchaseOption.RENT_ONLY -> checkRentOnly()
}
}
@ -625,7 +629,7 @@ class AudioContentUploadActivity : BaseActivity<ActivityAudioContentUploadBindin
viewModel.price = 0
binding.etSetPrice.setText("0")
binding.llSetPrice.visibility = View.GONE
binding.llConfigKeep.visibility = View.GONE
binding.llConfigPurchase.visibility = View.GONE
binding.tvTitleConfigKeep.visibility = View.GONE
binding.ivPriceFree.visibility = View.VISIBLE
@ -654,7 +658,7 @@ class AudioContentUploadActivity : BaseActivity<ActivityAudioContentUploadBindin
private fun checkPricePaid() {
binding.llSetPrice.visibility = View.VISIBLE
binding.llConfigKeep.visibility = View.VISIBLE
binding.llConfigPurchase.visibility = View.VISIBLE
binding.tvTitleConfigKeep.visibility = View.VISIBLE
binding.ivPricePaid.visibility = View.VISIBLE
@ -772,50 +776,73 @@ class AudioContentUploadActivity : BaseActivity<ActivityAudioContentUploadBindin
binding.llConfigPreviewTime.visibility = View.GONE
}
private fun checkRentalAndKeep() {
binding.tvPriceTitle.text = "소장 가격"
binding.ivRentalAndKeep.visibility = View.VISIBLE
binding.tvRentalAndKeep.setTextColor(
ContextCompat.getColor(
applicationContext,
R.color.color_eeeeee
)
)
binding.llRentalAndKeep.setBackgroundResource(R.drawable.bg_round_corner_6_7_3bb9f1)
private fun uncheckPurchaseOption() {
binding.ivBoth.visibility = View.GONE
binding.ivBuyOnly.visibility = View.GONE
binding.ivRentOnly.visibility = View.GONE
binding.ivOnlyRental.visibility = View.GONE
binding.tvOnlyRental.setTextColor(
binding.tvBoth.setTextColor(
ContextCompat.getColor(
applicationContext,
R.color.color_3bb9f1
)
)
binding.llOnlyRental.setBackgroundResource(
R.drawable.bg_round_corner_6_7_13181b
binding.llBoth.setBackgroundResource(R.drawable.bg_round_corner_6_7_13181b)
binding.tvBuyOnly.setTextColor(
ContextCompat.getColor(
applicationContext,
R.color.color_3bb9f1
)
)
binding.llBuyOnly.setBackgroundResource(R.drawable.bg_round_corner_6_7_13181b)
binding.tvRentOnly.setTextColor(
ContextCompat.getColor(
applicationContext,
R.color.color_3bb9f1
)
)
binding.llRentOnly.setBackgroundResource(R.drawable.bg_round_corner_6_7_13181b)
}
private fun checkOnlyRental() {
binding.tvPriceTitle.text = "대여 가격"
binding.ivOnlyRental.visibility = View.VISIBLE
binding.tvOnlyRental.setTextColor(
private fun checkBoth() {
uncheckPurchaseOption()
binding.tvPriceTitle.text = "소장 가격"
binding.ivBoth.visibility = View.VISIBLE
binding.tvBoth.setTextColor(
ContextCompat.getColor(
applicationContext,
R.color.color_eeeeee
)
)
binding.llOnlyRental.setBackgroundResource(R.drawable.bg_round_corner_6_7_3bb9f1)
binding.llBoth.setBackgroundResource(R.drawable.bg_round_corner_6_7_3bb9f1)
}
binding.ivRentalAndKeep.visibility = View.GONE
binding.tvRentalAndKeep.setTextColor(
private fun checkBuyOnly() {
uncheckPurchaseOption()
binding.tvPriceTitle.text = "소장 가격"
binding.ivBuyOnly.visibility = View.VISIBLE
binding.tvBuyOnly.setTextColor(
ContextCompat.getColor(
applicationContext,
R.color.color_3bb9f1
R.color.color_eeeeee
)
)
binding.llRentalAndKeep.setBackgroundResource(
R.drawable.bg_round_corner_6_7_13181b
binding.llBuyOnly.setBackgroundResource(R.drawable.bg_round_corner_6_7_3bb9f1)
}
private fun checkRentOnly() {
uncheckPurchaseOption()
binding.tvPriceTitle.text = "대여 가격"
binding.ivRentOnly.visibility = View.VISIBLE
binding.tvRentOnly.setTextColor(
ContextCompat.getColor(
applicationContext,
R.color.color_eeeeee
)
)
binding.llRentOnly.setBackgroundResource(R.drawable.bg_round_corner_6_7_3bb9f1)
}
private fun getFileName(uri: Uri): String? {

View File

@ -8,6 +8,7 @@ import com.orhanobut.logger.Logger
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers
import kr.co.vividnext.sodalive.audio_content.AudioContentRepository
import kr.co.vividnext.sodalive.audio_content.PurchaseOption
import kr.co.vividnext.sodalive.audio_content.upload.theme.GetAudioContentThemeResponse
import kr.co.vividnext.sodalive.base.BaseViewModel
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
@ -38,9 +39,9 @@ class AudioContentUploadViewModel(
val isAdultLiveData: LiveData<Boolean>
get() = _isAdultLiveData
private val _isOnlyRentalLiveData = MutableLiveData(false)
val isOnlyRentalLiveData: LiveData<Boolean>
get() = _isOnlyRentalLiveData
private val _purchaseOptionLiveData = MutableLiveData(PurchaseOption.BOTH)
val purchaseOptionLiveData: LiveData<PurchaseOption>
get() = _purchaseOptionLiveData
private val _isAvailableCommentLiveData = MutableLiveData(true)
val isAvailableCommentLiveData: LiveData<Boolean>
@ -101,13 +102,13 @@ class AudioContentUploadViewModel(
_isPriceFreeLiveData.postValue(isPriceFree)
if (isPriceFree) {
_isOnlyRentalLiveData.postValue(false)
_purchaseOptionLiveData.postValue(PurchaseOption.BOTH)
_isShowConfigLimitedLiveData.postValue(false)
_isLimitedLiveData.postValue(false)
limited = 0
_isGeneratePreviewLiveData.postValue(true)
} else {
if (!_isOnlyRentalLiveData.value!!) {
if (_purchaseOptionLiveData.value!! != PurchaseOption.RENT_ONLY) {
_isShowConfigLimitedLiveData.postValue(true)
}
}
@ -125,10 +126,10 @@ class AudioContentUploadViewModel(
}
}
fun setIsOnlyRental(isOnlyRental: Boolean) {
_isOnlyRentalLiveData.postValue(isOnlyRental)
fun setPurchaseOption(purchaseOption: PurchaseOption) {
_purchaseOptionLiveData.postValue(purchaseOption)
if (isOnlyRental) {
if (purchaseOption == PurchaseOption.RENT_ONLY) {
_isShowConfigLimitedLiveData.postValue(false)
_isLimitedLiveData.postValue(false)
limited = 0
@ -154,6 +155,7 @@ class AudioContentUploadViewModel(
detail = detail,
tags = tags,
price = price,
purchaseOption = _purchaseOptionLiveData.value!!,
limited = if (
price > 0 &&
limited > 0 &&
@ -173,7 +175,6 @@ class AudioContentUploadViewModel(
timezone = TimeZone.getDefault().id,
themeId = theme!!.id,
isAdult = _isAdultLiveData.value!!,
isOnlyRental = _isOnlyRentalLiveData.value!!,
isGeneratePreview = isGeneratePreview,
isCommentAvailable = _isAvailableCommentLiveData.value!!,
previewStartTime = if (isGeneratePreview) {

View File

@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.audio_content.upload
import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName
import kr.co.vividnext.sodalive.audio_content.PurchaseOption
@Keep
data class CreateAudioContentRequest(
@ -9,12 +10,12 @@ data class CreateAudioContentRequest(
@SerializedName("detail") val detail: String,
@SerializedName("tags") val tags: String,
@SerializedName("price") val price: Int,
@SerializedName("purchaseOption") val purchaseOption: PurchaseOption,
@SerializedName("limited") val limited: Int? = null,
@SerializedName("releaseDate") val releaseDate: String?,
@SerializedName("timezone") val timezone: String,
@SerializedName("themeId") val themeId: Long,
@SerializedName("isAdult") val isAdult: Boolean,
@SerializedName("isOnlyRental") val isOnlyRental: Boolean,
@SerializedName("isGeneratePreview") val isGeneratePreview: Boolean,
@SerializedName("isCommentAvailable") val isCommentAvailable: Boolean,
@SerializedName("previewStartTime") val previewStartTime: String? = null,

View File

@ -379,7 +379,7 @@
android:textSize="16.7sp" />
<LinearLayout
android:id="@+id/ll_config_keep"
android:id="@+id/ll_config_purchase"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="13.3dp"
@ -387,7 +387,7 @@
android:baselineAligned="false">
<LinearLayout
android:id="@+id/ll_rental_and_keep"
android:id="@+id/ll_both"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -396,16 +396,16 @@
android:paddingVertical="14.3dp">
<ImageView
android:id="@+id/iv_rental_and_keep"
android:id="@+id/iv_both"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6.7dp"
android:layout_marginEnd="3.3dp"
android:contentDescription="@null"
android:src="@drawable/ic_select_check"
android:visibility="gone" />
<TextView
android:id="@+id/tv_rental_and_keep"
android:id="@+id/tv_both"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/gmarket_sans_bold"
@ -415,26 +415,54 @@
</LinearLayout>
<LinearLayout
android:id="@+id/ll_only_rental"
android:id="@+id/ll_buy_only"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="13.3dp"
android:layout_marginHorizontal="6.7dp"
android:layout_weight="1"
android:background="@drawable/bg_round_corner_6_7_13181b"
android:gravity="center"
android:paddingVertical="14.3dp">
<ImageView
android:id="@+id/iv_only_rental"
android:id="@+id/iv_buy_only"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6.7dp"
android:layout_marginEnd="3.3dp"
android:contentDescription="@null"
android:src="@drawable/ic_select_check"
android:visibility="gone" />
<TextView
android:id="@+id/tv_only_rental"
android:id="@+id/tv_buy_only"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/gmarket_sans_bold"
android:text="소장만"
android:textColor="@color/color_3bb9f1"
android:textSize="14.7sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_rent_only"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/bg_round_corner_6_7_13181b"
android:gravity="center"
android:paddingVertical="14.3dp">
<ImageView
android:id="@+id/iv_rent_only"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="3.3dp"
android:contentDescription="@null"
android:src="@drawable/ic_select_check"
android:visibility="gone" />
<TextView
android:id="@+id/tv_rent_only"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/gmarket_sans_bold"