팔로잉 채널 전체보기 페이지 추가
This commit is contained in:
parent
f455aa81a2
commit
6d93da2136
|
@ -85,6 +85,7 @@
|
|||
<activity android:name=".audio_content.modify.AudioContentModifyActivity" />
|
||||
<activity android:name=".audio_content.order.AudioContentOrderListActivity" />
|
||||
<activity android:name=".audio_content.upload.AudioContentUploadActivity" />
|
||||
<activity android:name=".following.FollowingCreatorActivity" />
|
||||
|
||||
<activity
|
||||
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
|
||||
|
|
|
@ -23,6 +23,8 @@ import kr.co.vividnext.sodalive.explorer.ExplorerRepository
|
|||
import kr.co.vividnext.sodalive.explorer.ExplorerViewModel
|
||||
import kr.co.vividnext.sodalive.explorer.profile.UserProfileViewModel
|
||||
import kr.co.vividnext.sodalive.explorer.profile.follow.UserFollowerListViewModel
|
||||
import kr.co.vividnext.sodalive.following.FollowingCreatorRepository
|
||||
import kr.co.vividnext.sodalive.following.FollowingCreatorViewModel
|
||||
import kr.co.vividnext.sodalive.live.LiveApi
|
||||
import kr.co.vividnext.sodalive.live.LiveRepository
|
||||
import kr.co.vividnext.sodalive.live.LiveViewModel
|
||||
|
@ -171,6 +173,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
|
|||
viewModel { AudioContentDetailViewModel(get(), get(), get(), get()) }
|
||||
viewModel { AudioContentCommentListViewModel(get()) }
|
||||
viewModel { AudioContentCommentReplyViewModel(get()) }
|
||||
viewModel { FollowingCreatorViewModel(get()) }
|
||||
}
|
||||
|
||||
private val repositoryModule = module {
|
||||
|
@ -189,6 +192,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
|
|||
factory { AudioContentRepository(get(), get()) }
|
||||
factory { AudioContentCommentRepository(get()) }
|
||||
factory { PlaybackTrackingRepository(get()) }
|
||||
factory { FollowingCreatorRepository(get(), get()) }
|
||||
}
|
||||
|
||||
private val moduleList = listOf(
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
package kr.co.vividnext.sodalive.following
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
import kr.co.vividnext.sodalive.common.Constants
|
||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||
import kr.co.vividnext.sodalive.databinding.ActivityFollowingCreatorBinding
|
||||
import kr.co.vividnext.sodalive.explorer.profile.UserProfileActivity
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
class FollowingCreatorActivity : BaseActivity<ActivityFollowingCreatorBinding>(
|
||||
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 "
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<FollowingCreatorAdapter.ViewHolder>() {
|
||||
|
||||
private val items = mutableListOf<GetCreatorFollowingAllListItem>()
|
||||
|
||||
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<GetCreatorFollowingAllListItem>) {
|
||||
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
|
||||
}
|
|
@ -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
|
||||
)
|
||||
}
|
|
@ -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<List<GetCreatorFollowingAllListItem>>()
|
||||
val creatorListLiveData: LiveData<List<GetCreatorFollowingAllListItem>>
|
||||
get() = _creatorListLiveData
|
||||
|
||||
private val _creatorListTotalCountLiveData = MutableLiveData<Int>()
|
||||
val creatorListTotalCountLiveData: LiveData<Int>
|
||||
get() = _creatorListTotalCountLiveData
|
||||
|
||||
private var _isLoading = MutableLiveData(false)
|
||||
val isLoading: LiveData<Boolean>
|
||||
get() = _isLoading
|
||||
|
||||
private val _toastLiveData = MutableLiveData<String?>()
|
||||
val toastLiveData: LiveData<String?>
|
||||
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({}, {})
|
||||
)
|
||||
}
|
||||
}
|
|
@ -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<GetCreatorFollowingAllListItem>
|
||||
)
|
||||
|
||||
data class GetCreatorFollowingAllListItem(
|
||||
@SerializedName("creatorId") val creatorId: Long,
|
||||
@SerializedName("nickname") val nickname: String,
|
||||
@SerializedName("profileImageUrl") val profileImageUrl: String,
|
||||
@SerializedName("isFollow") val isFollow: Boolean
|
||||
)
|
|
@ -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>(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(
|
||||
|
|
|
@ -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<ApiResponse<List<GetRecommendChannelResponse>>>
|
||||
|
||||
@GET("/live/recommend/following/channel/all/list")
|
||||
fun getCreatorFollowingAllList(
|
||||
@Query("page") page: Int,
|
||||
@Query("size") size: Int,
|
||||
@Header("Authorization") authHeader: String
|
||||
): Single<ApiResponse<GetCreatorFollowingAllListResponse>>
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
layout="@layout/detail_toolbar" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_total_count"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="13.3dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="13.3dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/toolbar">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="총"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_total_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:textColor="@color/color_dd4500"
|
||||
android:textSize="12sp"
|
||||
tools:text=" 10" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="명"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_following_creator"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="13.3dp"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="13.3dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ll_total_count" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue