feat(main): 메인 탭 당겨서 새로고침을 추가한다
This commit is contained in:
@@ -48,6 +48,9 @@ class ChatMainFragment : BaseFragment<FragmentV2MainChatBinding>(
|
||||
private val chatRoomListAdapter = ChatRoomListAdapter { onChatRoomClick(it) }
|
||||
private lateinit var loadingDialog: LoadingDialog
|
||||
private var selectedFilter: ChatRoomFilter = ChatRoomFilter.ALL
|
||||
private var isChatPullRefreshing = false
|
||||
private var refreshingChatFilter: ChatRoomFilter? = null
|
||||
private var lastRenderedChatContentState: ChatRoomListUiState.Content? = null
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
@@ -58,12 +61,16 @@ class ChatMainFragment : BaseFragment<FragmentV2MainChatBinding>(
|
||||
selectedFilter = initialFilter
|
||||
setupFilterTabs(initialFilter)
|
||||
setupChatRooms()
|
||||
setupRefresh()
|
||||
bindViewModel()
|
||||
|
||||
viewModel.loadFirstPage(initialFilter)
|
||||
}
|
||||
|
||||
fun selectFilter(filter: ChatRoomFilter) {
|
||||
if (refreshingChatFilter != null && refreshingChatFilter != filter) {
|
||||
cancelChatPullRefresh()
|
||||
}
|
||||
selectedFilter = filter
|
||||
selectFilterTab(filter)
|
||||
viewModel.selectFilter(filter)
|
||||
@@ -108,6 +115,9 @@ class ChatMainFragment : BaseFragment<FragmentV2MainChatBinding>(
|
||||
)
|
||||
binding.viewChatFilterTabs.root.setOnTabSelectedListener { index ->
|
||||
val filter = ChatRoomFilter.fromTabIndex(index)
|
||||
if (refreshingChatFilter != null && refreshingChatFilter != filter) {
|
||||
cancelChatPullRefresh()
|
||||
}
|
||||
selectedFilter = filter
|
||||
viewModel.selectFilter(filter)
|
||||
binding.rvChatRooms.scrollToPosition(0)
|
||||
@@ -133,18 +143,60 @@ class ChatMainFragment : BaseFragment<FragmentV2MainChatBinding>(
|
||||
})
|
||||
}
|
||||
|
||||
private fun setupRefresh() {
|
||||
binding.swipeChatRooms.setOnChildScrollUpCallback { _, _ ->
|
||||
binding.rvChatRooms.canScrollVertically(-1)
|
||||
}
|
||||
binding.swipeChatRooms.setOnRefreshListener {
|
||||
isChatPullRefreshing = true
|
||||
refreshingChatFilter = selectedFilter
|
||||
viewModel.loadFirstPage(selectedFilter)
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindViewModel() {
|
||||
viewModel.chatRoomStateLiveData.observe(viewLifecycleOwner) { state ->
|
||||
val isRefreshForCurrentFilter = refreshingChatFilter == selectedFilter
|
||||
when (state) {
|
||||
is ChatRoomListUiState.Content -> {
|
||||
bindChatRooms(state.items, showEmpty = false)
|
||||
if (!state.isAppending) {
|
||||
val isRestoredPullRefreshError = isChatPullRefreshing &&
|
||||
isRefreshForCurrentFilter &&
|
||||
lastRenderedChatContentState === state
|
||||
val shouldScrollToTop = !isRestoredPullRefreshError &&
|
||||
((isChatPullRefreshing && isRefreshForCurrentFilter) || !state.isAppending)
|
||||
lastRenderedChatContentState = state
|
||||
if (isRefreshForCurrentFilter) {
|
||||
isChatPullRefreshing = false
|
||||
refreshingChatFilter = null
|
||||
}
|
||||
if (shouldScrollToTop) {
|
||||
binding.rvChatRooms.scrollToPosition(0)
|
||||
}
|
||||
}
|
||||
ChatRoomListUiState.Empty -> bindChatRooms(emptyList(), showEmpty = true)
|
||||
is ChatRoomListUiState.Error -> bindChatRooms(emptyList(), showEmpty = false)
|
||||
ChatRoomListUiState.Loading -> binding.tvChatEmptyMessage.isVisible = false
|
||||
ChatRoomListUiState.Empty -> {
|
||||
lastRenderedChatContentState = null
|
||||
bindChatRooms(emptyList(), showEmpty = true)
|
||||
if (isRefreshForCurrentFilter) {
|
||||
isChatPullRefreshing = false
|
||||
refreshingChatFilter = null
|
||||
}
|
||||
}
|
||||
is ChatRoomListUiState.Error -> {
|
||||
lastRenderedChatContentState = null
|
||||
if (!isChatPullRefreshing || !isRefreshForCurrentFilter) {
|
||||
bindChatRooms(emptyList(), showEmpty = false)
|
||||
}
|
||||
if (isRefreshForCurrentFilter) {
|
||||
isChatPullRefreshing = false
|
||||
refreshingChatFilter = null
|
||||
}
|
||||
}
|
||||
ChatRoomListUiState.Loading -> {
|
||||
if (!isChatPullRefreshing) {
|
||||
binding.tvChatEmptyMessage.isVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
viewModel.isLoading.observe(viewLifecycleOwner) {
|
||||
@@ -152,6 +204,7 @@ class ChatMainFragment : BaseFragment<FragmentV2MainChatBinding>(
|
||||
loadingDialog.show(screenWidth)
|
||||
} else {
|
||||
loadingDialog.dismiss()
|
||||
binding.swipeChatRooms.isRefreshing = false
|
||||
}
|
||||
}
|
||||
viewModel.toastLiveData.observe(viewLifecycleOwner) {
|
||||
@@ -162,6 +215,12 @@ class ChatMainFragment : BaseFragment<FragmentV2MainChatBinding>(
|
||||
}
|
||||
}
|
||||
|
||||
private fun cancelChatPullRefresh() {
|
||||
isChatPullRefreshing = false
|
||||
refreshingChatFilter = null
|
||||
binding.swipeChatRooms.isRefreshing = false
|
||||
}
|
||||
|
||||
private fun bindChatRooms(items: List<ChatRoomListUiItem>, showEmpty: Boolean) {
|
||||
chatRoomListAdapter.submitItems(items)
|
||||
binding.rvChatRooms.isVisible = !showEmpty
|
||||
|
||||
@@ -25,6 +25,7 @@ class ChatMainViewModel(
|
||||
private var nextCursor: String? = null
|
||||
private var hasMore: Boolean = false
|
||||
private var requestGeneration: Long = 0L
|
||||
private var activeFirstPageKey: ChatRoomFilter? = null
|
||||
|
||||
private val _chatRoomStateLiveData = MutableLiveData<ChatRoomListUiState>()
|
||||
val chatRoomStateLiveData: LiveData<ChatRoomListUiState>
|
||||
@@ -43,6 +44,15 @@ class ChatMainViewModel(
|
||||
get() = _isAppending
|
||||
|
||||
fun loadFirstPage(filter: ChatRoomFilter = currentFilter) {
|
||||
val requestKey = filter
|
||||
if (activeFirstPageKey == requestKey) return
|
||||
activeFirstPageKey = requestKey
|
||||
val previousState = _chatRoomStateLiveData.value
|
||||
val canRestoreOnError = filter == currentFilter &&
|
||||
(previousState is ChatRoomListUiState.Content || previousState is ChatRoomListUiState.Empty)
|
||||
val previousItems = currentItems
|
||||
val previousNextCursor = nextCursor
|
||||
val previousHasMore = hasMore
|
||||
currentFilter = filter
|
||||
requestGeneration += 1L
|
||||
val generation = requestGeneration
|
||||
@@ -53,6 +63,18 @@ class ChatMainViewModel(
|
||||
_isAppending.value = false
|
||||
_chatRoomStateLiveData.value = ChatRoomListUiState.Loading
|
||||
|
||||
fun showFirstPageError(message: String?) {
|
||||
if (canRestoreOnError) {
|
||||
currentItems = previousItems
|
||||
nextCursor = previousNextCursor
|
||||
hasMore = previousHasMore
|
||||
_chatRoomStateLiveData.value = previousState
|
||||
} else {
|
||||
_chatRoomStateLiveData.value = ChatRoomListUiState.Error(message = message)
|
||||
}
|
||||
_toastLiveData.value = ToastMessage(resId = R.string.common_error_unknown)
|
||||
}
|
||||
|
||||
compositeDisposable.add(
|
||||
repository.getChatRooms(
|
||||
token = authToken(),
|
||||
@@ -64,19 +86,21 @@ class ChatMainViewModel(
|
||||
.subscribe(
|
||||
{
|
||||
if (generation != requestGeneration) return@subscribe
|
||||
clearActiveFirstPageKey(requestKey, generation)
|
||||
_isLoading.value = false
|
||||
val data = it.data
|
||||
if (it.success && data != null) {
|
||||
handleFirstPageSuccess(data)
|
||||
} else {
|
||||
showUnknownError(it.message)
|
||||
showFirstPageError(it.message)
|
||||
}
|
||||
},
|
||||
{
|
||||
if (generation != requestGeneration) return@subscribe
|
||||
clearActiveFirstPageKey(requestKey, generation)
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
showUnknownError(it.message)
|
||||
showFirstPageError(it.message)
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -138,6 +162,12 @@ class ChatMainViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearActiveFirstPageKey(requestKey: ChatRoomFilter, generation: Long) {
|
||||
if (activeFirstPageKey == requestKey && requestGeneration == generation) {
|
||||
activeFirstPageKey = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleNextPageSuccess(data: ChatRoomListPageResponse) {
|
||||
currentItems = currentItems + data.rooms.toUiItems()
|
||||
hasMore = data.hasMore
|
||||
|
||||
+81
-18
@@ -23,6 +23,11 @@ import kr.co.vividnext.sodalive.v2.main.content.model.toUiModel
|
||||
import kr.co.vividnext.sodalive.v2.main.content.model.usesDayOfWeekQuery
|
||||
import kr.co.vividnext.sodalive.v2.main.content.model.usesSeriesItems
|
||||
|
||||
enum class ContentAllTabRefreshResult {
|
||||
Success,
|
||||
Failure
|
||||
}
|
||||
|
||||
class ContentAllTabViewModel(
|
||||
private val repository: MainContentAllTabRepository,
|
||||
private val currentDayOfWeekProvider: () -> SeriesPublishedDaysOfWeek = { currentDeviceDayOfWeek() }
|
||||
@@ -40,10 +45,15 @@ class ContentAllTabViewModel(
|
||||
val toastLiveData: LiveData<ToastMessage?>
|
||||
get() = _toastLiveData
|
||||
|
||||
private val _refreshResultLiveData = MutableLiveData<ContentAllTabRefreshResult>()
|
||||
val refreshResultLiveData: LiveData<ContentAllTabRefreshResult>
|
||||
get() = _refreshResultLiveData
|
||||
|
||||
private var selectedType: MainContentAllType = MainContentAllType.AUDIO
|
||||
private var selectedSort: ContentSort = ContentSort.LATEST
|
||||
private var selectedDayOfWeek: SeriesPublishedDaysOfWeek? = null
|
||||
private var requestGeneration: Int = 0
|
||||
private var activeFirstPageKey: FirstPageRequestKey? = null
|
||||
|
||||
fun loadContents() {
|
||||
loadFirstPage(selectedType, selectedSort, selectedDayOfWeekFor(selectedType))
|
||||
@@ -121,28 +131,58 @@ class ContentAllTabViewModel(
|
||||
sort: ContentSort,
|
||||
dayOfWeek: SeriesPublishedDaysOfWeek?
|
||||
) {
|
||||
val requestKey = FirstPageRequestKey(type, sort, dayOfWeek)
|
||||
if (activeFirstPageKey == requestKey) return
|
||||
activeFirstPageKey = requestKey
|
||||
val previousContent = (_allTabStateLiveData.value as? MainContentAllTabUiState.Content)
|
||||
?.takeIf { it.matches(type, sort, dayOfWeek) }
|
||||
?.copy(isLoadingMore = false, paginationErrorMessage = null)
|
||||
val generation = ++requestGeneration
|
||||
_isLoading.value = true
|
||||
_allTabStateLiveData.value = MainContentAllTabUiState.Loading(type, sort, dayOfWeek, totalCount = 0)
|
||||
requestContents(type, sort, FIRST_PAGE, dayOfWeek, generation) { response ->
|
||||
_isLoading.value = false
|
||||
val data = response.data
|
||||
if (response.success && data != null) {
|
||||
val content = data.toContent()
|
||||
_allTabStateLiveData.value = if (content.isSelectedTypeEmpty()) {
|
||||
MainContentAllTabUiState.Empty(
|
||||
content.selectedType,
|
||||
content.selectedSort,
|
||||
content.selectedDayOfWeek,
|
||||
content.totalCount
|
||||
)
|
||||
} else {
|
||||
content
|
||||
}
|
||||
|
||||
fun showFirstPageError(message: String?) {
|
||||
_refreshResultLiveData.value = ContentAllTabRefreshResult.Failure
|
||||
if (previousContent != null) {
|
||||
_allTabStateLiveData.value = previousContent
|
||||
_toastLiveData.value = ToastMessage(resId = R.string.common_error_unknown)
|
||||
} else {
|
||||
showFirstPageError(type, sort, dayOfWeek, response.message)
|
||||
showFirstPageError(type, sort, dayOfWeek, message)
|
||||
}
|
||||
}
|
||||
|
||||
requestContents(
|
||||
type = type,
|
||||
sort = sort,
|
||||
page = FIRST_PAGE,
|
||||
dayOfWeek = dayOfWeek,
|
||||
generation = generation,
|
||||
onSuccess = { response ->
|
||||
clearActiveFirstPageKey(requestKey, generation)
|
||||
_isLoading.value = false
|
||||
val data = response.data
|
||||
if (response.success && data != null) {
|
||||
_refreshResultLiveData.value = ContentAllTabRefreshResult.Success
|
||||
val content = data.toContent()
|
||||
_allTabStateLiveData.value = if (content.isSelectedTypeEmpty()) {
|
||||
MainContentAllTabUiState.Empty(
|
||||
content.selectedType,
|
||||
content.selectedSort,
|
||||
content.selectedDayOfWeek,
|
||||
content.totalCount
|
||||
)
|
||||
} else {
|
||||
content
|
||||
}
|
||||
} else {
|
||||
showFirstPageError(response.message)
|
||||
}
|
||||
},
|
||||
onFirstPageError = { message ->
|
||||
clearActiveFirstPageKey(requestKey, generation)
|
||||
showFirstPageError(message)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun requestContents(
|
||||
@@ -151,6 +191,7 @@ class ContentAllTabViewModel(
|
||||
page: Int,
|
||||
dayOfWeek: SeriesPublishedDaysOfWeek?,
|
||||
generation: Int,
|
||||
onFirstPageError: ((String?) -> Unit)? = null,
|
||||
onSuccess: (ApiResponse<MainContentAllTabResponse>) -> Unit
|
||||
) {
|
||||
compositeDisposable.add(
|
||||
@@ -164,7 +205,9 @@ class ContentAllTabViewModel(
|
||||
}
|
||||
},
|
||||
{
|
||||
if (generation != requestGeneration) return@subscribe
|
||||
if (generation != requestGeneration) {
|
||||
return@subscribe
|
||||
}
|
||||
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_isLoading.value = false
|
||||
@@ -175,7 +218,7 @@ class ContentAllTabViewModel(
|
||||
paginationErrorMessage = it.message
|
||||
)
|
||||
} else {
|
||||
showFirstPageError(type, sort, dayOfWeek, it.message)
|
||||
onFirstPageError?.invoke(it.message) ?: showFirstPageError(type, sort, dayOfWeek, it.message)
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -186,10 +229,24 @@ class ContentAllTabViewModel(
|
||||
return if (type.usesDayOfWeekQuery()) selectedDayOfWeek ?: currentDayOfWeekProvider() else null
|
||||
}
|
||||
|
||||
private fun clearActiveFirstPageKey(requestKey: FirstPageRequestKey, generation: Int) {
|
||||
if (activeFirstPageKey == requestKey && requestGeneration == generation) {
|
||||
activeFirstPageKey = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun MainContentAllTabUiState.Content.isSelectedTypeEmpty(): Boolean {
|
||||
return if (selectedType.usesSeriesItems()) seriesItems.isEmpty() else audioItems.isEmpty()
|
||||
}
|
||||
|
||||
private fun MainContentAllTabUiState.Content.matches(
|
||||
type: MainContentAllType,
|
||||
sort: ContentSort,
|
||||
dayOfWeek: SeriesPublishedDaysOfWeek?
|
||||
): Boolean {
|
||||
return selectedType == type && selectedSort == sort && selectedDayOfWeek == dayOfWeek
|
||||
}
|
||||
|
||||
private fun MainContentAllTabUiState.Content.append(
|
||||
data: MainContentAllTabResponse
|
||||
): MainContentAllTabUiState.Content {
|
||||
@@ -241,4 +298,10 @@ class ContentAllTabViewModel(
|
||||
const val DEFAULT_PAGE_SIZE = 20
|
||||
private const val FIRST_PAGE = 0
|
||||
}
|
||||
|
||||
private data class FirstPageRequestKey(
|
||||
val type: MainContentAllType,
|
||||
val sort: ContentSort,
|
||||
val dayOfWeek: SeriesPublishedDaysOfWeek?
|
||||
)
|
||||
}
|
||||
|
||||
+143
-15
@@ -112,6 +112,11 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
private var currentContentTab = CONTENT_TAB_RECOMMENDATION
|
||||
private var currentAllTabState: MainContentAllTabUiState? = null
|
||||
private var pendingAllTabSelection: ContentAllTabSelection? = null
|
||||
private var isContentPullRefreshing = false
|
||||
private var refreshingContentTab: Int? = null
|
||||
private var hasRenderedAllTabContent = false
|
||||
private var lastRenderedContentRecommendationState: AudioRecommendationsUiState.Content? = null
|
||||
private var lastRenderedContentRankingState: AudioRankingsUiState.Content? = null
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
@@ -124,6 +129,7 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
showContentTab(CONTENT_TAB_RECOMMENDATION)
|
||||
setUpSectionTitles()
|
||||
setUpAdapters()
|
||||
setUpRefreshLayouts()
|
||||
bindObservers()
|
||||
contentMainViewModel.loadRecommendations()
|
||||
applyPendingAllTabSelection()
|
||||
@@ -249,16 +255,16 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
}
|
||||
|
||||
private fun showRecommendationContent() {
|
||||
binding.nsvContentRecommendationContent.visibility = View.VISIBLE
|
||||
binding.swipeContentRecommendation.visibility = View.VISIBLE
|
||||
binding.viewContentRankingTypeTabs.root.visibility = View.GONE
|
||||
binding.rvContentRankings.visibility = View.GONE
|
||||
binding.swipeContentRanking.visibility = View.GONE
|
||||
binding.layoutContentAllSurface.visibility = View.GONE
|
||||
}
|
||||
|
||||
private fun showRankingContent() {
|
||||
binding.nsvContentRecommendationContent.visibility = View.GONE
|
||||
binding.swipeContentRecommendation.visibility = View.GONE
|
||||
binding.viewContentRankingTypeTabs.root.visibility = View.VISIBLE
|
||||
binding.rvContentRankings.visibility = View.VISIBLE
|
||||
binding.swipeContentRanking.visibility = View.VISIBLE
|
||||
binding.layoutContentAllSurface.visibility = View.GONE
|
||||
if (!hasSelectedRankingTab) {
|
||||
hasSelectedRankingTab = true
|
||||
@@ -267,9 +273,9 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
}
|
||||
|
||||
private fun showAllContent() {
|
||||
binding.nsvContentRecommendationContent.visibility = View.GONE
|
||||
binding.swipeContentRecommendation.visibility = View.GONE
|
||||
binding.viewContentRankingTypeTabs.root.visibility = View.GONE
|
||||
binding.rvContentRankings.visibility = View.GONE
|
||||
binding.swipeContentRanking.visibility = View.GONE
|
||||
binding.layoutContentAllSurface.visibility = View.VISIBLE
|
||||
currentAllTabState?.let(::renderAllTabState)
|
||||
if (currentAllTabState == null && !hasSelectedAllTab) {
|
||||
@@ -279,9 +285,9 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
}
|
||||
|
||||
private fun hideContentSurfaces() {
|
||||
binding.nsvContentRecommendationContent.visibility = View.GONE
|
||||
binding.swipeContentRecommendation.visibility = View.GONE
|
||||
binding.viewContentRankingTypeTabs.root.visibility = View.GONE
|
||||
binding.rvContentRankings.visibility = View.GONE
|
||||
binding.swipeContentRanking.visibility = View.GONE
|
||||
binding.layoutContentAllSurface.visibility = View.GONE
|
||||
}
|
||||
|
||||
@@ -351,12 +357,90 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUpRefreshLayouts() {
|
||||
binding.swipeContentRecommendation.setOnRefreshListener { refreshCurrentContentTab() }
|
||||
binding.swipeContentRanking.setOnRefreshListener { refreshCurrentContentTab() }
|
||||
binding.swipeContentAll.setOnChildScrollUpCallback { _, _ ->
|
||||
binding.rvContentAllItems.canScrollVertically(-1)
|
||||
}
|
||||
binding.swipeContentAll.setOnRefreshListener { refreshCurrentContentTab() }
|
||||
}
|
||||
|
||||
private fun refreshCurrentContentTab() {
|
||||
isContentPullRefreshing = true
|
||||
refreshingContentTab = currentContentTab
|
||||
when (currentContentTab) {
|
||||
CONTENT_TAB_RECOMMENDATION -> contentMainViewModel.loadRecommendations()
|
||||
CONTENT_TAB_RANKING -> refreshCurrentRankingTab()
|
||||
CONTENT_TAB_ALL -> contentAllTabViewModel.loadContents()
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshCurrentRankingTab() {
|
||||
val type = contentRankingViewModel.selectedTypeLiveData.value ?: AudioRankingType.WEEKLY_POPULAR
|
||||
contentRankingViewModel.loadRankings(type, force = true)
|
||||
}
|
||||
|
||||
private fun finishContentPullRefresh(tab: Int, isRestoredPullRefreshError: Boolean = false) {
|
||||
if (!isContentPullRefreshing) return
|
||||
if (refreshingContentTab != tab) return
|
||||
if (!isRestoredPullRefreshError) {
|
||||
scrollContentTabToTop(tab)
|
||||
}
|
||||
when (tab) {
|
||||
CONTENT_TAB_RECOMMENDATION -> binding.swipeContentRecommendation.isRefreshing = false
|
||||
CONTENT_TAB_RANKING -> binding.swipeContentRanking.isRefreshing = false
|
||||
CONTENT_TAB_ALL -> binding.swipeContentAll.isRefreshing = false
|
||||
}
|
||||
isContentPullRefreshing = false
|
||||
refreshingContentTab = null
|
||||
}
|
||||
|
||||
private fun cancelContentPullRefresh(tab: Int? = refreshingContentTab) {
|
||||
when (tab) {
|
||||
CONTENT_TAB_RECOMMENDATION -> binding.swipeContentRecommendation.isRefreshing = false
|
||||
CONTENT_TAB_RANKING -> binding.swipeContentRanking.isRefreshing = false
|
||||
CONTENT_TAB_ALL -> binding.swipeContentAll.isRefreshing = false
|
||||
}
|
||||
isContentPullRefreshing = false
|
||||
refreshingContentTab = null
|
||||
}
|
||||
|
||||
private fun shouldPreserveContentOnPullRefreshError(tab: Int): Boolean {
|
||||
if (!isContentPullRefreshing) return false
|
||||
if (refreshingContentTab != tab) return false
|
||||
cancelContentPullRefresh(tab)
|
||||
return true
|
||||
}
|
||||
|
||||
private fun scrollContentTabToTop(tab: Int) {
|
||||
when (tab) {
|
||||
CONTENT_TAB_RECOMMENDATION -> binding.nsvContentRecommendationContent.scrollTo(0, 0)
|
||||
CONTENT_TAB_RANKING -> binding.rvContentRankings.scrollToPosition(0)
|
||||
CONTENT_TAB_ALL -> binding.rvContentAllItems.scrollToPosition(0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindObservers() {
|
||||
contentMainViewModel.recommendationsStateLiveData.observe(viewLifecycleOwner) { state ->
|
||||
when (state) {
|
||||
is AudioRecommendationsUiState.Content -> bindContent(state)
|
||||
AudioRecommendationsUiState.Empty,
|
||||
is AudioRecommendationsUiState.Error -> bindContent(emptyContent())
|
||||
is AudioRecommendationsUiState.Content -> {
|
||||
val isRestoredPullRefreshError = isContentPullRefreshing &&
|
||||
refreshingContentTab == CONTENT_TAB_RECOMMENDATION &&
|
||||
lastRenderedContentRecommendationState === state
|
||||
bindContent(state)
|
||||
lastRenderedContentRecommendationState = state
|
||||
finishContentPullRefresh(CONTENT_TAB_RECOMMENDATION, isRestoredPullRefreshError)
|
||||
}
|
||||
AudioRecommendationsUiState.Empty -> {
|
||||
lastRenderedContentRecommendationState = null
|
||||
bindContent(emptyContent())
|
||||
finishContentPullRefresh(CONTENT_TAB_RECOMMENDATION)
|
||||
}
|
||||
is AudioRecommendationsUiState.Error -> {
|
||||
if (shouldPreserveContentOnPullRefreshError(CONTENT_TAB_RECOMMENDATION)) return@observe
|
||||
bindContent(emptyContent())
|
||||
}
|
||||
|
||||
AudioRecommendationsUiState.Loading -> Unit
|
||||
}
|
||||
@@ -370,9 +454,23 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
}
|
||||
contentRankingViewModel.rankingStateLiveData.observe(viewLifecycleOwner) { state ->
|
||||
when (state) {
|
||||
is AudioRankingsUiState.Content -> contentRankingAdapter.submitItems(state.items)
|
||||
is AudioRankingsUiState.Empty,
|
||||
is AudioRankingsUiState.Error -> contentRankingAdapter.submitItems(emptyList())
|
||||
is AudioRankingsUiState.Content -> {
|
||||
val isRestoredPullRefreshError = isContentPullRefreshing &&
|
||||
refreshingContentTab == CONTENT_TAB_RANKING &&
|
||||
lastRenderedContentRankingState === state
|
||||
contentRankingAdapter.submitItems(state.items)
|
||||
lastRenderedContentRankingState = state
|
||||
finishContentPullRefresh(CONTENT_TAB_RANKING, isRestoredPullRefreshError)
|
||||
}
|
||||
is AudioRankingsUiState.Empty -> {
|
||||
lastRenderedContentRankingState = null
|
||||
contentRankingAdapter.submitItems(emptyList())
|
||||
finishContentPullRefresh(CONTENT_TAB_RANKING)
|
||||
}
|
||||
is AudioRankingsUiState.Error -> {
|
||||
if (shouldPreserveContentOnPullRefreshError(CONTENT_TAB_RANKING)) return@observe
|
||||
contentRankingAdapter.submitItems(emptyList())
|
||||
}
|
||||
|
||||
AudioRankingsUiState.Loading -> Unit
|
||||
}
|
||||
@@ -385,6 +483,14 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
toastMessage?.let(::showToast)
|
||||
}
|
||||
contentAllTabViewModel.allTabStateLiveData.observe(viewLifecycleOwner) { state ->
|
||||
val isAllTabPullRefresh = isContentPullRefreshing && refreshingContentTab == CONTENT_TAB_ALL
|
||||
if (state is MainContentAllTabUiState.Loading && isAllTabPullRefresh && hasRenderedAllTabContent) {
|
||||
return@observe
|
||||
}
|
||||
if (state is MainContentAllTabUiState.Error && isAllTabPullRefresh && hasRenderedAllTabContent) {
|
||||
cancelContentPullRefresh()
|
||||
return@observe
|
||||
}
|
||||
currentAllTabState = state
|
||||
renderAllTabState(state)
|
||||
}
|
||||
@@ -395,6 +501,13 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
contentAllTabViewModel.toastLiveData.observe(viewLifecycleOwner) { toastMessage ->
|
||||
toastMessage?.let(::showToast)
|
||||
}
|
||||
contentAllTabViewModel.refreshResultLiveData.observe(viewLifecycleOwner) { result ->
|
||||
if (!isContentPullRefreshing || refreshingContentTab != CONTENT_TAB_ALL) return@observe
|
||||
when (result) {
|
||||
ContentAllTabRefreshResult.Success -> finishContentPullRefresh(CONTENT_TAB_ALL)
|
||||
ContentAllTabRefreshResult.Failure -> cancelContentPullRefresh(CONTENT_TAB_ALL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderAllTabState(state: MainContentAllTabUiState) {
|
||||
@@ -409,6 +522,7 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
}
|
||||
|
||||
private fun bindAllTabContent(state: MainContentAllTabUiState.Content) {
|
||||
hasRenderedAllTabContent = true
|
||||
bindAllTabControls(state)
|
||||
binding.layoutContentAllSurface.visibility = View.VISIBLE
|
||||
hideAllTabEmptyError()
|
||||
@@ -422,8 +536,14 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
contentAllSeriesCardAdapter.submitItems(emptyList())
|
||||
contentAllAudioCardAdapter.submitItems(state.audioItems)
|
||||
}
|
||||
state.paginationErrorMessage?.let { message ->
|
||||
val paginationErrorMessage = state.paginationErrorMessage
|
||||
paginationErrorMessage?.let { message ->
|
||||
showToast(message)
|
||||
if (isContentPullRefreshing && refreshingContentTab == CONTENT_TAB_ALL) {
|
||||
cancelContentPullRefresh()
|
||||
contentAllTabViewModel.consumePaginationErrorMessage()
|
||||
return
|
||||
}
|
||||
contentAllTabViewModel.consumePaginationErrorMessage()
|
||||
}
|
||||
}
|
||||
@@ -448,14 +568,21 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
}
|
||||
|
||||
private fun bindAllTabEmpty(state: MainContentAllTabUiState.Empty) {
|
||||
hasRenderedAllTabContent = false
|
||||
bindAllTabControls(state)
|
||||
binding.layoutContentAllSurface.visibility = View.VISIBLE
|
||||
binding.layoutContentAllEmptyError.visibility = View.VISIBLE
|
||||
binding.tvContentAllEmptyError.setText(R.string.screen_content_all_empty)
|
||||
clearAllTabItems()
|
||||
finishContentPullRefresh(CONTENT_TAB_ALL)
|
||||
}
|
||||
|
||||
private fun bindAllTabError(state: MainContentAllTabUiState.Error) {
|
||||
if (isContentPullRefreshing && refreshingContentTab == CONTENT_TAB_ALL && hasRenderedAllTabContent) {
|
||||
cancelContentPullRefresh()
|
||||
return
|
||||
}
|
||||
hasRenderedAllTabContent = false
|
||||
bindAllTabControls(state)
|
||||
binding.layoutContentAllSurface.visibility = View.VISIBLE
|
||||
binding.layoutContentAllEmptyError.visibility = View.VISIBLE
|
||||
@@ -467,6 +594,7 @@ class ContentMainFragment : BaseFragment<FragmentV2MainContentBinding>(
|
||||
bindAllTabControls(state)
|
||||
binding.layoutContentAllSurface.visibility = View.VISIBLE
|
||||
hideAllTabEmptyError()
|
||||
if (isContentPullRefreshing && refreshingContentTab == CONTENT_TAB_ALL && hasRenderedAllTabContent) return
|
||||
clearAllTabItems()
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,13 @@ class ContentMainViewModel(
|
||||
val isLoading: LiveData<Boolean>
|
||||
get() = _isLoading
|
||||
|
||||
private var requestGeneration: Int = 0
|
||||
|
||||
fun loadRecommendations() {
|
||||
if (_isLoading.value == true) return
|
||||
|
||||
val previousState = _recommendationsStateLiveData.value
|
||||
val generation = ++requestGeneration
|
||||
_isLoading.value = true
|
||||
_recommendationsStateLiveData.value = AudioRecommendationsUiState.Loading
|
||||
|
||||
@@ -39,6 +45,8 @@ class ContentMainViewModel(
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
if (generation != requestGeneration) return@subscribe
|
||||
|
||||
_isLoading.value = false
|
||||
val data = it.data
|
||||
if (it.success && data != null) {
|
||||
@@ -49,20 +57,22 @@ class ContentMainViewModel(
|
||||
content
|
||||
}
|
||||
} else {
|
||||
showUnknownError(it.message)
|
||||
showUnknownError(it.message, previousState)
|
||||
}
|
||||
},
|
||||
{
|
||||
if (generation != requestGeneration) return@subscribe
|
||||
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
showUnknownError(it.message)
|
||||
showUnknownError(it.message, previousState)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun showUnknownError(message: String?) {
|
||||
_recommendationsStateLiveData.value = AudioRecommendationsUiState.Error(message = message)
|
||||
private fun showUnknownError(message: String?, fallbackState: AudioRecommendationsUiState? = null) {
|
||||
_recommendationsStateLiveData.value = fallbackState ?: AudioRecommendationsUiState.Error(message = message)
|
||||
_toastLiveData.postValue(ToastMessage(resId = R.string.common_error_unknown))
|
||||
}
|
||||
|
||||
|
||||
+23
-5
@@ -19,6 +19,7 @@ class ContentRankingViewModel(
|
||||
) : BaseViewModel() {
|
||||
|
||||
private val cachedStates = mutableMapOf<AudioRankingType, AudioRankingsUiState>()
|
||||
private var activeFirstPageKey: AudioRankingType? = null
|
||||
private var latestRequestId = 0L
|
||||
|
||||
private val _rankingStateLiveData = MutableLiveData<AudioRankingsUiState>()
|
||||
@@ -39,13 +40,18 @@ class ContentRankingViewModel(
|
||||
|
||||
fun loadRankings(type: AudioRankingType, force: Boolean = false) {
|
||||
_selectedTypeLiveData.value = type
|
||||
val requestId = ++latestRequestId
|
||||
val cachedState = cachedStates[type]
|
||||
if (!force && cachedState != null) {
|
||||
latestRequestId += 1L
|
||||
activeFirstPageKey = null
|
||||
_isLoading.value = false
|
||||
_rankingStateLiveData.value = cachedState
|
||||
return
|
||||
}
|
||||
val requestKey = type
|
||||
if (activeFirstPageKey == requestKey) return
|
||||
activeFirstPageKey = requestKey
|
||||
val requestId = ++latestRequestId
|
||||
|
||||
_isLoading.value = true
|
||||
_rankingStateLiveData.value = AudioRankingsUiState.Loading
|
||||
@@ -57,6 +63,7 @@ class ContentRankingViewModel(
|
||||
.subscribe(
|
||||
{
|
||||
if (!isCurrentRequest(requestId, type)) return@subscribe
|
||||
clearActiveFirstPageKey(requestKey, requestId)
|
||||
_isLoading.value = false
|
||||
val data = it.data
|
||||
if (it.success && data != null) {
|
||||
@@ -70,14 +77,15 @@ class ContentRankingViewModel(
|
||||
cachedStates[type] = state
|
||||
_rankingStateLiveData.value = state
|
||||
} else {
|
||||
showUnknownError(type, it.message)
|
||||
showUnknownError(type, it.message, cachedState)
|
||||
}
|
||||
},
|
||||
{
|
||||
if (!isCurrentRequest(requestId, type)) return@subscribe
|
||||
clearActiveFirstPageKey(requestKey, requestId)
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
showUnknownError(type, it.message)
|
||||
showUnknownError(type, it.message, cachedState)
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -87,9 +95,19 @@ class ContentRankingViewModel(
|
||||
return requestId == latestRequestId && _selectedTypeLiveData.value == type
|
||||
}
|
||||
|
||||
private fun showUnknownError(type: AudioRankingType, message: String?) {
|
||||
private fun clearActiveFirstPageKey(requestKey: AudioRankingType, requestId: Long) {
|
||||
if (activeFirstPageKey == requestKey && latestRequestId == requestId) {
|
||||
activeFirstPageKey = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun showUnknownError(
|
||||
type: AudioRankingType,
|
||||
message: String?,
|
||||
fallbackState: AudioRankingsUiState? = null
|
||||
) {
|
||||
if (_selectedTypeLiveData.value != type) return
|
||||
_rankingStateLiveData.value = AudioRankingsUiState.Error(type = type, message = message)
|
||||
_rankingStateLiveData.value = fallbackState ?: AudioRankingsUiState.Error(type = type, message = message)
|
||||
_toastLiveData.value = ToastMessage(resId = R.string.common_error_unknown)
|
||||
}
|
||||
|
||||
|
||||
+14
-4
@@ -29,7 +29,13 @@ class HomeCreatorRankingViewModel(
|
||||
val isLoading: LiveData<Boolean>
|
||||
get() = _isLoading
|
||||
|
||||
private var requestGeneration: Int = 0
|
||||
|
||||
fun loadCreatorRankings() {
|
||||
if (_isLoading.value == true) return
|
||||
|
||||
val previousState = _rankingStateLiveData.value
|
||||
val generation = ++requestGeneration
|
||||
_isLoading.value = true
|
||||
_rankingStateLiveData.value = HomeCreatorRankingUiState.Loading
|
||||
|
||||
@@ -39,6 +45,8 @@ class HomeCreatorRankingViewModel(
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
if (generation != requestGeneration) return@subscribe
|
||||
|
||||
_isLoading.value = false
|
||||
val data = it.data
|
||||
if (it.success && data != null) {
|
||||
@@ -49,20 +57,22 @@ class HomeCreatorRankingViewModel(
|
||||
HomeCreatorRankingUiState.Content(items = items)
|
||||
}
|
||||
} else {
|
||||
showUnknownError(it.message)
|
||||
showUnknownError(it.message, previousState)
|
||||
}
|
||||
},
|
||||
{
|
||||
if (generation != requestGeneration) return@subscribe
|
||||
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
showUnknownError(it.message)
|
||||
showUnknownError(it.message, previousState)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun showUnknownError(message: String?) {
|
||||
_rankingStateLiveData.value = HomeCreatorRankingUiState.Error(message = message)
|
||||
private fun showUnknownError(message: String?, fallbackState: HomeCreatorRankingUiState? = null) {
|
||||
_rankingStateLiveData.value = fallbackState ?: HomeCreatorRankingUiState.Error(message = message)
|
||||
_toastLiveData.postValue(ToastMessage(resId = R.string.common_error_unknown))
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,13 @@ class HomeFollowingViewModel(
|
||||
val isLoading: LiveData<Boolean>
|
||||
get() = _isLoading
|
||||
|
||||
private var requestGeneration: Int = 0
|
||||
|
||||
fun loadFollowing() {
|
||||
if (_isLoading.value == true) return
|
||||
|
||||
val previousState = _followingStateLiveData.value
|
||||
val generation = ++requestGeneration
|
||||
_isLoading.value = true
|
||||
_followingStateLiveData.value = HomeFollowingUiState.Loading
|
||||
|
||||
@@ -43,25 +49,29 @@ class HomeFollowingViewModel(
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
if (generation != requestGeneration) return@subscribe
|
||||
|
||||
_isLoading.value = false
|
||||
val data = it.data
|
||||
if (it.success && data != null) {
|
||||
_followingStateLiveData.value = data.toUiState(relativeTimeTextFormatter)
|
||||
} else {
|
||||
showUnknownError(it.message)
|
||||
showUnknownError(it.message, previousState)
|
||||
}
|
||||
},
|
||||
{
|
||||
if (generation != requestGeneration) return@subscribe
|
||||
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
showUnknownError(it.message)
|
||||
showUnknownError(it.message, previousState)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun showUnknownError(message: String?) {
|
||||
_followingStateLiveData.value = HomeFollowingUiState.Error(message = message)
|
||||
private fun showUnknownError(message: String?, fallbackState: HomeFollowingUiState? = null) {
|
||||
_followingStateLiveData.value = fallbackState ?: HomeFollowingUiState.Error(message = message)
|
||||
_toastLiveData.value = ToastMessage(resId = R.string.common_error_unknown)
|
||||
}
|
||||
|
||||
|
||||
@@ -125,9 +125,15 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
||||
private var hasLoadedFollowing = false
|
||||
private var currentHomeTabIndex = HOME_TAB_RECOMMENDATION
|
||||
private var isRecommendationLoading = false
|
||||
private var isRecommendationFollowLoading = false
|
||||
private var isCreatorRankingLoading = false
|
||||
private var isFollowingLoading = false
|
||||
private var isLiveEntryLoading = false
|
||||
private var isHomePullRefreshing = false
|
||||
private var refreshingHomeTabIndex: Int? = null
|
||||
private var lastRenderedHomeRecommendationState: HomeRecommendationUiState.Content? = null
|
||||
private var lastRenderedHomeRankingState: HomeCreatorRankingUiState.Content? = null
|
||||
private var lastRenderedHomeFollowingState: HomeFollowingUiState.Content? = null
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
@@ -150,6 +156,7 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
||||
setUpRecommendationAdapters()
|
||||
setUpCreatorRankingAdapter()
|
||||
setUpFollowingAdapters()
|
||||
setUpRefreshLayouts()
|
||||
setUpBusinessInfo()
|
||||
setupTitleBarActions()
|
||||
bindHomeRecommendationObservers()
|
||||
@@ -260,12 +267,78 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUpRefreshLayouts() {
|
||||
binding.swipeHomeRecommendation.setOnRefreshListener { refreshCurrentHomeTab() }
|
||||
binding.swipeHomeRanking.setOnRefreshListener { refreshCurrentHomeTab() }
|
||||
binding.swipeHomeFollowing.setOnRefreshListener { refreshCurrentHomeTab() }
|
||||
}
|
||||
|
||||
private fun refreshCurrentHomeTab() {
|
||||
isHomePullRefreshing = true
|
||||
refreshingHomeTabIndex = currentHomeTabIndex
|
||||
when (currentHomeTabIndex) {
|
||||
HOME_TAB_RECOMMENDATION -> homeRecommendationViewModel.loadRecommendations()
|
||||
HOME_TAB_RANKING -> homeCreatorRankingViewModel.loadCreatorRankings()
|
||||
HOME_TAB_FOLLOWING -> homeFollowingViewModel.loadFollowing()
|
||||
}
|
||||
}
|
||||
|
||||
private fun finishHomePullRefresh(tabIndex: Int, isRestoredPullRefreshError: Boolean = false) {
|
||||
if (!isHomePullRefreshing) return
|
||||
if (refreshingHomeTabIndex != tabIndex) return
|
||||
if (!isRestoredPullRefreshError) {
|
||||
scrollHomeTabToTop(tabIndex)
|
||||
}
|
||||
when (tabIndex) {
|
||||
HOME_TAB_RECOMMENDATION -> binding.swipeHomeRecommendation.isRefreshing = false
|
||||
HOME_TAB_RANKING -> binding.swipeHomeRanking.isRefreshing = false
|
||||
HOME_TAB_FOLLOWING -> binding.swipeHomeFollowing.isRefreshing = false
|
||||
}
|
||||
isHomePullRefreshing = false
|
||||
refreshingHomeTabIndex = null
|
||||
}
|
||||
|
||||
private fun shouldPreserveHomeContentOnPullRefreshError(tabIndex: Int): Boolean {
|
||||
if (!isHomePullRefreshing) return false
|
||||
if (refreshingHomeTabIndex != tabIndex) return false
|
||||
when (tabIndex) {
|
||||
HOME_TAB_RECOMMENDATION -> binding.swipeHomeRecommendation.isRefreshing = false
|
||||
HOME_TAB_RANKING -> binding.swipeHomeRanking.isRefreshing = false
|
||||
HOME_TAB_FOLLOWING -> binding.swipeHomeFollowing.isRefreshing = false
|
||||
}
|
||||
isHomePullRefreshing = false
|
||||
refreshingHomeTabIndex = null
|
||||
return true
|
||||
}
|
||||
|
||||
private fun scrollHomeTabToTop(tabIndex: Int) {
|
||||
when (tabIndex) {
|
||||
HOME_TAB_RECOMMENDATION -> binding.nsvHomeRecommendationContent.scrollTo(0, 0)
|
||||
HOME_TAB_RANKING -> binding.rvHomeCreatorRankings.scrollToPosition(0)
|
||||
HOME_TAB_FOLLOWING -> binding.nsvHomeFollowingContent.scrollTo(0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindHomeCreatorRankingObservers() {
|
||||
homeCreatorRankingViewModel.rankingStateLiveData.observe(viewLifecycleOwner) { state ->
|
||||
when (state) {
|
||||
is HomeCreatorRankingUiState.Content -> creatorRankingAdapter.submitItems(state.items)
|
||||
HomeCreatorRankingUiState.Empty,
|
||||
is HomeCreatorRankingUiState.Error -> creatorRankingAdapter.submitItems(emptyList())
|
||||
is HomeCreatorRankingUiState.Content -> {
|
||||
val isRestoredPullRefreshError = isHomePullRefreshing &&
|
||||
refreshingHomeTabIndex == HOME_TAB_RANKING &&
|
||||
lastRenderedHomeRankingState === state
|
||||
creatorRankingAdapter.submitItems(state.items)
|
||||
lastRenderedHomeRankingState = state
|
||||
finishHomePullRefresh(HOME_TAB_RANKING, isRestoredPullRefreshError)
|
||||
}
|
||||
HomeCreatorRankingUiState.Empty -> {
|
||||
lastRenderedHomeRankingState = null
|
||||
creatorRankingAdapter.submitItems(emptyList())
|
||||
finishHomePullRefresh(HOME_TAB_RANKING)
|
||||
}
|
||||
is HomeCreatorRankingUiState.Error -> {
|
||||
if (shouldPreserveHomeContentOnPullRefreshError(HOME_TAB_RANKING)) return@observe
|
||||
creatorRankingAdapter.submitItems(emptyList())
|
||||
}
|
||||
|
||||
HomeCreatorRankingUiState.Loading -> Unit
|
||||
}
|
||||
@@ -293,15 +366,15 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
||||
currentHomeTabIndex = index
|
||||
when (index) {
|
||||
HOME_TAB_RECOMMENDATION -> {
|
||||
binding.nsvHomeRecommendationContent.visibility = View.VISIBLE
|
||||
binding.rvHomeCreatorRankings.visibility = View.GONE
|
||||
binding.nsvHomeFollowingContent.visibility = View.GONE
|
||||
binding.swipeHomeRecommendation.visibility = View.VISIBLE
|
||||
binding.swipeHomeRanking.visibility = View.GONE
|
||||
binding.swipeHomeFollowing.visibility = View.GONE
|
||||
}
|
||||
|
||||
HOME_TAB_RANKING -> {
|
||||
binding.nsvHomeRecommendationContent.visibility = View.GONE
|
||||
binding.rvHomeCreatorRankings.visibility = View.VISIBLE
|
||||
binding.nsvHomeFollowingContent.visibility = View.GONE
|
||||
binding.swipeHomeRecommendation.visibility = View.GONE
|
||||
binding.swipeHomeRanking.visibility = View.VISIBLE
|
||||
binding.swipeHomeFollowing.visibility = View.GONE
|
||||
if (!hasLoadedCreatorRankings) {
|
||||
hasLoadedCreatorRankings = true
|
||||
homeCreatorRankingViewModel.loadCreatorRankings()
|
||||
@@ -309,9 +382,9 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
||||
}
|
||||
|
||||
HOME_TAB_FOLLOWING -> {
|
||||
binding.nsvHomeFollowingContent.visibility = View.VISIBLE
|
||||
binding.nsvHomeRecommendationContent.visibility = View.GONE
|
||||
binding.rvHomeCreatorRankings.visibility = View.GONE
|
||||
binding.swipeHomeFollowing.visibility = View.VISIBLE
|
||||
binding.swipeHomeRecommendation.visibility = View.GONE
|
||||
binding.swipeHomeRanking.visibility = View.GONE
|
||||
if (!hasLoadedFollowing) {
|
||||
hasLoadedFollowing = true
|
||||
homeFollowingViewModel.loadFollowing()
|
||||
@@ -323,10 +396,24 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
||||
private fun bindHomeFollowingObservers() {
|
||||
homeFollowingViewModel.followingStateLiveData.observe(viewLifecycleOwner) { state ->
|
||||
when (state) {
|
||||
is HomeFollowingUiState.Content -> bindHomeFollowingContent(state)
|
||||
HomeFollowingUiState.Empty -> bindHomeFollowingEmpty(showEmptyMessage = true)
|
||||
HomeFollowingUiState.LoginRequired,
|
||||
is HomeFollowingUiState.Error -> bindHomeFollowingEmpty(showEmptyMessage = false)
|
||||
is HomeFollowingUiState.Content -> {
|
||||
val isRestoredPullRefreshError = isHomePullRefreshing &&
|
||||
refreshingHomeTabIndex == HOME_TAB_FOLLOWING &&
|
||||
lastRenderedHomeFollowingState === state
|
||||
bindHomeFollowingContent(state)
|
||||
lastRenderedHomeFollowingState = state
|
||||
finishHomePullRefresh(HOME_TAB_FOLLOWING, isRestoredPullRefreshError)
|
||||
}
|
||||
HomeFollowingUiState.Empty -> {
|
||||
lastRenderedHomeFollowingState = null
|
||||
bindHomeFollowingEmpty(showEmptyMessage = true)
|
||||
finishHomePullRefresh(HOME_TAB_FOLLOWING)
|
||||
}
|
||||
HomeFollowingUiState.LoginRequired -> bindHomeFollowingEmpty(showEmptyMessage = false)
|
||||
is HomeFollowingUiState.Error -> {
|
||||
if (shouldPreserveHomeContentOnPullRefreshError(HOME_TAB_FOLLOWING)) return@observe
|
||||
bindHomeFollowingEmpty(showEmptyMessage = false)
|
||||
}
|
||||
|
||||
HomeFollowingUiState.Loading -> Unit
|
||||
}
|
||||
@@ -343,9 +430,23 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
||||
private fun bindHomeRecommendationObservers() {
|
||||
homeRecommendationViewModel.recommendationStateLiveData.observe(viewLifecycleOwner) { state ->
|
||||
when (state) {
|
||||
is HomeRecommendationUiState.Content -> bindHomeRecommendationContent(state)
|
||||
HomeRecommendationUiState.Empty,
|
||||
is HomeRecommendationUiState.Error -> bindHomeRecommendationContent(emptyHomeRecommendationContent())
|
||||
is HomeRecommendationUiState.Content -> {
|
||||
val isRestoredPullRefreshError = isHomePullRefreshing &&
|
||||
refreshingHomeTabIndex == HOME_TAB_RECOMMENDATION &&
|
||||
lastRenderedHomeRecommendationState === state
|
||||
bindHomeRecommendationContent(state)
|
||||
lastRenderedHomeRecommendationState = state
|
||||
finishHomePullRefresh(HOME_TAB_RECOMMENDATION, isRestoredPullRefreshError)
|
||||
}
|
||||
HomeRecommendationUiState.Empty -> {
|
||||
lastRenderedHomeRecommendationState = null
|
||||
bindHomeRecommendationContent(emptyHomeRecommendationContent())
|
||||
finishHomePullRefresh(HOME_TAB_RECOMMENDATION)
|
||||
}
|
||||
is HomeRecommendationUiState.Error -> {
|
||||
if (shouldPreserveHomeContentOnPullRefreshError(HOME_TAB_RECOMMENDATION)) return@observe
|
||||
bindHomeRecommendationContent(emptyHomeRecommendationContent())
|
||||
}
|
||||
|
||||
HomeRecommendationUiState.Loading -> Unit
|
||||
}
|
||||
@@ -354,6 +455,10 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
||||
isRecommendationLoading = isLoading
|
||||
updateLoadingDialog()
|
||||
}
|
||||
homeRecommendationViewModel.isFollowLoading.observe(viewLifecycleOwner) { isLoading ->
|
||||
isRecommendationFollowLoading = isLoading
|
||||
updateLoadingDialog()
|
||||
}
|
||||
homeRecommendationViewModel.toastLiveData.observe(viewLifecycleOwner) { toastMessage ->
|
||||
toastMessage?.let(::showToast)
|
||||
}
|
||||
@@ -370,7 +475,13 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
||||
}
|
||||
|
||||
private fun updateLoadingDialog() {
|
||||
if (isRecommendationLoading || isCreatorRankingLoading || isFollowingLoading || isLiveEntryLoading) {
|
||||
if (
|
||||
isRecommendationLoading ||
|
||||
isRecommendationFollowLoading ||
|
||||
isCreatorRankingLoading ||
|
||||
isFollowingLoading ||
|
||||
isLiveEntryLoading
|
||||
) {
|
||||
loadingDialog.show(screenWidth)
|
||||
} else {
|
||||
loadingDialog.dismiss()
|
||||
|
||||
+41
-11
@@ -30,7 +30,18 @@ class HomeRecommendationViewModel(
|
||||
val isLoading: LiveData<Boolean>
|
||||
get() = _isLoading
|
||||
|
||||
private val _isFollowLoading = MutableLiveData(false)
|
||||
val isFollowLoading: LiveData<Boolean>
|
||||
get() = _isFollowLoading
|
||||
|
||||
private var requestGeneration: Int = 0
|
||||
private var isCheerCreatorsFollowCompleted = false
|
||||
|
||||
fun loadRecommendations() {
|
||||
if (_isLoading.value == true) return
|
||||
|
||||
val previousState = _recommendationStateLiveData.value
|
||||
val generation = ++requestGeneration
|
||||
_isLoading.value = true
|
||||
_recommendationStateLiveData.value = HomeRecommendationUiState.Loading
|
||||
|
||||
@@ -40,23 +51,27 @@ class HomeRecommendationViewModel(
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
if (generation != requestGeneration) return@subscribe
|
||||
|
||||
_isLoading.value = false
|
||||
val data = it.data
|
||||
if (it.success && data != null) {
|
||||
val content = data.toContent()
|
||||
val content = data.toContent().withFollowCompleted()
|
||||
_recommendationStateLiveData.value = if (content.isEmpty) {
|
||||
HomeRecommendationUiState.Empty
|
||||
} else {
|
||||
content
|
||||
}
|
||||
} else {
|
||||
showUnknownError(it.message)
|
||||
showUnknownError(it.message, previousState)
|
||||
}
|
||||
},
|
||||
{
|
||||
if (generation != requestGeneration) return@subscribe
|
||||
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
showUnknownError(it.message)
|
||||
showUnknownError(it.message, previousState)
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -65,7 +80,7 @@ class HomeRecommendationViewModel(
|
||||
fun followCreators(sectionKey: String, creatorIds: List<Long>) {
|
||||
if (creatorIds.isEmpty()) return
|
||||
|
||||
_isLoading.value = true
|
||||
_isFollowLoading.value = true
|
||||
compositeDisposable.add(
|
||||
repository.followRecommendedCreators(
|
||||
request = FollowRecommendedCreatorsRequest(creatorIds = creatorIds),
|
||||
@@ -75,35 +90,50 @@ class HomeRecommendationViewModel(
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
_isLoading.value = false
|
||||
_isFollowLoading.value = false
|
||||
if (it.success) {
|
||||
updateFollowCompleted(sectionKey)
|
||||
} else {
|
||||
showUnknownError(it.message)
|
||||
showFollowError()
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
_isFollowLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
showUnknownError(it.message)
|
||||
showFollowError()
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun updateFollowCompleted(sectionKey: String) {
|
||||
val content = _recommendationStateLiveData.value as? HomeRecommendationUiState.Content ?: return
|
||||
if (sectionKey != SECTION_KEY_CHEER_CREATORS) return
|
||||
isCheerCreatorsFollowCompleted = true
|
||||
val content = _recommendationStateLiveData.value as? HomeRecommendationUiState.Content ?: return
|
||||
_recommendationStateLiveData.value = content.copy(
|
||||
cheerCreators = content.cheerCreators.copy(isFollowCompleted = true)
|
||||
)
|
||||
}
|
||||
|
||||
private fun showUnknownError(message: String?) {
|
||||
_recommendationStateLiveData.value = HomeRecommendationUiState.Error(message = message)
|
||||
private fun HomeRecommendationUiState.Content.withFollowCompleted(): HomeRecommendationUiState.Content {
|
||||
if (!isCheerCreatorsFollowCompleted) return this
|
||||
return copy(cheerCreators = cheerCreators.copy(isFollowCompleted = true))
|
||||
}
|
||||
|
||||
private fun showFollowError() {
|
||||
_toastLiveData.postValue(ToastMessage(resId = R.string.common_error_unknown))
|
||||
}
|
||||
|
||||
private fun showUnknownError(message: String?, fallbackState: HomeRecommendationUiState? = null) {
|
||||
_recommendationStateLiveData.value = fallbackState.withFollowCompleted()
|
||||
?: HomeRecommendationUiState.Error(message = message)
|
||||
_toastLiveData.postValue(ToastMessage(resId = R.string.common_error_unknown))
|
||||
}
|
||||
|
||||
private fun HomeRecommendationUiState?.withFollowCompleted(): HomeRecommendationUiState? {
|
||||
return (this as? HomeRecommendationUiState.Content)?.withFollowCompleted() ?: this
|
||||
}
|
||||
|
||||
private fun authToken(): String = "Bearer ${SharedPreferenceManager.token}"
|
||||
|
||||
private companion object {
|
||||
|
||||
@@ -24,30 +24,38 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/view_chat_title_bar" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_chat_rooms"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_chat_rooms"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="@dimen/spacing_48"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/view_chat_filter_tabs"
|
||||
tools:listitem="@layout/item_v2_chat_room" />
|
||||
app:layout_constraintTop_toBottomOf="@id/view_chat_filter_tabs">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_chat_empty_message"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/view_chat_filter_tabs"
|
||||
tools:text="아직 나눈 대화가 없어요.\n크리에이터와 이야기를 시작해 보세요." />
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_chat_rooms"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="@dimen/spacing_48"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_v2_chat_room" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_chat_empty_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone"
|
||||
tools:text="아직 나눈 대화가 없어요.\n크리에이터와 이야기를 시작해 보세요." />
|
||||
</FrameLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@@ -99,41 +99,48 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_content_all_items"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_content_all"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:clipToPadding="false"
|
||||
android:paddingHorizontal="@dimen/spacing_14"
|
||||
android:paddingTop="@dimen/spacing_14"
|
||||
android:paddingBottom="@dimen/spacing_28"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/layout_content_all_sort_bar" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/layout_content_all_empty_error"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:paddingHorizontal="@dimen/spacing_28"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/layout_content_all_sort_bar">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content_all_empty_error"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:fontFamily="@font/medium"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="14sp" />
|
||||
</FrameLayout>
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_content_all_items"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingHorizontal="@dimen/spacing_14"
|
||||
android:paddingTop="@dimen/spacing_14"
|
||||
android:paddingBottom="@dimen/spacing_28" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/layout_content_all_empty_error"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingHorizontal="@dimen/spacing_28"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content_all_empty_error"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:fontFamily="@font/medium"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="14sp" />
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<include
|
||||
@@ -146,30 +153,41 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/text_tab_bar_content" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_content_rankings"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_content_ranking"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:clipToPadding="false"
|
||||
android:paddingHorizontal="@dimen/spacing_14"
|
||||
android:paddingTop="@dimen/spacing_14"
|
||||
android:paddingBottom="@dimen/spacing_28"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/view_content_ranking_type_tabs" />
|
||||
app:layout_constraintTop_toBottomOf="@id/view_content_ranking_type_tabs">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nsv_content_recommendation_content"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_content_rankings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingHorizontal="@dimen/spacing_14"
|
||||
android:paddingTop="@dimen/spacing_14"
|
||||
android:paddingBottom="@dimen/spacing_28" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_content_recommendation"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:fillViewport="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/text_tab_bar_content">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nsv_content_recommendation_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_content_recommendation_content"
|
||||
android:layout_width="match_parent"
|
||||
@@ -342,5 +360,6 @@
|
||||
android:paddingHorizontal="@dimen/spacing_14" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@@ -24,16 +24,21 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/view_home_title_bar" />
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nsv_home_recommendation_content"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_home_recommendation"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:fillViewport="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/text_tab_bar_home">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nsv_home_recommendation_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_home_recommendation_content"
|
||||
android:layout_width="match_parent"
|
||||
@@ -216,19 +221,25 @@
|
||||
android:textColor="@color/gray_500" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nsv_home_following_content"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_home_following"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:fillViewport="true"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/text_tab_bar_home">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nsv_home_following_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_home_following_content"
|
||||
android:layout_width="match_parent"
|
||||
@@ -357,20 +368,27 @@
|
||||
tools:listitem="@layout/item_home_following_news_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_home_creator_rankings"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_home_ranking"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:clipToPadding="false"
|
||||
android:paddingHorizontal="@dimen/spacing_14"
|
||||
android:paddingTop="@dimen/spacing_14"
|
||||
android:paddingBottom="@dimen/spacing_28"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/text_tab_bar_home"
|
||||
tools:listitem="@layout/view_creator_ranking_lower_row" />
|
||||
app:layout_constraintTop_toBottomOf="@id/text_tab_bar_home">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_home_creator_rankings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingHorizontal="@dimen/spacing_14"
|
||||
android:paddingTop="@dimen/spacing_14"
|
||||
android:paddingBottom="@dimen/spacing_28"
|
||||
tools:listitem="@layout/view_creator_ranking_lower_row" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
Reference in New Issue
Block a user