메인 라이브 탭 - 커뮤니티 포스트 영역 추가
This commit is contained in:
@@ -27,6 +27,7 @@ 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.explorer.profile.creator_community.CreatorCommunityAdapter
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import kr.co.vividnext.sodalive.extensions.moneyFormat
|
||||
import kr.co.vividnext.sodalive.following.FollowingCreatorActivity
|
||||
@@ -56,6 +57,7 @@ class LiveFragment : BaseFragment<FragmentLiveBinding>(FragmentLiveBinding::infl
|
||||
|
||||
private lateinit var liveNowAdapter: LiveNowAdapter
|
||||
private lateinit var liveReservationAdapter: LiveReservationAdapter
|
||||
private lateinit var creatorCommunityAdapter: CreatorCommunityAdapter
|
||||
private lateinit var liveRecommendChannelAdapter: LiveRecommendChannelAdapter
|
||||
|
||||
private lateinit var loadingDialog: LoadingDialog
|
||||
@@ -91,6 +93,7 @@ class LiveFragment : BaseFragment<FragmentLiveBinding>(FragmentLiveBinding::infl
|
||||
setupLiveNow()
|
||||
setupLiveReservation()
|
||||
setupEvent()
|
||||
setupCommunityPost()
|
||||
|
||||
message = "라이브를 불러오고 있습니다."
|
||||
viewModel.getSummary()
|
||||
@@ -494,6 +497,59 @@ class LiveFragment : BaseFragment<FragmentLiveBinding>(FragmentLiveBinding::infl
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun setupCommunityPost() {
|
||||
val recyclerView = binding.rvCommunityPost
|
||||
|
||||
recyclerView.layoutManager = LinearLayoutManager(
|
||||
requireContext(),
|
||||
LinearLayoutManager.HORIZONTAL,
|
||||
false
|
||||
)
|
||||
|
||||
recyclerView.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
|
||||
when (parent.getChildAdapterPosition(view)) {
|
||||
0 -> {
|
||||
outRect.left = 13.3f.dpToPx().toInt()
|
||||
outRect.right = 5.dpToPx().toInt()
|
||||
}
|
||||
|
||||
liveNowAdapter.itemCount - 1 -> {
|
||||
outRect.left = 6.7f.dpToPx().toInt()
|
||||
outRect.right = 13.3f.dpToPx().toInt()
|
||||
}
|
||||
|
||||
else -> {
|
||||
outRect.left = 6.7f.dpToPx().toInt()
|
||||
outRect.right = 6.7f.dpToPx().toInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
creatorCommunityAdapter = CreatorCommunityAdapter {}
|
||||
binding.rvCommunityPost.adapter = creatorCommunityAdapter
|
||||
|
||||
viewModel.communityPostItemLiveData.observe(viewLifecycleOwner) {
|
||||
if (it.isNotEmpty()) {
|
||||
binding.rvCommunityPost.visibility = View.VISIBLE
|
||||
creatorCommunityAdapter.items.clear()
|
||||
creatorCommunityAdapter.items.addAll(it)
|
||||
creatorCommunityAdapter.notifyDataSetChanged()
|
||||
} else {
|
||||
binding.rvCommunityPost.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startLive(roomId: Long) {
|
||||
val onEnterRoomSuccess = {
|
||||
viewModel.getSummary()
|
||||
|
||||
@@ -8,6 +8,8 @@ import io.reactivex.rxjava3.core.Flowable
|
||||
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.explorer.profile.creator_community.CreatorCommunityRepository
|
||||
import kr.co.vividnext.sodalive.explorer.profile.creator_community.GetCommunityPostListResponse
|
||||
import kr.co.vividnext.sodalive.live.recommend.GetRecommendLiveResponse
|
||||
import kr.co.vividnext.sodalive.live.recommend.LiveRecommendRepository
|
||||
import kr.co.vividnext.sodalive.live.recommend_channel.GetRecommendChannelResponse
|
||||
@@ -24,7 +26,8 @@ import kr.co.vividnext.sodalive.settings.event.EventRepository
|
||||
class LiveViewModel(
|
||||
private val repository: LiveRepository,
|
||||
private val eventRepository: EventRepository,
|
||||
private val liveRecommendRepository: LiveRecommendRepository
|
||||
private val liveRecommendRepository: LiveRecommendRepository,
|
||||
private val creatorCommunityRepository: CreatorCommunityRepository
|
||||
) : BaseViewModel() {
|
||||
private var _isLoading = MutableLiveData(false)
|
||||
val isLoading: LiveData<Boolean>
|
||||
@@ -60,6 +63,10 @@ class LiveViewModel(
|
||||
val eventLiveData: LiveData<List<EventItem>>
|
||||
get() = _eventLiveData
|
||||
|
||||
private val _communityPostItemLiveData = MutableLiveData<List<GetCommunityPostListResponse>>()
|
||||
val communityPostItemLiveData: LiveData<List<GetCommunityPostListResponse>>
|
||||
get() = _communityPostItemLiveData
|
||||
|
||||
var page = 1
|
||||
var isLast = false
|
||||
private val pageSize = 10
|
||||
@@ -135,6 +142,36 @@ class LiveViewModel(
|
||||
)
|
||||
}
|
||||
|
||||
private fun getLatestPostListFromCreatorsYouFollow() {
|
||||
compositeDisposable.add(
|
||||
creatorCommunityRepository.getLatestPostListFromCreatorsYouFollow(
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
if (it.success && it.data != null) {
|
||||
_communityPostItemLiveData.postValue(it.data!!)
|
||||
} 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 getSummary() {
|
||||
if (!_isLoading.value!!) {
|
||||
if (_isFollowedCreatorLive.value!!) {
|
||||
@@ -142,6 +179,7 @@ class LiveViewModel(
|
||||
} else {
|
||||
getRecommendChannelList()
|
||||
}
|
||||
getLatestPostListFromCreatorsYouFollow()
|
||||
|
||||
val liveNow = repository.roomList(
|
||||
status = LiveRoomStatus.NOW,
|
||||
|
||||
Reference in New Issue
Block a user