오디션

- 오디션 알림 받기 설정 추가
This commit is contained in:
klaus 2025-01-08 22:11:49 +09:00
parent 4180736065
commit 273ddb8b97
11 changed files with 85 additions and 5 deletions

View File

@ -5,16 +5,21 @@ import android.graphics.Rect
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.media3.common.util.UnstableApi
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.audition.detail.AuditionDetailActivity
import kr.co.vividnext.sodalive.base.BaseFragment
import kr.co.vividnext.sodalive.common.Constants
import kr.co.vividnext.sodalive.common.LoadingDialog
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.databinding.FragmentAuditionBinding
import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.main.MainActivity
import org.koin.android.ext.android.inject
@UnstableApi
class AuditionFragment : BaseFragment<FragmentAuditionBinding>(
FragmentAuditionBinding::inflate
) {
@ -32,6 +37,12 @@ class AuditionFragment : BaseFragment<FragmentAuditionBinding>(
viewModel.getAuditionList()
}
override fun onResume() {
super.onResume()
setAuditionNotification(SharedPreferenceManager.isAuditionNotification)
}
private fun setupView() {
loadingDialog = LoadingDialog(requireActivity(), layoutInflater)
@ -79,6 +90,12 @@ class AuditionFragment : BaseFragment<FragmentAuditionBinding>(
})
recyclerView.adapter = adapter
binding.ivNotification.setOnClickListener {
viewModel.updateNotificationSettings {
setAuditionNotification(it)
}
}
}
private fun bindData() {
@ -98,4 +115,14 @@ class AuditionFragment : BaseFragment<FragmentAuditionBinding>(
adapter.addGroupedList(it)
}
}
private fun setAuditionNotification(isAuditionNotification: Boolean) {
binding.ivNotification.setImageResource(
if (isAuditionNotification) {
R.drawable.btn_audition_notification_selected
} else {
R.drawable.btn_audition_notification_normal
}
)
}
}

View File

@ -7,8 +7,13 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers
import kr.co.vividnext.sodalive.base.BaseViewModel
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.settings.notification.UpdateNotificationSettingRequest
import kr.co.vividnext.sodalive.user.UserRepository
class AuditionViewModel(private val repository: AuditionRepository) : BaseViewModel() {
class AuditionViewModel(
private val repository: AuditionRepository,
private val userRepository: UserRepository
) : BaseViewModel() {
private val _toastLiveData = MutableLiveData<String?>()
val toastLiveData: LiveData<String?>
get() = _toastLiveData
@ -65,4 +70,30 @@ class AuditionViewModel(private val repository: AuditionRepository) : BaseViewMo
)
}
}
fun updateNotificationSettings(onSuccess: (Boolean) -> Unit) {
val isActiveNotification = !SharedPreferenceManager.isAuditionNotification
compositeDisposable.add(
userRepository.updateNotificationSettings(
request = UpdateNotificationSettingRequest(
audition = isActiveNotification
),
token = "Bearer ${SharedPreferenceManager.token}"
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
if (it.success) {
SharedPreferenceManager.isAuditionNotification = isActiveNotification
onSuccess(isActiveNotification)
} else {
onSuccess(!isActiveNotification)
}
},
{}
)
)
}
}

View File

@ -13,6 +13,7 @@ object Constants {
const val PREF_PROFILE_IMAGE = "pref_profile_image"
const val PREF_CONTENT_PREFERENCE = "pref_content_preference"
const val PREF_IS_CONTENT_PLAY_LOOP = "pref_is_content_play_loop"
const val PREF_IS_AUDITION_NOTIFICATION = "pref_is_audition_notification"
const val PREF_IS_ADULT_CONTENT_VISIBLE = "pref_is_adult_content_visible"
const val PREF_IS_FOLLOWED_CREATOR_LIVE = "pref_is_followed_creator_live"
const val PREF_IS_PLAYER_SERVICE_RUNNING = "pref_is_player_service_running"

View File

@ -107,6 +107,12 @@ object SharedPreferenceManager {
sharedPreferences[Constants.PREF_IS_ADULT] = value
}
var isAuditionNotification: Boolean
get() = sharedPreferences[Constants.PREF_IS_AUDITION_NOTIFICATION, false]
set(value) {
sharedPreferences[Constants.PREF_IS_AUDITION_NOTIFICATION] = value
}
var isAdultContentVisible: Boolean
get() = sharedPreferences[Constants.PREF_IS_ADULT_CONTENT_VISIBLE, true]
set(value) {

View File

@ -286,7 +286,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
viewModel { AudioContentPlaylistCreateViewModel(get()) }
viewModel { AudioContentPlaylistModifyViewModel(get()) }
viewModel { AudioContentPlayerViewModel() }
viewModel { AuditionViewModel(get()) }
viewModel { AuditionViewModel(get(), get()) }
viewModel { AuditionDetailViewModel(get()) }
viewModel { AuditionRoleDetailViewModel(get()) }
viewModel { AudioContentMainCreatorRankingViewModel(get()) }

View File

@ -98,6 +98,7 @@ class MainViewModel(
SharedPreferenceManager.can = data.can
SharedPreferenceManager.role = data.role.name
SharedPreferenceManager.isAuth = data.isAuth
SharedPreferenceManager.isAuditionNotification = data.auditionNotice ?: false
if (
data.followingChannelUploadContentNotice == null &&
data.followingChannelLiveNotice == null &&

View File

@ -12,7 +12,9 @@ data class GetMemberInfoResponse(
@SerializedName("followingChannelLiveNotice")
val followingChannelLiveNotice: Boolean?,
@SerializedName("followingChannelUploadContentNotice")
val followingChannelUploadContentNotice: Boolean?
val followingChannelUploadContentNotice: Boolean?,
@SerializedName("auditionNotice")
val auditionNotice: Boolean?
)
enum class MemberRole {

View File

@ -7,5 +7,6 @@ import com.google.gson.annotations.SerializedName
data class UpdateNotificationSettingRequest(
@SerializedName("live") var live: Boolean? = null,
@SerializedName("uploadContent") var uploadContent: Boolean? = null,
@SerializedName("message") var message: Boolean? = null
@SerializedName("message") var message: Boolean? = null,
@SerializedName("audition") var audition: Boolean? = null
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -8,7 +8,6 @@
android:id="@+id/tv_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginStart="13.3dp"
android:layout_marginTop="13.3dp"
android:fontFamily="@font/gmarket_sans_bold"
@ -18,6 +17,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="13.3dp"
android:layout_marginEnd="13.3dp"
android:contentDescription="@null"
android:src="@drawable/btn_audition_notification_normal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_audition"
android:layout_width="0dp"