From 640d845fc3cedbb7428a6fc1d9d73c22370ec16d Mon Sep 17 00:00:00 2001 From: leeeha Date: Wed, 13 Sep 2023 20:19:48 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20#192=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EB=A1=9C=EB=94=A9=20=EC=A4=91=EC=9D=BC=20=EB=95=8C=EB=8A=94=20?= =?UTF-8?q?=EB=A1=9C=EB=94=A9=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EB=9C=A8=EB=8F=84=EB=A1=9D=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/feed/WineyFeedFragment.kt | 17 +++++++++++++++-- .../feed/WineyFeedLoadingDialogFragment.kt | 16 ++++++++++++++++ .../fragment_winey_feed_loading_dialog.xml | 19 +++++++++++++++++++ app/src/main/res/values/strings.xml | 3 +++ 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedLoadingDialogFragment.kt create mode 100644 app/src/main/res/layout/fragment_winey_feed_loading_dialog.xml 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…