Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import android.net.Uri
import android.os.Bundle
import android.view.View
import androidx.fragment.app.activityViewModels
import coil.ImageLoader
import coil.decode.ImageDecoderDecoder
import coil.load
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.into.websoso.R.layout.dialog_create_feed_search_novel
import com.into.websoso.core.common.ui.base.BaseBottomSheetDialog
import com.into.websoso.core.common.util.InfiniteScrollListener
import com.into.websoso.core.common.util.SingleEventHandler
import com.into.websoso.core.common.util.tracker.Tracker
import com.into.websoso.core.resource.R.drawable.ic_load_load
import com.into.websoso.core.resource.R.string.novel_inquire_link
import com.into.websoso.databinding.DialogCreateFeedSearchNovelBinding
import com.into.websoso.ui.createFeed.adapter.SearchNovelAdapter
Expand Down Expand Up @@ -45,6 +49,7 @@ class CreateFeedSearchNovelBottomSheetDialog :

setupDialog()
setupAdapter()
setupLoadingAnimation()
setupObserver()
setupNavigateToInquireNovel()
binding.viewModel = createFeedViewModel
Expand Down Expand Up @@ -93,12 +98,31 @@ class CreateFeedSearchNovelBottomSheetDialog :
private fun setupObserver() {
createFeedViewModel.searchNovelUiState.observe(viewLifecycleOwner) { uiState ->
when {
!uiState.loading -> updateView(uiState)
uiState.loading -> updateLoadingView()
uiState.isSearched -> updateView(uiState)
else -> binding.ivCreateFeedSearchNovelLoading.visibility = View.GONE
}
}
}

private fun setupLoadingAnimation() {
val gifImageLoader = ImageLoader
.Builder(requireContext())
.components {
add(ImageDecoderDecoder.Factory())
}.build()
binding.ivCreateFeedSearchNovelLoading.load(ic_load_load, gifImageLoader)
}

private fun updateLoadingView() {
binding.ivCreateFeedSearchNovelLoading.visibility = View.VISIBLE
binding.rvCreateFeedSearchNovelResult.visibility = View.INVISIBLE
binding.clCreateFeedResultNotExist.visibility = View.INVISIBLE
binding.tvCreateFeedSearchNovelConnectButton.visibility = View.INVISIBLE
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

private fun updateView(uiState: SearchNovelUiState) {
binding.ivCreateFeedSearchNovelLoading.visibility = View.GONE
val hasSelected = uiState.novels.any { it.isSelected }

when (hasSelected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class CreateFeedViewModel
}.onSuccess { result ->
_searchNovelUiState.value = searchNovelUiState.copy(
loading = false,
isSearched = true,
isLoadable = result.isLoadable,
novelCount = result.resultCount,
novels = result.novels.map { novel ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package com.into.websoso.ui.createFeed.model
import com.into.websoso.ui.normalExplore.model.NormalExploreModel.NovelModel

data class SearchNovelUiState(
val loading: Boolean = true,
val loading: Boolean = false,
val isSearched: Boolean = false,
val error: Boolean = false,
val isLoadable: Boolean = true,
val novelCount: Long = 0,
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/layout/dialog_create_feed_search_novel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@
tools:itemCount="10"
tools:listitem="@layout/item_search_novel" />

<ImageView
android:id="@+id/iv_create_feed_search_novel_loading"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="@null"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/rv_create_feed_search_novel_result"
app:layout_constraintEnd_toEndOf="@id/rv_create_feed_search_novel_result"
app:layout_constraintStart_toStartOf="@id/rv_create_feed_search_novel_result"
app:layout_constraintTop_toTopOf="@id/rv_create_feed_search_novel_result"
tools:visibility="visible" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_create_feed_result_not_exist"
android:layout_width="0dp"
Expand Down
Loading