diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 774db06..46c67b6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -85,6 +85,7 @@
+
(
+ ActivityFollowingCreatorBinding::inflate
+) {
+ private val viewModel: FollowingCreatorViewModel by inject()
+
+ private lateinit var loadingDialog: LoadingDialog
+ private lateinit var adapter: FollowingCreatorAdapter
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ bindData()
+ viewModel.getFollowedCreatorAllList()
+ }
+
+ override fun setupView() {
+ loadingDialog = LoadingDialog(this, layoutInflater)
+ binding.toolbar.tvBack.text = "팔로잉 채널 리스트"
+ binding.toolbar.tvBack.setOnClickListener { finish() }
+
+ adapter = FollowingCreatorAdapter(
+ onClickItem = { creatorId ->
+ startActivity(
+ Intent(applicationContext, UserProfileActivity::class.java).apply {
+ putExtra(Constants.EXTRA_USER_ID, creatorId)
+ }
+ )
+ },
+ onClickRegisterNotification = { viewModel.registerNotification(it) },
+ onClickUnRegisterNotification = { viewModel.unRegisterNotification(it) }
+ )
+
+ binding.rvFollowingCreator.layoutManager = LinearLayoutManager(
+ applicationContext,
+ LinearLayoutManager.VERTICAL,
+ false
+ )
+
+ binding.rvFollowingCreator.addOnScrollListener(object : RecyclerView.OnScrollListener() {
+ override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
+ super.onScrolled(recyclerView, dx, dy)
+
+ val layoutManager = recyclerView.layoutManager as? LinearLayoutManager
+ if (
+ layoutManager != null &&
+ layoutManager.findLastCompletelyVisibleItemPosition() == adapter.itemCount - 1
+ ) {
+ viewModel.getFollowedCreatorAllList()
+ }
+ }
+ })
+
+ binding.rvFollowingCreator.addItemDecoration(object : RecyclerView.ItemDecoration() {
+ override fun getItemOffsets(
+ outRect: Rect,
+ view: View,
+ parent: RecyclerView,
+ state: RecyclerView.State
+ ) {
+ super.getItemOffsets(outRect, view, parent, state)
+
+ outRect.left = 13.3f.dpToPx().toInt()
+ outRect.right = 13.3f.dpToPx().toInt()
+ }
+ })
+
+ binding.rvFollowingCreator.adapter = adapter
+ }
+
+ @SuppressLint("SetTextI18n")
+ private fun bindData() {
+ viewModel.toastLiveData.observe(this) {
+ it?.let { Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show() }
+ }
+
+ viewModel.isLoading.observe(this) {
+ if (it) {
+ loadingDialog.show(screenWidth, "")
+ } else {
+ loadingDialog.dismiss()
+ }
+ }
+
+ viewModel.creatorListLiveData.observe(this) {
+ adapter.addAll(it)
+ }
+
+ viewModel.creatorListTotalCountLiveData.observe(this) {
+ binding.tvTotalCount.text = " $it "
+ }
+ }
+}
diff --git a/app/src/main/java/kr/co/vividnext/sodalive/following/FollowingCreatorAdapter.kt b/app/src/main/java/kr/co/vividnext/sodalive/following/FollowingCreatorAdapter.kt
new file mode 100644
index 0000000..77df191
--- /dev/null
+++ b/app/src/main/java/kr/co/vividnext/sodalive/following/FollowingCreatorAdapter.kt
@@ -0,0 +1,83 @@
+package kr.co.vividnext.sodalive.following
+
+import android.annotation.SuppressLint
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.recyclerview.widget.RecyclerView
+import coil.load
+import coil.transform.CircleCropTransformation
+import kr.co.vividnext.sodalive.R
+import kr.co.vividnext.sodalive.databinding.ItemFollowerListBinding
+
+class FollowingCreatorAdapter(
+ private val onClickItem: (Long) -> Unit,
+ private val onClickRegisterNotification: (Long) -> Unit,
+ private val onClickUnRegisterNotification: (Long) -> Unit,
+) : RecyclerView.Adapter() {
+
+ private val items = mutableListOf()
+
+ inner class ViewHolder(
+ private val binding: ItemFollowerListBinding
+ ) : RecyclerView.ViewHolder(binding.root) {
+ @SuppressLint("NotifyDataSetChanged")
+ fun bind(item: GetCreatorFollowingAllListItem) {
+ binding.tvNickname.text = item.nickname
+ binding.ivProfile.load(item.profileImageUrl) {
+ transformations(CircleCropTransformation())
+ placeholder(R.drawable.bg_placeholder)
+ crossfade(true)
+ }
+
+ binding.ivNotification.visibility = View.VISIBLE
+ if (item.isFollow) {
+ binding.ivNotification.setImageResource(R.drawable.btn_notification_selected)
+ binding.ivNotification.setOnClickListener {
+ val index = items.indexOf(item)
+ val copyItem = item.copy(isFollow = false)
+ items.add(index, copyItem)
+ items.removeAt(index + 1)
+ notifyDataSetChanged()
+ onClickUnRegisterNotification(item.creatorId)
+ }
+ } else {
+ binding.ivNotification.setImageResource(R.drawable.btn_notification)
+ binding.ivNotification.setOnClickListener {
+ val index = items.indexOf(item)
+ val copyItem = item.copy(isFollow = true)
+ items.add(index, copyItem)
+ items.removeAt(index + 1)
+ notifyDataSetChanged()
+ onClickRegisterNotification(item.creatorId)
+ }
+ }
+
+ binding.root.setOnClickListener { onClickItem(item.creatorId) }
+ }
+ }
+
+ @SuppressLint("NotifyDataSetChanged")
+ fun addAll(items: List) {
+ this.items.addAll(items)
+ notifyDataSetChanged()
+ }
+
+ fun clear() {
+ this.items.clear()
+ }
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ViewHolder(
+ ItemFollowerListBinding.inflate(
+ LayoutInflater.from(parent.context),
+ parent,
+ false
+ )
+ )
+
+ override fun onBindViewHolder(holder: ViewHolder, position: Int) {
+ holder.bind(items[position])
+ }
+
+ override fun getItemCount() = items.size
+}
diff --git a/app/src/main/java/kr/co/vividnext/sodalive/following/FollowingCreatorRepository.kt b/app/src/main/java/kr/co/vividnext/sodalive/following/FollowingCreatorRepository.kt
new file mode 100644
index 0000000..e33bdd6
--- /dev/null
+++ b/app/src/main/java/kr/co/vividnext/sodalive/following/FollowingCreatorRepository.kt
@@ -0,0 +1,32 @@
+package kr.co.vividnext.sodalive.following
+
+import kr.co.vividnext.sodalive.live.recommend.LiveRecommendApi
+import kr.co.vividnext.sodalive.user.CreatorFollowRequestRequest
+import kr.co.vividnext.sodalive.user.UserApi
+
+class FollowingCreatorRepository(
+ private val api: LiveRecommendApi,
+ private val userApi: UserApi
+) {
+ fun getFollowedCreatorAllList(
+ page: Int,
+ size: Int,
+ token: String
+ ) = api.getCreatorFollowingAllList(page = page - 1, size = size, authHeader = token)
+
+ fun registerNotification(
+ creatorId: Long,
+ token: String
+ ) = userApi.creatorFollow(
+ request = CreatorFollowRequestRequest(creatorId = creatorId),
+ authHeader = token
+ )
+
+ fun unRegisterNotification(
+ creatorId: Long,
+ token: String
+ ) = userApi.creatorUnFollow(
+ request = CreatorFollowRequestRequest(creatorId = creatorId),
+ authHeader = token
+ )
+}
diff --git a/app/src/main/java/kr/co/vividnext/sodalive/following/FollowingCreatorViewModel.kt b/app/src/main/java/kr/co/vividnext/sodalive/following/FollowingCreatorViewModel.kt
new file mode 100644
index 0000000..85a376f
--- /dev/null
+++ b/app/src/main/java/kr/co/vividnext/sodalive/following/FollowingCreatorViewModel.kt
@@ -0,0 +1,106 @@
+package kr.co.vividnext.sodalive.following
+
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+import com.orhanobut.logger.Logger
+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
+
+class FollowingCreatorViewModel(
+ private val repository: FollowingCreatorRepository
+) : BaseViewModel() {
+
+ private val _creatorListLiveData = MutableLiveData>()
+ val creatorListLiveData: LiveData>
+ get() = _creatorListLiveData
+
+ private val _creatorListTotalCountLiveData = MutableLiveData()
+ val creatorListTotalCountLiveData: LiveData
+ get() = _creatorListTotalCountLiveData
+
+ private var _isLoading = MutableLiveData(false)
+ val isLoading: LiveData
+ get() = _isLoading
+
+ private val _toastLiveData = MutableLiveData()
+ val toastLiveData: LiveData
+ get() = _toastLiveData
+
+ var page = 1
+ var isLast = false
+ private val pageSize = 10
+
+ fun getFollowedCreatorAllList() {
+ if (!isLast && !_isLoading.value!!) {
+ _isLoading.value = true
+
+ compositeDisposable.add(
+ repository.getFollowedCreatorAllList(
+ page = page,
+ size = pageSize,
+ token = "Bearer ${SharedPreferenceManager.token}"
+ )
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(
+ {
+ _isLoading.value = false
+ if (it.success && it.data != null) {
+ val data = it.data
+ if (data.items.isEmpty()) {
+ isLast = true
+ } else {
+ page += 1
+ _creatorListTotalCountLiveData.value = data.totalCount
+ _creatorListLiveData.value = data.items
+ }
+ } else {
+ if (it.message != null) {
+ _toastLiveData.postValue(it.message)
+ } else {
+ _toastLiveData.postValue(
+ "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
+ )
+ }
+ }
+ },
+ {
+ _isLoading.value = false
+ it.message?.let { message -> Logger.e(message) }
+ _toastLiveData.postValue(
+ "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
+ )
+ }
+ )
+ )
+ }
+ }
+
+ fun registerNotification(creatorId: Long) {
+ _creatorListTotalCountLiveData.value = _creatorListTotalCountLiveData.value!! + 1
+ compositeDisposable.add(
+ repository.registerNotification(
+ creatorId,
+ "Bearer ${SharedPreferenceManager.token}"
+ )
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe({}, {})
+ )
+ }
+
+ fun unRegisterNotification(creatorId: Long) {
+ _creatorListTotalCountLiveData.value = _creatorListTotalCountLiveData.value!! - 1
+ compositeDisposable.add(
+ repository.unRegisterNotification(
+ creatorId,
+ "Bearer ${SharedPreferenceManager.token}"
+ )
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe({}, {})
+ )
+ }
+}
diff --git a/app/src/main/java/kr/co/vividnext/sodalive/following/GetCreatorFollowingAllListResponse.kt b/app/src/main/java/kr/co/vividnext/sodalive/following/GetCreatorFollowingAllListResponse.kt
new file mode 100644
index 0000000..d668fe7
--- /dev/null
+++ b/app/src/main/java/kr/co/vividnext/sodalive/following/GetCreatorFollowingAllListResponse.kt
@@ -0,0 +1,15 @@
+package kr.co.vividnext.sodalive.following
+
+import com.google.gson.annotations.SerializedName
+
+data class GetCreatorFollowingAllListResponse(
+ @SerializedName("totalCount") val totalCount: Int,
+ @SerializedName("items") val items: List
+)
+
+data class GetCreatorFollowingAllListItem(
+ @SerializedName("creatorId") val creatorId: Long,
+ @SerializedName("nickname") val nickname: String,
+ @SerializedName("profileImageUrl") val profileImageUrl: String,
+ @SerializedName("isFollow") val isFollow: Boolean
+)
diff --git a/app/src/main/java/kr/co/vividnext/sodalive/live/LiveFragment.kt b/app/src/main/java/kr/co/vividnext/sodalive/live/LiveFragment.kt
index 3b4e6d6..bfdc5a2 100644
--- a/app/src/main/java/kr/co/vividnext/sodalive/live/LiveFragment.kt
+++ b/app/src/main/java/kr/co/vividnext/sodalive/live/LiveFragment.kt
@@ -26,8 +26,10 @@ 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.FragmentLiveBinding
+import kr.co.vividnext.sodalive.explorer.profile.UserProfileActivity
import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.extensions.moneyFormat
+import kr.co.vividnext.sodalive.following.FollowingCreatorActivity
import kr.co.vividnext.sodalive.live.event_banner.EventBannerAdapter
import kr.co.vividnext.sodalive.live.now.LiveNowAdapter
import kr.co.vividnext.sodalive.live.recommend.RecommendLiveAdapter
@@ -195,8 +197,16 @@ class LiveFragment : BaseFragment(FragmentLiveBinding::infl
private fun setupRecommendChannel() {
liveRecommendChannelAdapter = LiveRecommendChannelAdapter(
- onClick = {},
- onClickMore = {}
+ onClick = {
+ startActivity(
+ Intent(requireContext(), UserProfileActivity::class.java).apply {
+ putExtra(Constants.EXTRA_USER_ID, it)
+ }
+ )
+ },
+ onClickMore = {
+ startActivity(Intent(requireContext(), FollowingCreatorActivity::class.java))
+ }
)
binding.layoutRecommendChannel.rvRecommendChannel.layoutManager = LinearLayoutManager(
diff --git a/app/src/main/java/kr/co/vividnext/sodalive/live/recommend/LiveRecommendApi.kt b/app/src/main/java/kr/co/vividnext/sodalive/live/recommend/LiveRecommendApi.kt
index 928e11a..a2628a3 100644
--- a/app/src/main/java/kr/co/vividnext/sodalive/live/recommend/LiveRecommendApi.kt
+++ b/app/src/main/java/kr/co/vividnext/sodalive/live/recommend/LiveRecommendApi.kt
@@ -3,9 +3,11 @@ package kr.co.vividnext.sodalive.live.recommend
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Single
import kr.co.vividnext.sodalive.common.ApiResponse
+import kr.co.vividnext.sodalive.following.GetCreatorFollowingAllListResponse
import kr.co.vividnext.sodalive.live.recommend_channel.GetRecommendChannelResponse
import retrofit2.http.GET
import retrofit2.http.Header
+import retrofit2.http.Query
interface LiveRecommendApi {
@GET("/live/recommend")
@@ -22,4 +24,11 @@ interface LiveRecommendApi {
fun getFollowingChannelList(
@Header("Authorization") authHeader: String
): Single>>
+
+ @GET("/live/recommend/following/channel/all/list")
+ fun getCreatorFollowingAllList(
+ @Query("page") page: Int,
+ @Query("size") size: Int,
+ @Header("Authorization") authHeader: String
+ ): Single>
}
diff --git a/app/src/main/res/layout/activity_following_creator.xml b/app/src/main/res/layout/activity_following_creator.xml
new file mode 100644
index 0000000..9f0b06b
--- /dev/null
+++ b/app/src/main/res/layout/activity_following_creator.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+