parent
5b2c5a6e2f
commit
2ed77a3332
|
@ -42,6 +42,7 @@ import kr.co.vividnext.sodalive.common.LoadingDialog
|
|||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.common.Utils
|
||||
import kr.co.vividnext.sodalive.databinding.ActivityAudioContentDetailBinding
|
||||
import kr.co.vividnext.sodalive.explorer.profile.CreatorFollowNotifyFragment
|
||||
import kr.co.vividnext.sodalive.explorer.profile.UserProfileActivity
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import kr.co.vividnext.sodalive.extensions.moneyFormat
|
||||
|
@ -843,21 +844,50 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
|||
if (creator.creatorId != SharedPreferenceManager.userId) {
|
||||
binding.ivFollow.visibility = View.VISIBLE
|
||||
|
||||
if (creator.isFollowing) {
|
||||
binding.ivFollow.setImageResource(R.drawable.btn_following_big)
|
||||
if (creator.isFollow) {
|
||||
binding.ivFollow.setImageResource(
|
||||
if (creator.isNotify) {
|
||||
R.drawable.btn_following_big
|
||||
} else {
|
||||
R.drawable.btn_following_no_alarm_big
|
||||
}
|
||||
)
|
||||
|
||||
binding.ivFollow.setOnClickListener {
|
||||
viewModel.unRegisterNotification(
|
||||
contentId = audioContentId,
|
||||
creatorId = creator.creatorId
|
||||
val notifyFragment = CreatorFollowNotifyFragment(
|
||||
onClickNotifyAll = {
|
||||
viewModel.follow(
|
||||
contentId = audioContentId,
|
||||
creatorId = creator.creatorId,
|
||||
follow = true,
|
||||
notify = true
|
||||
)
|
||||
},
|
||||
onClickNotifyNone = {
|
||||
viewModel.follow(
|
||||
contentId = audioContentId,
|
||||
creatorId = creator.creatorId,
|
||||
follow = true,
|
||||
notify = false
|
||||
)
|
||||
},
|
||||
onClickUnFollow = {
|
||||
viewModel.follow(
|
||||
contentId = audioContentId,
|
||||
creatorId = creator.creatorId,
|
||||
follow = false,
|
||||
notify = false
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
if (notifyFragment.isAdded) return@setOnClickListener
|
||||
notifyFragment.show(supportFragmentManager, notifyFragment.tag)
|
||||
}
|
||||
} else {
|
||||
binding.ivFollow.setImageResource(R.drawable.btn_follow_big)
|
||||
binding.ivFollow.setOnClickListener {
|
||||
viewModel.registerNotification(
|
||||
contentId = audioContentId,
|
||||
creatorId = creator.creatorId
|
||||
)
|
||||
viewModel.follow(contentId = audioContentId, creatorId = creator.creatorId)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -25,9 +25,11 @@ import kr.co.vividnext.sodalive.mypage.auth.AuthVerifyRequest
|
|||
import kr.co.vividnext.sodalive.report.ReportRepository
|
||||
import kr.co.vividnext.sodalive.report.ReportRequest
|
||||
import kr.co.vividnext.sodalive.report.ReportType
|
||||
import kr.co.vividnext.sodalive.user.UserRepository
|
||||
|
||||
class AudioContentDetailViewModel(
|
||||
private val repository: AudioContentRepository,
|
||||
private val userRepository: UserRepository,
|
||||
private val authRepository: AuthRepository,
|
||||
private val reportRepository: ReportRepository,
|
||||
private val commentRepository: AudioContentCommentRepository
|
||||
|
@ -102,6 +104,41 @@ class AudioContentDetailViewModel(
|
|||
)
|
||||
}
|
||||
|
||||
fun follow(contentId: Long, creatorId: Long, follow: Boolean = true, notify: Boolean = true) {
|
||||
isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
userRepository.creatorFollow(
|
||||
creatorId = creatorId,
|
||||
follow,
|
||||
notify,
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
if (it.success && it.data != null) {
|
||||
getAudioContentDetail(contentId)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
}
|
||||
isLoading.value = false
|
||||
},
|
||||
{
|
||||
isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun registerNotification(contentId: Long, creatorId: Long) {
|
||||
isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
|
|
|
@ -237,7 +237,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
|
|||
viewModel { AudioContentUploadViewModel(get()) }
|
||||
viewModel { AudioContentModifyViewModel(get()) }
|
||||
viewModel { AudioContentThemeViewModel(get()) }
|
||||
viewModel { AudioContentDetailViewModel(get(), get(), get(), get()) }
|
||||
viewModel { AudioContentDetailViewModel(get(), get(), get(), get(), get()) }
|
||||
viewModel { AudioContentCommentListViewModel(get()) }
|
||||
viewModel { AudioContentCommentReplyViewModel(get()) }
|
||||
viewModel { FollowingCreatorViewModel(get(), get()) }
|
||||
|
|
|
@ -82,6 +82,7 @@ class FollowingCreatorViewModel(
|
|||
}
|
||||
|
||||
fun follow(creatorId: Long, follow: Boolean = true, notify: Boolean = true) {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
userRepository.creatorFollow(
|
||||
creatorId = creatorId,
|
||||
|
|
Loading…
Reference in New Issue