diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt index 0d3940a1..5fe32f4d 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt @@ -60,6 +60,7 @@ class WineyFeedFragment : private lateinit var wineyFeedAdapter: WineyFeedAdapter private lateinit var wineyFeedHeaderAdapter: WineyFeedHeaderAdapter private lateinit var wineyFeedLoadAdapter: WineyFeedLoadAdapter + private val loadingDialog by lazy { WineyFeedLoadingDialogFragment() } private var clickedFeedId = -1 private var deleteFeedId = -1 @@ -275,21 +276,32 @@ class WineyFeedFragment : when (loadStates.refresh) { is LoadState.Loading -> { Timber.d("LOADING") - binding.rvWineyfeedPost.isVisible = false + showLoadingDialog() } is LoadState.NotLoading -> { Timber.d("NOT LOADING") + dismissLoadingDialog() binding.rvWineyfeedPost.isVisible = wineyFeedAdapter.itemCount > 0 } is LoadState.Error -> { - Timber.tag("failure").e(MSG_WINEYFEED_ERROR) + dismissLoadingDialog() + snackBar(binding.root) { stringOf(R.string.error_winey_feed_loading) } } } } } + private fun showLoadingDialog() { + binding.rvWineyfeedPost.isVisible = false + loadingDialog.show(parentFragmentManager, TAG_LOADING_DIALOG) + } + + private fun dismissLoadingDialog() { + if (loadingDialog.isAdded) loadingDialog.dismiss() + } + private fun initPostLikeStateObserver() { viewModel.postWineyFeedLikeState.flowWithLifecycle(viewLifeCycle).onEach { state -> when (state) { @@ -459,6 +471,7 @@ class WineyFeedFragment : private const val TAG_GOAL_DIALOG = "NO_GOAL_DIALOG" private const val TAG_FEED_DELETE_DIALOG = "FEED_DELETE_DIALOG" private const val TAG_FEED_REPORT_DIALOG = "FEED_REPORT_DIALOG" + private const val TAG_LOADING_DIALOG = "WINEY_FEED_LOADING_DIALOG" private const val POPUP_MENU_POS_OFFSET = 65 private const val KEY_FEED_ID = "feedId" private const val KEY_FEED_WRITER_ID = "feedWriterId" diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedLoadingDialogFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedLoadingDialogFragment.kt new file mode 100644 index 00000000..91220fda --- /dev/null +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedLoadingDialogFragment.kt @@ -0,0 +1,16 @@ +package org.go.sopt.winey.presentation.main.feed + +import android.os.Bundle +import org.go.sopt.winey.R +import org.go.sopt.winey.databinding.FragmentWineyFeedLoadingDialogBinding +import org.go.sopt.winey.util.binding.BindingDialogFragment + +class WineyFeedLoadingDialogFragment : + BindingDialogFragment( + R.layout.fragment_winey_feed_loading_dialog + ) { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + dialog?.setCanceledOnTouchOutside(false) + } +} diff --git a/app/src/main/res/layout/fragment_winey_feed_loading_dialog.xml b/app/src/main/res/layout/fragment_winey_feed_loading_dialog.xml new file mode 100644 index 00000000..eb1c0930 --- /dev/null +++ b/app/src/main/res/layout/fragment_winey_feed_loading_dialog.xml @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b1cb3b92..2b190fa1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -228,4 +228,7 @@ 조금 더 아껴볼까요? 오늘은 절약했어요 + + + Can\'t loading winey feed list…