크리에이터 채널 - 팔로우와 알림설정
- 팔로잉 상태에서 알림 켜기/끄기 상태 추가
This commit is contained in:
@@ -67,8 +67,8 @@ class SeriesDetailViewModel(
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
userRepository.creatorFollow(
|
||||
creatorId,
|
||||
"Bearer ${SharedPreferenceManager.token}"
|
||||
creatorId = creatorId,
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package kr.co.vividnext.sodalive.explorer.profile
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import kr.co.vividnext.sodalive.R
|
||||
|
||||
class CreatorFollowNotifyFragment(
|
||||
private val onClickNotifyAll: () -> Unit,
|
||||
private val onClickNotifyNone: () -> Unit,
|
||||
private val onClickUnFollow: () -> Unit,
|
||||
) : BottomSheetDialogFragment() {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View = inflater.inflate(
|
||||
R.layout.fragment_creator_follow_notify,
|
||||
container,
|
||||
false
|
||||
)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
view.findViewById<LinearLayout>(R.id.ll_notify_all).setOnClickListener {
|
||||
onClickNotifyAll()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
|
||||
view.findViewById<LinearLayout>(R.id.ll_notify_none).setOnClickListener {
|
||||
onClickNotifyNone()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
|
||||
view.findViewById<LinearLayout>(R.id.ll_unfollow).setOnClickListener {
|
||||
onClickUnFollow()
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,8 @@ data class CreatorResponse(
|
||||
@SerializedName("websiteUrl") val websiteUrl: String? = null,
|
||||
@SerializedName("blogUrl") val blogUrl: String? = null,
|
||||
@SerializedName("isAvailableChat") val isAvailableChat: Boolean = true,
|
||||
@SerializedName("isFollow") val isFollow: Boolean,
|
||||
@SerializedName("isNotify") val isNotify: Boolean,
|
||||
@SerializedName("isNotification") val isNotification: Boolean,
|
||||
@SerializedName("notificationRecipientCount") val notificationRecipientCount: Int
|
||||
)
|
||||
|
||||
@@ -83,6 +83,8 @@ class UserProfileActivity : BaseActivity<ActivityUserProfileBinding>(
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private var userId: Long = 0
|
||||
|
||||
private var notifyFragment: CreatorFollowNotifyFragment? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
userId = intent.getLongExtra(Constants.EXTRA_USER_ID, 0)
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -703,10 +705,32 @@ class UserProfileActivity : BaseActivity<ActivityUserProfileBinding>(
|
||||
}
|
||||
}
|
||||
|
||||
if (creator.isNotification) {
|
||||
layoutUserProfile.ivNotification.setImageResource(R.drawable.btn_following_big)
|
||||
if (creator.isFollow) {
|
||||
layoutUserProfile.ivNotification.setImageResource(
|
||||
if (creator.isNotify) {
|
||||
R.drawable.btn_following_big
|
||||
} else {
|
||||
R.drawable.btn_following_no_alarm_big
|
||||
}
|
||||
)
|
||||
|
||||
layoutUserProfile.ivNotification.setOnClickListener {
|
||||
viewModel.unFollow(creator.creatorId)
|
||||
if (notifyFragment == null) {
|
||||
notifyFragment = CreatorFollowNotifyFragment(
|
||||
onClickNotifyAll = {
|
||||
viewModel.follow(creator.creatorId, follow = true, notify = true)
|
||||
},
|
||||
onClickNotifyNone = {
|
||||
viewModel.follow(creator.creatorId, follow = true, notify = false)
|
||||
},
|
||||
onClickUnFollow = {
|
||||
viewModel.follow(creator.creatorId, follow = false, notify = false)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if (notifyFragment!!.isAdded) return@setOnClickListener
|
||||
notifyFragment!!.show(supportFragmentManager, notifyFragment!!.tag)
|
||||
}
|
||||
} else {
|
||||
layoutUserProfile.ivNotification.setImageResource(R.drawable.btn_follow_big)
|
||||
|
||||
@@ -16,7 +16,6 @@ import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.explorer.ExplorerRepository
|
||||
import kr.co.vividnext.sodalive.explorer.profile.cheers.PutModifyCheersRequest
|
||||
import kr.co.vividnext.sodalive.explorer.profile.creator_community.GetCommunityPostListResponse
|
||||
import kr.co.vividnext.sodalive.report.ReportRepository
|
||||
import kr.co.vividnext.sodalive.report.ReportRequest
|
||||
import kr.co.vividnext.sodalive.report.ReportType
|
||||
@@ -147,12 +146,14 @@ class UserProfileViewModel(
|
||||
)
|
||||
}
|
||||
|
||||
fun follow(creatorId: Long) {
|
||||
fun follow(creatorId: Long, follow: Boolean = true, notify: Boolean = true) {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
userRepository.creatorFollow(
|
||||
creatorId,
|
||||
"Bearer ${SharedPreferenceManager.token}"
|
||||
follow = follow,
|
||||
notify = notify,
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
@@ -88,8 +88,8 @@ class UserFollowerListViewModel(
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
userRepository.creatorFollow(
|
||||
creatorId,
|
||||
"Bearer ${SharedPreferenceManager.token}"
|
||||
creatorId = creatorId,
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
@@ -4,4 +4,8 @@ import androidx.annotation.Keep
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
@Keep
|
||||
data class CreatorFollowRequestRequest(@SerializedName("creatorId") val creatorId: Long)
|
||||
data class CreatorFollowRequestRequest(
|
||||
@SerializedName("creatorId") val creatorId: Long,
|
||||
@SerializedName("isNotify") val isNotify: Boolean = true,
|
||||
@SerializedName("isActive") val isActive: Boolean = true
|
||||
)
|
||||
|
||||
@@ -54,9 +54,15 @@ class UserRepository(private val userApi: UserApi) {
|
||||
|
||||
fun creatorFollow(
|
||||
creatorId: Long,
|
||||
follow: Boolean = true,
|
||||
notify: Boolean = true,
|
||||
token: String
|
||||
) = userApi.creatorFollow(
|
||||
request = CreatorFollowRequestRequest(creatorId = creatorId),
|
||||
request = CreatorFollowRequestRequest(
|
||||
creatorId = creatorId,
|
||||
isActive = follow,
|
||||
isNotify = notify
|
||||
),
|
||||
authHeader = token
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user