From 88597d3007c60baaed4f0e13b8c22829d72a97e6 Mon Sep 17 00:00:00 2001 From: quanda-0562 Date: Mon, 17 Jul 2023 11:32:38 +0700 Subject: [PATCH] add items Fragment, ViewModel --- .../moviedb/compose/ui/home/HomeScreen.kt | 10 +- .../example/moviedb/ui/base/BaseActivity.kt | 40 ++--- .../ui/base/BaseBottomSheetDialogFragment.kt | 37 ++-- .../moviedb/ui/base/BaseDialogFragment.kt | 37 ++-- .../example/moviedb/ui/base/BaseFragment.kt | 37 ++-- .../example/moviedb/ui/base/BaseViewModel.kt | 41 +++-- .../com/example/moviedb/ui/base/UiState.kt | 9 +- .../moviedb/ui/base/items/ItemsFragment.kt | 64 +++++++ .../moviedb/ui/base/items/ItemsViewModel.kt | 168 ++++++++++++++++++ .../BaseLoadMoreRefreshViewModel.kt | 3 +- .../ui/base/paging/BasePagingViewModel.kt | 2 +- .../popularmovie/PopularMovieFragment.kt | 9 +- .../popularmovie/PopularMovieViewModel.kt | 8 +- .../ui/screen/splash/SplashFragment.kt | 4 +- app/src/main/res/layout/fragment_items.xml | 48 +++++ gradle.properties | 2 +- 16 files changed, 398 insertions(+), 121 deletions(-) create mode 100644 app/src/main/java/com/example/moviedb/ui/base/items/ItemsFragment.kt create mode 100644 app/src/main/java/com/example/moviedb/ui/base/items/ItemsViewModel.kt create mode 100644 app/src/main/res/layout/fragment_items.xml diff --git a/app/src/main/java/com/example/moviedb/compose/ui/home/HomeScreen.kt b/app/src/main/java/com/example/moviedb/compose/ui/home/HomeScreen.kt index 2c0232a..972894e 100644 --- a/app/src/main/java/com/example/moviedb/compose/ui/home/HomeScreen.kt +++ b/app/src/main/java/com/example/moviedb/compose/ui/home/HomeScreen.kt @@ -40,9 +40,9 @@ fun HomeScreen( navController: NavController, viewModel: PopularMovieViewModel = hiltViewModel() ) { - val movieList by viewModel.itemList.collectAsState(listOf()) - val refreshing by viewModel.isRefreshing.collectAsState(false) - val pullRefreshState = rememberPullRefreshState(refreshing, { viewModel.doRefresh() }) + val itemListUiState by viewModel.itemsUiState.collectAsState() + val pullRefreshState = + rememberPullRefreshState(itemListUiState.isRefreshing, { viewModel.doRefresh() }) val scrollState = rememberLazyGridState() val endOfListReached by remember { derivedStateOf { @@ -65,7 +65,7 @@ fun HomeScreen( state = scrollState, ) { items( - items = movieList, + items = itemListUiState.items, key = { movie: Movie -> movie.id }, itemContent = { movie -> ItemMovie( @@ -79,7 +79,7 @@ fun HomeScreen( } PullRefreshIndicator( - refreshing = refreshing, + refreshing = itemListUiState.isRefreshing, state = pullRefreshState, modifier = Modifier.align(Alignment.TopCenter) ) diff --git a/app/src/main/java/com/example/moviedb/ui/base/BaseActivity.kt b/app/src/main/java/com/example/moviedb/ui/base/BaseActivity.kt index 2e0147a..1083673 100644 --- a/app/src/main/java/com/example/moviedb/ui/base/BaseActivity.kt +++ b/app/src/main/java/com/example/moviedb/ui/base/BaseActivity.kt @@ -45,20 +45,8 @@ abstract class BaseActivity - when (uiState) { - is UiState.Loading -> { - handleLoading(isLoading = true) - } - - is UiState.Error -> { - handleLoading(isLoading = false) - handleError(uiState.errorType) - } - - else -> { - handleLoading(isLoading = false) - } - } + handleLoading(uiState.isLoading) + handleError(errorType = uiState.errorType) } } } @@ -68,10 +56,11 @@ abstract class BaseActivity { handleErrorMessage(getString(R.string.no_internet_connection)) @@ -96,16 +85,23 @@ abstract class BaseActivity { handleErrorMessage(getString(R.string.unknown_error)) } + + else -> { + dismissShowingDialog() + } } } protected open fun handleErrorMessage(message: String?) { - if (message.isNullOrBlank()) return - dismissLLoadingDialog() - showDialog( - message = message, - firstText = getString(R.string.ok) - ) + if (message.isNullOrBlank().not()) { + showDialog( + message = message, + firstText = getString(R.string.ok), + dismissListener = { + viewModel.hideError() + } + ) + } } override fun onStart() { diff --git a/app/src/main/java/com/example/moviedb/ui/base/BaseBottomSheetDialogFragment.kt b/app/src/main/java/com/example/moviedb/ui/base/BaseBottomSheetDialogFragment.kt index 4a4018f..07ea05f 100644 --- a/app/src/main/java/com/example/moviedb/ui/base/BaseBottomSheetDialogFragment.kt +++ b/app/src/main/java/com/example/moviedb/ui/base/BaseBottomSheetDialogFragment.kt @@ -57,20 +57,8 @@ abstract class BaseBottomSheetDialogFragment - when (uiState) { - is UiState.Loading -> { - handleLoading(isLoading = true) - } - - is UiState.Error -> { - handleLoading(isLoading = false) - handleError(uiState.errorType) - } - - else -> { - handleLoading(isLoading = false) - } - } + handleLoading(uiState.isLoading) + handleError(errorType = uiState.errorType) } } } @@ -84,7 +72,7 @@ abstract class BaseBottomSheetDialogFragment { handleErrorMessage(getString(R.string.no_internet_connection)) @@ -109,16 +97,23 @@ abstract class BaseBottomSheetDialogFragment { handleErrorMessage(getString(R.string.unknown_error)) } + + else -> { + baseActivity.dismissShowingDialog() + } } } protected open fun handleErrorMessage(message: String?) { - if (message.isNullOrBlank()) return - baseActivity.dismissLLoadingDialog() - baseActivity.showDialog( - message = message, - firstText = getString(R.string.ok) - ) + if (message.isNullOrBlank().not()) { + baseActivity.showDialog( + message = message, + firstText = getString(R.string.ok), + dismissListener = { + viewModel.hideError() + } + ) + } } override fun onStart() { diff --git a/app/src/main/java/com/example/moviedb/ui/base/BaseDialogFragment.kt b/app/src/main/java/com/example/moviedb/ui/base/BaseDialogFragment.kt index 4665021..0880c5e 100644 --- a/app/src/main/java/com/example/moviedb/ui/base/BaseDialogFragment.kt +++ b/app/src/main/java/com/example/moviedb/ui/base/BaseDialogFragment.kt @@ -56,20 +56,8 @@ abstract class BaseDialogFragment - when (uiState) { - is UiState.Loading -> { - handleLoading(isLoading = true) - } - - is UiState.Error -> { - handleLoading(isLoading = false) - handleError(uiState.errorType) - } - - else -> { - handleLoading(isLoading = false) - } - } + handleLoading(uiState.isLoading) + handleError(errorType = uiState.errorType) } } } @@ -83,7 +71,7 @@ abstract class BaseDialogFragment { handleErrorMessage(getString(R.string.no_internet_connection)) @@ -108,16 +96,23 @@ abstract class BaseDialogFragment { handleErrorMessage(getString(R.string.unknown_error)) } + + else -> { + baseActivity.dismissShowingDialog() + } } } protected open fun handleErrorMessage(message: String?) { - if (message.isNullOrBlank()) return - baseActivity.dismissLLoadingDialog() - baseActivity.showDialog( - message = message, - firstText = getString(R.string.ok) - ) + if (message.isNullOrBlank().not()) { + baseActivity.showDialog( + message = message, + firstText = getString(R.string.ok), + dismissListener = { + viewModel.hideError() + } + ) + } } override fun onStart() { diff --git a/app/src/main/java/com/example/moviedb/ui/base/BaseFragment.kt b/app/src/main/java/com/example/moviedb/ui/base/BaseFragment.kt index aa13437..fabc111 100644 --- a/app/src/main/java/com/example/moviedb/ui/base/BaseFragment.kt +++ b/app/src/main/java/com/example/moviedb/ui/base/BaseFragment.kt @@ -57,20 +57,8 @@ abstract class BaseFragment - when (uiState) { - is UiState.Loading -> { - handleLoading(isLoading = true) - } - - is UiState.Error -> { - handleLoading(isLoading = false) - handleError(uiState.errorType) - } - - else -> { - handleLoading(isLoading = false) - } - } + handleLoading(uiState.isLoading) + handleError(errorType = uiState.errorType) } } } @@ -84,7 +72,7 @@ abstract class BaseFragment { handleErrorMessage(getString(R.string.no_internet_connection)) @@ -109,16 +97,23 @@ abstract class BaseFragment { handleErrorMessage(getString(R.string.unknown_error)) } + + else -> { + baseActivity.dismissShowingDialog() + } } } protected open fun handleErrorMessage(message: String?) { - if (message.isNullOrBlank()) return - baseActivity.dismissLLoadingDialog() - baseActivity.showDialog( - message = message, - firstText = getString(R.string.ok) - ) + if (message.isNullOrBlank().not()) { + baseActivity.showDialog( + message = message, + firstText = getString(R.string.ok), + dismissListener = { + viewModel.hideError() + } + ) + } } override fun onStart() { diff --git a/app/src/main/java/com/example/moviedb/ui/base/BaseViewModel.kt b/app/src/main/java/com/example/moviedb/ui/base/BaseViewModel.kt index aa6adae..9a3bb18 100644 --- a/app/src/main/java/com/example/moviedb/ui/base/BaseViewModel.kt +++ b/app/src/main/java/com/example/moviedb/ui/base/BaseViewModel.kt @@ -6,6 +6,8 @@ import com.example.moviedb.data.remote.toBaseException import com.example.moviedb.data.repository.UserRepository import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import kotlinx.coroutines.plus import java.net.ConnectException @@ -15,7 +17,8 @@ import java.net.UnknownHostException import javax.inject.Inject open class BaseViewModel : ViewModel() { - val uiState = MutableStateFlow(UiState.Success) + private val _uiState = MutableStateFlow(UiState()) + val uiState: StateFlow = _uiState @Inject lateinit var userRepo: UserRepository @@ -30,15 +33,11 @@ open class BaseViewModel : ViewModel() { } protected val viewModelScopeExceptionHandler by lazy { viewModelScope + exceptionHandler } - fun showSuccess() { - uiState.value = UiState.Success - } - /** * handle throwable when load fail */ - protected open suspend fun onError(throwable: Throwable) { - val errorType: ErrorType = when (throwable) { + protected fun toErrorType(throwable: Throwable): ErrorType { + return when (throwable) { // case no internet connection is UnknownHostException -> { ErrorType.NoInternetConnection @@ -70,16 +69,34 @@ open class BaseViewModel : ViewModel() { } } } - uiState.value = UiState.Error(errorType) } - fun showError(throwable: Throwable) { - uiState.value = UiState.Error(ErrorType.UnknownError(throwable)) + protected open fun onError(throwable: Throwable) { + _uiState.update { + it.copy( + isLoading = false, + errorType = toErrorType(throwable) + ) + } + } + + open fun hideError() { + _uiState.update { + it.copy(errorType = null) + } } fun showLoading() { - uiState.value = UiState.Loading + _uiState.update { + it.copy(isLoading = true, errorType = null) + } + } + + fun hideLoading() { + _uiState.update { + it.copy(isLoading = false) + } } - fun isLoading() = uiState.value == UiState.Loading + fun isLoading() = uiState.value.isLoading } \ No newline at end of file diff --git a/app/src/main/java/com/example/moviedb/ui/base/UiState.kt b/app/src/main/java/com/example/moviedb/ui/base/UiState.kt index 3f21c9b..dd9a5bd 100644 --- a/app/src/main/java/com/example/moviedb/ui/base/UiState.kt +++ b/app/src/main/java/com/example/moviedb/ui/base/UiState.kt @@ -1,10 +1,9 @@ package com.example.moviedb.ui.base -sealed class UiState { - object Success : UiState() - object Loading : UiState() - class Error(val errorType: ErrorType) : UiState() -} +data class UiState( + val isLoading: Boolean = false, + val errorType: ErrorType? = null +) sealed class ErrorType { object NoInternetConnection : ErrorType() diff --git a/app/src/main/java/com/example/moviedb/ui/base/items/ItemsFragment.kt b/app/src/main/java/com/example/moviedb/ui/base/items/ItemsFragment.kt new file mode 100644 index 0000000..7936dd5 --- /dev/null +++ b/app/src/main/java/com/example/moviedb/ui/base/items/ItemsFragment.kt @@ -0,0 +1,64 @@ +package com.example.moviedb.ui.base.items + +import android.os.Bundle +import android.view.View +import androidx.core.widget.ContentLoadingProgressBar +import androidx.databinding.ViewDataBinding +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout +import com.example.moviedb.R +import com.example.moviedb.ui.base.BaseFragment +import com.example.moviedb.ui.base.BaseListAdapter +import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.launch + +abstract class ItemsFragment, Item : Any> : + BaseFragment() { + + override val layoutId: Int = R.layout.fragment_items + abstract val listAdapter: BaseListAdapter + abstract val swipeRefreshLayout: SwipeRefreshLayout + abstract val progressLoading: ContentLoadingProgressBar + abstract val recyclerView: RecyclerView + + open fun getLayoutManager(): RecyclerView.LayoutManager = + LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + setupUi() + } + + open fun setupUi() { + swipeRefreshLayout.setOnRefreshListener { + viewModel.doRefresh() + } + recyclerView.layoutManager = getLayoutManager() + recyclerView.adapter = listAdapter + recyclerView.setHasFixedSize(true) + lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.STARTED) { + viewModel.itemsUiState.collectLatest { uiState -> + swipeRefreshLayout.isRefreshing = uiState.isRefreshing + handleLoading(isLoading = uiState.isLoading) + listAdapter.submitList(uiState.items) + handleError(errorType = uiState.errorType) + } + } + } + viewModel.firstLoad() + } + + override fun handleLoading(isLoading: Boolean) { + progressLoading.visibility = if (isLoading) View.VISIBLE else View.GONE + } + + override fun onDestroyView() { + super.onDestroyView() + recyclerView.adapter = null + } +} diff --git a/app/src/main/java/com/example/moviedb/ui/base/items/ItemsViewModel.kt b/app/src/main/java/com/example/moviedb/ui/base/items/ItemsViewModel.kt new file mode 100644 index 0000000..0b4ff1e --- /dev/null +++ b/app/src/main/java/com/example/moviedb/ui/base/items/ItemsViewModel.kt @@ -0,0 +1,168 @@ +package com.example.moviedb.ui.base.items + +import com.example.moviedb.data.constant.Constants +import com.example.moviedb.ui.base.BaseViewModel +import com.example.moviedb.ui.base.ErrorType +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.update + +data class ItemsUiState( + val isLoading: Boolean = false, + val isRefreshing: Boolean = false, + val isLoadMore: Boolean = false, + val items: ArrayList = arrayListOf(), + val errorType: ErrorType? = null +) + +abstract class ItemsViewModel : BaseViewModel() { + private val _itemsUiState = MutableStateFlow(ItemsUiState()) + val itemsUiState: StateFlow> = _itemsUiState + private var loadMoreTimeMillis = 0L + + // override if first page is not 1 + protected open val firstPage = Constants.DEFAULT_FIRST_PAGE + private val preFirstPage = firstPage - 1 + + // current page + private var currentPage: Int = preFirstPage + + // last page flag + private var isLastPage: Boolean = false + + // empty list flag + private val isEmptyList = MutableStateFlow(false) + + // override if need change number visible threshold + protected open val loadMoreThreshold = Constants.DEFAULT_NUM_VISIBLE_THRESHOLD + + // override if need change number item per page + protected open val numberItemPerPage = Constants.DEFAULT_ITEM_PER_PAGE + + /** + * load data + */ + abstract fun loadData(page: Int) + + /** + * first load + */ + fun firstLoad() { + if (currentPage == preFirstPage + && _itemsUiState.value.items.isEmpty() + ) { + _itemsUiState.update { + it.copy(isLoading = true) + } + loadData(firstPage) + } + } + + fun doRefresh() { + when { + _itemsUiState.value.isLoading + || _itemsUiState.value.isRefreshing -> { + } + + else -> { + _itemsUiState.update { + it.copy(isRefreshing = true) + } + refreshData() + } + } + } + + /** + * load first page + */ + private fun refreshData() { + loadData(firstPage) + } + + fun onBind(position: Int) { +// Timber.v("Check load more on $position") + if (_itemsUiState.value.items.size - position <= loadMoreThreshold) { + doLoadMore() + } + } + + fun doLoadMore() { + when { + _itemsUiState.value.isLoading + || _itemsUiState.value.isRefreshing + || _itemsUiState.value.isLoadMore + || isLastPage + || System.currentTimeMillis() - loadMoreTimeMillis < 2000 -> { + } + + else -> { + _itemsUiState.update { + it.copy(isLoadMore = true) + } + loadMoreTimeMillis = System.currentTimeMillis() + loadMore() + } + } + } + + /** + * load next page + */ + private fun loadMore() { + loadData(currentPage + 1) + } + + /** + * handle load success + */ + fun onLoadSuccess(page: Int, items: List?) { + currentPage = page + isLastPage = (items?.size ?: 0) < numberItemPerPage + _itemsUiState.update { + it.copy( + isLoading = false, + isRefreshing = false, + isLoadMore = false, + items = arrayListOf().apply { + if (currentPage != firstPage) { + addAll(_itemsUiState.value.items) + } + if (items?.isNotEmpty() == true) { + addAll(items) + } + }, + errorType = null + ) + } + checkEmptyList() + } + + /** + * handle load fail + */ + override fun onError(throwable: Throwable) { + _itemsUiState.update { + it.copy( + isLoading = false, + isRefreshing = false, + isLoadMore = false, + errorType = toErrorType(throwable = throwable) + ) + } + checkEmptyList() + } + + override fun hideError() { + _itemsUiState.update { + it.copy(errorType = null) + } + } + + /** + * check list is empty + */ + private fun checkEmptyList() { + isEmptyList.value = _itemsUiState.value.items.isEmpty() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/moviedb/ui/base/loadmorerefresh/BaseLoadMoreRefreshViewModel.kt b/app/src/main/java/com/example/moviedb/ui/base/loadmorerefresh/BaseLoadMoreRefreshViewModel.kt index 32a5b11..31706f9 100644 --- a/app/src/main/java/com/example/moviedb/ui/base/loadmorerefresh/BaseLoadMoreRefreshViewModel.kt +++ b/app/src/main/java/com/example/moviedb/ui/base/loadmorerefresh/BaseLoadMoreRefreshViewModel.kt @@ -147,7 +147,6 @@ abstract class BaseLoadMoreRefreshViewModel() : BaseViewModel() { // reset load isRefreshing.value = false isLoadMore.value = false - showSuccess() // check empty list checkEmptyList() } @@ -155,7 +154,7 @@ abstract class BaseLoadMoreRefreshViewModel() : BaseViewModel() { /** * handle load fail */ - override suspend fun onError(throwable: Throwable) { + override fun onError(throwable: Throwable) { super.onError(throwable) // reset load isRefreshing.value = false diff --git a/app/src/main/java/com/example/moviedb/ui/base/paging/BasePagingViewModel.kt b/app/src/main/java/com/example/moviedb/ui/base/paging/BasePagingViewModel.kt index 84b2399..313d0c4 100644 --- a/app/src/main/java/com/example/moviedb/ui/base/paging/BasePagingViewModel.kt +++ b/app/src/main/java/com/example/moviedb/ui/base/paging/BasePagingViewModel.kt @@ -91,7 +91,7 @@ abstract class BasePagingViewModel : BaseViewModel() { /** * handler error */ - override suspend fun onError(throwable: Throwable) { + override fun onError(throwable: Throwable) { super.onError(throwable) // reset load hideLoadRefresh() diff --git a/app/src/main/java/com/example/moviedb/ui/screen/popularmovie/PopularMovieFragment.kt b/app/src/main/java/com/example/moviedb/ui/screen/popularmovie/PopularMovieFragment.kt index 005ead5..4e5c321 100644 --- a/app/src/main/java/com/example/moviedb/ui/screen/popularmovie/PopularMovieFragment.kt +++ b/app/src/main/java/com/example/moviedb/ui/screen/popularmovie/PopularMovieFragment.kt @@ -3,21 +3,22 @@ package com.example.moviedb.ui.screen.popularmovie import android.graphics.Color import android.os.Bundle import android.view.View +import androidx.core.widget.ContentLoadingProgressBar import androidx.databinding.ViewDataBinding import androidx.fragment.app.viewModels import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.example.moviedb.data.model.Movie -import com.example.moviedb.databinding.FragmentLoadmoreRefreshBinding +import com.example.moviedb.databinding.FragmentItemsBinding import com.example.moviedb.ui.base.BaseListAdapter import com.example.moviedb.ui.base.getNavController -import com.example.moviedb.ui.base.loadmorerefresh.BaseLoadMoreRefreshFragment +import com.example.moviedb.ui.base.items.ItemsFragment import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class PopularMovieFragment : - BaseLoadMoreRefreshFragment() { + ItemsFragment() { override val viewModel: PopularMovieViewModel by viewModels() override val listAdapter: BaseListAdapter by lazy { @@ -28,6 +29,8 @@ class PopularMovieFragment : } override val swipeRefreshLayout: SwipeRefreshLayout get() = viewBinding.refreshLayout + override val progressLoading: ContentLoadingProgressBar + get() = viewBinding.progressLoading override val recyclerView: RecyclerView get() = viewBinding.recyclerView diff --git a/app/src/main/java/com/example/moviedb/ui/screen/popularmovie/PopularMovieViewModel.kt b/app/src/main/java/com/example/moviedb/ui/screen/popularmovie/PopularMovieViewModel.kt index 8733411..db9bf9b 100644 --- a/app/src/main/java/com/example/moviedb/ui/screen/popularmovie/PopularMovieViewModel.kt +++ b/app/src/main/java/com/example/moviedb/ui/screen/popularmovie/PopularMovieViewModel.kt @@ -4,8 +4,7 @@ import androidx.lifecycle.viewModelScope import com.example.moviedb.data.constant.MovieListType import com.example.moviedb.data.model.Movie import com.example.moviedb.data.remote.api.ApiParams -import com.example.moviedb.data.repository.UserRepository -import com.example.moviedb.ui.base.loadmorerefresh.BaseLoadMoreRefreshViewModel +import com.example.moviedb.ui.base.items.ItemsViewModel import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch @@ -13,8 +12,7 @@ import javax.inject.Inject @HiltViewModel class PopularMovieViewModel @Inject constructor( - private val userRepository: UserRepository -) : BaseLoadMoreRefreshViewModel() { +) : ItemsViewModel() { val mode = MutableStateFlow(MovieListType.POPULAR.type) @@ -29,7 +27,7 @@ class PopularMovieViewModel @Inject constructor( viewModelScope.launch { try { - onLoadSuccess(page, userRepository.getMovieList(hashMap).results) + onLoadSuccess(page, userRepo.getMovieList(hashMap).results) } catch (e: Exception) { onError(e) } diff --git a/app/src/main/java/com/example/moviedb/ui/screen/splash/SplashFragment.kt b/app/src/main/java/com/example/moviedb/ui/screen/splash/SplashFragment.kt index 9b242d5..97e2280 100644 --- a/app/src/main/java/com/example/moviedb/ui/screen/splash/SplashFragment.kt +++ b/app/src/main/java/com/example/moviedb/ui/screen/splash/SplashFragment.kt @@ -32,11 +32,11 @@ class SplashFragment : BaseFragment() { repeatOnLifecycle(Lifecycle.State.STARTED) { viewModel.splashViewStateFlow.collectLatest { state -> when (state) { - is SplashViewState.Idle -> { + SplashViewState.Idle -> { // do nothing } - is SplashViewState.NavigateToHome -> { + SplashViewState.NavigateToHome -> { navigateToHome() } } diff --git a/app/src/main/res/layout/fragment_items.xml b/app/src/main/res/layout/fragment_items.xml new file mode 100644 index 0000000..6fd0b6a --- /dev/null +++ b/app/src/main/res/layout/fragment_items.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/gradle.properties b/gradle.properties index 8fb547d..e5d8272 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,7 +25,7 @@ kapt.incremental.apt=true ksp.incremental.apt=true android.defaults.buildfeatures.buildconfig=true android.nonTransitiveRClass=true -android.nonFinalResIds=false +android.nonFinalResIds=true #org.gradle.unsafe.configuration-cache=true org.gradle.caching=true # read more https://developer.android.com/build/releases/gradle-plugin