From e3b229cad806179277578e72ca1639a7265ecdba Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Mon, 21 Aug 2023 21:42:23 +0900 Subject: [PATCH 01/11] =?UTF-8?q?[feat]=20#135=20=EC=9C=84=EB=8B=88=20?= =?UTF-8?q?=ED=94=BC=EB=93=9C=20=EC=83=81=EC=84=B8=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EC=A2=8B=EC=95=84=EC=9A=94=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/feed/detail/DetailActivity.kt | 28 +++++++++++++++++- .../main/feed/detail/DetailFeedAdapter.kt | 29 ++++++++++++------- .../main/feed/detail/DetailViewModel.kt | 21 ++++++++++++++ 3 files changed, 66 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt index aa558f7d..238d4546 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt @@ -36,6 +36,7 @@ class DetailActivity : BindingActivity(R.layout.activity_ viewModel.getFeedDetail(feedId) initGetFeedDetailObserver() initBackButtonClickListener() + initPostLikeStateObserver() } private fun initGetFeedDetailObserver() { @@ -62,7 +63,13 @@ class DetailActivity : BindingActivity(R.layout.activity_ Timber.e("DETAIL FEED IS NULL") return } - detailFeedAdapter = DetailFeedAdapter(detailFeed) + detailFeedAdapter = + DetailFeedAdapter( + detailFeed, + postLike = { feedId, isLiked -> + viewModel.likeFeed(feedId, isLiked) + } + ) } private fun switchCommentContainer(commentList: List?) { @@ -85,6 +92,25 @@ class DetailActivity : BindingActivity(R.layout.activity_ } } + private fun initPostLikeStateObserver() { + viewModel.postFeedDetailLikeState.flowWithLifecycle(lifecycle).onEach { state -> + when (state) { + is UiState.Success -> { + viewModel.getFeedDetail(feedId) + + } + + is UiState.Failure -> { + snackBar(binding.root) { state.msg } + } + + else -> { + + } + } + }.launchIn(lifecycleScope) + } + companion object { private const val KEY_FEED_ID = "feedId" private const val KEY_WRITER_LV = "writerLevel" diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFeedAdapter.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFeedAdapter.kt index bc2c45e4..1b88e4d7 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFeedAdapter.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFeedAdapter.kt @@ -5,20 +5,18 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.android.go.sopt.winey.databinding.ItemDetailFeedBinding import com.android.go.sopt.winey.domain.entity.DetailFeed +import com.android.go.sopt.winey.util.view.setOnSingleClickListener class DetailFeedAdapter( - private val detailFeed: DetailFeed + private val detailFeed: DetailFeed, + private val postLike: (feedId: Int, isLiked: Boolean) -> Unit ) : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DetailFeedViewHolder { - return DetailFeedViewHolder( - ItemDetailFeedBinding.inflate( - LayoutInflater.from(parent.context), - parent, - false - ) - ) + val binding = + ItemDetailFeedBinding.inflate(LayoutInflater.from(parent.context), parent, false) + return DetailFeedViewHolder(binding, postLike) } override fun onBindViewHolder(holder: DetailFeedViewHolder, position: Int) { @@ -28,10 +26,19 @@ class DetailFeedAdapter( override fun getItemCount(): Int = FEED_ITEM_COUNT class DetailFeedViewHolder( - private val binding: ItemDetailFeedBinding + private val binding: ItemDetailFeedBinding, + private val postLike: (feedId: Int, isLiked: Boolean) -> Unit ) : RecyclerView.ViewHolder(binding.root) { - fun bind(data: DetailFeed) { - binding.data = data + fun bind(data: DetailFeed?) { + binding.apply { + this.data = data + if (data == null) { + return + } + ivDetailLike.setOnSingleClickListener { + postLike(data.feedId, !data.isLiked) + } + } } } diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt index 5e25da8a..c3289951 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt @@ -2,7 +2,9 @@ package com.android.go.sopt.winey.presentation.main.feed.detail import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.android.go.sopt.winey.data.model.remote.request.RequestPostLikeDto import com.android.go.sopt.winey.domain.entity.DetailFeed +import com.android.go.sopt.winey.domain.entity.Like import com.android.go.sopt.winey.domain.repository.FeedRepository import com.android.go.sopt.winey.util.view.UiState import dagger.hilt.android.lifecycle.HiltViewModel @@ -49,6 +51,15 @@ class DetailViewModel @Inject constructor( val getFeedDetailState: StateFlow> = _getFeedDetailState.asStateFlow() + private val _postFeedDetailLikeState = MutableStateFlow>(UiState.Loading) + val postFeedDetailLikeState: StateFlow> = _postFeedDetailLikeState.asStateFlow() + + + fun likeFeed(feedId: Int, isLiked: Boolean) { + val requestPostLikeDto = RequestPostLikeDto(isLiked) + postLike(feedId, requestPostLikeDto) + } + fun getFeedDetail(feedId: Int) { viewModelScope.launch { feedRepository.getFeedDetail(feedId) @@ -59,6 +70,16 @@ class DetailViewModel @Inject constructor( } } + private fun postLike(feedId: Int, requestPostLikeDto: RequestPostLikeDto) { + viewModelScope.launch { + feedRepository.postFeedLike(feedId, requestPostLikeDto) + .onSuccess { response -> + _postFeedDetailLikeState.emit(UiState.Success(response)) + } + .onFailure { t -> handleFailureState(_postFeedDetailLikeState, t) } + } + } + private fun handleFailureState(loadingState: MutableStateFlow>, t: Throwable) { if (t is HttpException) { val errorMessage = when (t.code()) { From 61049c94c489b21332de77fab344ea4747796338 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Mon, 21 Aug 2023 22:54:06 +0900 Subject: [PATCH 02/11] =?UTF-8?q?[fix]=20#124=20=EC=A2=8B=EC=95=84?= =?UTF-8?q?=EC=9A=94=20=EC=A4=91=EB=B3=B5=20=EC=A6=9D=EA=B0=80=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/feed/WineyFeedAdapter.kt | 18 ------ .../main/feed/WineyFeedFragment.kt | 64 +++++++++++++++---- .../main/feed/detail/DetailActivity.kt | 1 - .../main/mypage/myfeed/MyFeedAdapter.kt | 19 +----- .../main/mypage/myfeed/MyFeedFragment.kt | 5 +- 5 files changed, 55 insertions(+), 52 deletions(-) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedAdapter.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedAdapter.kt index b5b0152f..220225b0 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedAdapter.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedAdapter.kt @@ -72,24 +72,6 @@ class WineyFeedAdapter( holder.onBind(getItem(position)) } - fun updateLikeStatus(feedId: Int, isLiked: Boolean) { - currentData.let { data -> - val index = data.indexOfFirst { it?.feedId == feedId } - if (index == -1) { - return - } - data[index]?.let { item -> - item.isLiked = isLiked - if (isLiked) { - item.likes++ - } else { - item.likes-- - } - notifyItemChanged(index) - } - } - } - companion object { private val diffUtil = ItemDiffCallback( onItemsTheSame = { old, new -> old.feedId == new.feedId }, diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt index 21c803ee..d7afda71 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt @@ -2,6 +2,7 @@ package com.android.go.sopt.winey.presentation.main.feed import android.content.Intent import android.os.Bundle +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.WindowManager @@ -47,8 +48,10 @@ import kotlinx.coroutines.runBlocking import timber.log.Timber import javax.inject.Inject + @AndroidEntryPoint -class WineyFeedFragment : BindingFragment(R.layout.fragment_winey_feed) { +class WineyFeedFragment : + BindingFragment(R.layout.fragment_winey_feed) { private val viewModel by viewModels() private val mainViewModel by activityViewModels() private lateinit var wineyFeedAdapter: WineyFeedAdapter @@ -60,6 +63,7 @@ class WineyFeedFragment : BindingFragment(R.layout.fra override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + Log.d("Fragment Lifecycle", "onViewCreated 호출됨") initAdapter() setSwipeRefreshListener() initFabClickListener() @@ -87,7 +91,7 @@ class WineyFeedFragment : BindingFragment(R.layout.fra private fun showPopupMenu(view: View, wineyFeed: WineyFeed) { val inflater = LayoutInflater.from(requireContext()) - val popupView = inflater.inflate(R.layout.menu_wineyfeed, null) + val popupView = inflater.inflate(com.android.go.sopt.winey.R.layout.menu_wineyfeed, null) val popupWindow = PopupWindow( popupView, WindowManager.LayoutParams.WRAP_CONTENT, @@ -95,8 +99,10 @@ class WineyFeedFragment : BindingFragment(R.layout.fra true ) - val menuDelete = popupView.findViewById(R.id.tv_popup_delete) - val menuReport = popupView.findViewById(R.id.tv_popup_report) + val menuDelete = + popupView.findViewById(com.android.go.sopt.winey.R.id.tv_popup_delete) + val menuReport = + popupView.findViewById(com.android.go.sopt.winey.R.id.tv_popup_report) if (wineyFeed.userId == runBlocking { dataStoreRepository.getUserId().first() }) { menuReport.isVisible = false @@ -115,7 +121,7 @@ class WineyFeedFragment : BindingFragment(R.layout.fra private fun refreshWineyFeed() { val fragmentManager = parentFragmentManager fragmentManager.beginTransaction().apply { - replace(R.id.fcv_main, WineyFeedFragment()) + replace(com.android.go.sopt.winey.R.id.fcv_main, WineyFeedFragment()) commit() } } @@ -178,10 +184,7 @@ class WineyFeedFragment : BindingFragment(R.layout.fra when (state) { is UiState.Success -> { initGetFeedStateObserver() - wineyFeedAdapter.updateLikeStatus( - state.data.data.feedId, - state.data.data.isLiked - ) + wineyFeedAdapter.refresh() } is UiState.Failure -> { @@ -236,10 +239,11 @@ class WineyFeedFragment : BindingFragment(R.layout.fra private inline fun navigateTo() { parentFragmentManager.commit { - replace(R.id.fcv_main, T::class.simpleName) + replace(com.android.go.sopt.winey.R.id.fcv_main, T::class.simpleName) } - val bottomNav: BottomNavigationView = requireActivity().findViewById(R.id.bnv_main) - bottomNav.selectedItemId = R.id.menu_mypage + val bottomNav: BottomNavigationView = + requireActivity().findViewById(com.android.go.sopt.winey.R.id.bnv_main) + bottomNav.selectedItemId = com.android.go.sopt.winey.R.id.menu_mypage } private fun setSwipeRefreshListener() { @@ -261,6 +265,42 @@ class WineyFeedFragment : BindingFragment(R.layout.fra startActivity(intent) } + + override fun onStart() { + super.onStart() + Log.d("Fragment Lifecycle", "onStart 호출됨") + } + + override fun onResume() { + super.onResume() + viewModel.getWineyFeed() + } + + override fun onPause() { + super.onPause() + Log.d("Fragment Lifecycle", "onPause 호출됨") + } + + override fun onStop() { + super.onStop() + Log.d("Fragment Lifecycle", "onStop 호출됨") + } + + override fun onDestroyView() { + super.onDestroyView() + Log.d("Fragment Lifecycle", "onDestroyView 호출됨") + } + + override fun onDestroy() { + super.onDestroy() + Log.d("Fragment Lifecycle", "onDestroy 호출됨") + } + + override fun onDetach() { + super.onDetach() + Log.d("Fragment Lifecycle", "onDetach 호출됨") + } + companion object { private const val MSG_WINEYFEED_ERROR = "ERROR" private const val TAG_GOAL_DIALOG = "NO_GOAL_DIALOG" diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt index 238d4546..040c200b 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt @@ -97,7 +97,6 @@ class DetailActivity : BindingActivity(R.layout.activity_ when (state) { is UiState.Success -> { viewModel.getFeedDetail(feedId) - } is UiState.Failure -> { diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedAdapter.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedAdapter.kt index 336924c7..91d970d0 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedAdapter.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedAdapter.kt @@ -62,7 +62,8 @@ class MyFeedAdapter( parent: ViewGroup, viewType: Int ): MyFeedViewHolder { - val binding = ItemMyfeedPostBinding.inflate(LayoutInflater.from(parent.context), parent, false) + val binding = + ItemMyfeedPostBinding.inflate(LayoutInflater.from(parent.context), parent, false) return MyFeedViewHolder(binding, likeButtonClick, showPopupMenu, toFeedDetail) } @@ -70,22 +71,6 @@ class MyFeedAdapter( holder.onBind(getItem(position)) } - fun updateLikeStatus(feedId: Int, isLiked: Boolean) { - currentData.let { data -> - val index = data.indexOfFirst { it?.feedId == feedId } - if (index != -1) { - data[index]?.let { item -> - item.isLiked = isLiked - if (isLiked) { - item.likes++ - } else { - item.likes-- - } - notifyItemChanged(index) - } - } - } - } companion object { private val diffUtil = ItemDiffCallback( diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedFragment.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedFragment.kt index 4a4cff71..b52c93ca 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedFragment.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedFragment.kt @@ -162,10 +162,7 @@ class MyFeedFragment : BindingFragment(R.layout.fragment_ when (state) { is UiState.Success -> { initGetFeedStateObserver() - myFeedAdapter.updateLikeStatus( - state.data.data.feedId, - state.data.data.isLiked - ) + myFeedAdapter.refresh() } is UiState.Failure -> { From 4838ce3573886d1e76cae8fcb15cd0679c805790 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Mon, 21 Aug 2023 23:09:59 +0900 Subject: [PATCH 03/11] =?UTF-8?q?[merge]=20develop=20=EC=B6=A9=EB=8F=8C?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/feed/WineyFeedFragment.kt | 51 +++---------------- .../main/feed/detail/DetailActivity.kt | 3 +- .../main/feed/detail/DetailViewModel.kt | 1 - .../main/mypage/myfeed/MyFeedAdapter.kt | 1 - 4 files changed, 8 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt index a3812ecb..ea142985 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt @@ -49,7 +49,6 @@ import kotlinx.coroutines.runBlocking import timber.log.Timber import javax.inject.Inject - @AndroidEntryPoint class WineyFeedFragment : BindingFragment(R.layout.fragment_winey_feed) { @@ -101,7 +100,7 @@ class WineyFeedFragment : private fun showPopupMenu(view: View, wineyFeed: WineyFeed) { val inflater = LayoutInflater.from(requireContext()) - val popupView = inflater.inflate(com.android.go.sopt.winey.R.layout.menu_wineyfeed, null) + val popupView = inflater.inflate(R.layout.menu_wineyfeed, null) val popupWindow = PopupWindow( popupView, WindowManager.LayoutParams.WRAP_CONTENT, @@ -110,9 +109,9 @@ class WineyFeedFragment : ) val menuDelete = - popupView.findViewById(com.android.go.sopt.winey.R.id.tv_popup_delete) + popupView.findViewById(R.id.tv_popup_delete) val menuReport = - popupView.findViewById(com.android.go.sopt.winey.R.id.tv_popup_report) + popupView.findViewById(R.id.tv_popup_report) if (wineyFeed.userId == runBlocking { dataStoreRepository.getUserId().first() }) { menuReport.isVisible = false @@ -131,7 +130,7 @@ class WineyFeedFragment : private fun refreshWineyFeed() { val fragmentManager = parentFragmentManager fragmentManager.beginTransaction().apply { - replace(com.android.go.sopt.winey.R.id.fcv_main, WineyFeedFragment()) + replace(R.id.fcv_main, WineyFeedFragment()) commit() } } @@ -257,11 +256,11 @@ class WineyFeedFragment : private inline fun navigateTo() { parentFragmentManager.commit { - replace(com.android.go.sopt.winey.R.id.fcv_main, T::class.simpleName) + replace(R.id.fcv_main, T::class.simpleName) } val bottomNav: BottomNavigationView = - requireActivity().findViewById(com.android.go.sopt.winey.R.id.bnv_main) - bottomNav.selectedItemId = com.android.go.sopt.winey.R.id.menu_mypage + requireActivity().findViewById(R.id.bnv_main) + bottomNav.selectedItemId = R.id.menu_mypage } private fun setSwipeRefreshListener() { @@ -283,42 +282,6 @@ class WineyFeedFragment : startActivity(intent) } - - override fun onStart() { - super.onStart() - Log.d("Fragment Lifecycle", "onStart 호출됨") - } - - override fun onResume() { - super.onResume() - viewModel.getWineyFeed() - } - - override fun onPause() { - super.onPause() - Log.d("Fragment Lifecycle", "onPause 호출됨") - } - - override fun onStop() { - super.onStop() - Log.d("Fragment Lifecycle", "onStop 호출됨") - } - - override fun onDestroyView() { - super.onDestroyView() - Log.d("Fragment Lifecycle", "onDestroyView 호출됨") - } - - override fun onDestroy() { - super.onDestroy() - Log.d("Fragment Lifecycle", "onDestroy 호출됨") - } - - override fun onDetach() { - super.onDetach() - Log.d("Fragment Lifecycle", "onDetach 호출됨") - } - companion object { private const val MSG_WINEYFEED_ERROR = "ERROR" private const val TAG_GOAL_DIALOG = "NO_GOAL_DIALOG" diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt index 875580cc..c4087dd4 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt @@ -209,7 +209,7 @@ class DetailActivity : BindingActivity(R.layout.activity_ Timber.e("DETAIL FEED IS NULL") return } - detailFeedAdapter = + _detailFeedAdapter = DetailFeedAdapter( detailFeed, postLike = { feedId, isLiked -> @@ -250,7 +250,6 @@ class DetailActivity : BindingActivity(R.layout.activity_ } else -> { - } } }.launchIn(lifecycleScope) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt index 206a6adf..407a6f86 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt @@ -59,7 +59,6 @@ class DetailViewModel @Inject constructor( private val _postFeedDetailLikeState = MutableStateFlow>(UiState.Loading) val postFeedDetailLikeState: StateFlow> = _postFeedDetailLikeState.asStateFlow() - fun likeFeed(feedId: Int, isLiked: Boolean) { val requestPostLikeDto = RequestPostLikeDto(isLiked) postLike(feedId, requestPostLikeDto) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedAdapter.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedAdapter.kt index 91d970d0..7a86698d 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedAdapter.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedAdapter.kt @@ -71,7 +71,6 @@ class MyFeedAdapter( holder.onBind(getItem(position)) } - companion object { private val diffUtil = ItemDiffCallback( onItemsTheSame = { old, new -> old.feedId == new.feedId }, From 1901950765ac6f859cd91db333e74290c91340cb Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Tue, 22 Aug 2023 00:38:25 +0900 Subject: [PATCH 04/11] =?UTF-8?q?[chore]=20#136=20=EC=82=AD=EC=A0=9C,=20?= =?UTF-8?q?=EC=8B=A0=EA=B3=A0=20=EC=8A=A4=EB=82=B5=EB=B0=94=20=EB=AC=B8?= =?UTF-8?q?=EC=9E=90=EC=97=B4=20=EB=A6=AC=EC=86=8C=EC=8A=A4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/values/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 71f5e280..0c469098 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -193,6 +193,11 @@ 업로드가 완료되었습니다 :) 죄송합니다. 업로드에 실패했습니다 :( + 게시물이 삭제되었습니다 + 댓글이 삭제되었습니다 :) + 죄송합니다. 다시 시도해주세요. + 정상적으로 신고되었습니다 :) + 죄송합니다. 신고접수에 실패하였습니다. LV. 평민 ㆍ From 8bd141c0072a2d2c804fdb2f158e5f5c8d0286c5 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Tue, 22 Aug 2023 00:39:36 +0900 Subject: [PATCH 05/11] =?UTF-8?q?[feat]=20#136=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=82=AD=EC=A0=9C=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20=EC=84=9C=EB=B2=84=ED=86=B5=EC=8B=A0=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/feed/detail/DetailViewModel.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt index 407a6f86..dc1d0e13 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt @@ -59,6 +59,9 @@ class DetailViewModel @Inject constructor( private val _postFeedDetailLikeState = MutableStateFlow>(UiState.Loading) val postFeedDetailLikeState: StateFlow> = _postFeedDetailLikeState.asStateFlow() + val _deleteFeedDetailState = MutableStateFlow>(UiState.Loading) + val deleteFeedDetailState: StateFlow> = _deleteFeedDetailState.asStateFlow() + fun likeFeed(feedId: Int, isLiked: Boolean) { val requestPostLikeDto = RequestPostLikeDto(isLiked) postLike(feedId, requestPostLikeDto) @@ -103,6 +106,16 @@ class DetailViewModel @Inject constructor( } } + fun deleteFeed(feedId: Int) { + viewModelScope.launch { + feedRepository.deleteFeed(feedId) + .onSuccess { response -> + _deleteFeedDetailState.emit(UiState.Success(response)) + } + .onFailure { t -> handleFailureState(_deleteFeedDetailState, t) } + } + } + private fun handleFailureState(loadingState: MutableStateFlow>, t: Throwable) { if (t is HttpException) { val errorMessage = when (t.code()) { From 7271c10288f29f63f7cdf87d13504d4cbe9a2ff2 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Tue, 22 Aug 2023 00:40:22 +0900 Subject: [PATCH 06/11] =?UTF-8?q?[feat]=20#136=20=EC=82=AD=EC=A0=9C,=20?= =?UTF-8?q?=EC=8B=A0=EA=B3=A0=EC=9D=98=20=ED=8C=9D=EC=97=85=EB=A9=94?= =?UTF-8?q?=EB=89=B4,=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C=EA=B7=B8=20?= =?UTF-8?q?=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/feed/detail/DetailActivity.kt | 108 ++++++++++++++---- .../main/feed/detail/DetailFeedAdapter.kt | 15 ++- 2 files changed, 98 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt index c4087dd4..cacb5c2d 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt @@ -1,6 +1,7 @@ package com.android.go.sopt.winey.presentation.main.feed.detail import CommentAdapter +import android.content.Intent import android.os.Bundle import android.view.Gravity import android.view.View @@ -13,9 +14,11 @@ import com.android.go.sopt.winey.databinding.ActivityDetailBinding import com.android.go.sopt.winey.domain.entity.Comment import com.android.go.sopt.winey.domain.entity.DetailFeed import com.android.go.sopt.winey.domain.repository.DataStoreRepository +import com.android.go.sopt.winey.presentation.main.MainActivity import com.android.go.sopt.winey.util.binding.BindingActivity import com.android.go.sopt.winey.util.context.snackBar import com.android.go.sopt.winey.util.context.stringOf +import com.android.go.sopt.winey.util.context.wineySnackbar import com.android.go.sopt.winey.util.fragment.WineyDialogFragment import com.android.go.sopt.winey.util.view.UiState import com.android.go.sopt.winey.util.view.WineyPopupMenu @@ -62,19 +65,36 @@ class DetailActivity : BindingActivity(R.layout.activity_ private fun initCommentAdapter() { _commentAdapter = CommentAdapter( onPopupMenuClicked = { anchorView, commentAuthorId -> - showPopupMenu(anchorView, commentAuthorId) + showCommentPopupMenu(anchorView, commentAuthorId) } ) } - private fun showPopupMenu(anchorView: View, commentAuthorId: Int) { + private fun initDetailFeedAdapter(detailFeed: DetailFeed?) { + if (detailFeed == null) { + Timber.e("DETAIL FEED IS NULL") + return + } + _detailFeedAdapter = + DetailFeedAdapter( + detailFeed, + onLikeButtonClicked = { feedId, isLiked -> + viewModel.likeFeed(feedId, isLiked) + }, + onPopupMenuClicked = { anchorView -> + showFeedPopupMenu(anchorView) + } + ) + } + + private fun showCommentPopupMenu(anchorView: View, commentAuthorId: Int) { lifecycleScope.launch { val currentUserId = dataStoreRepository.getUserId().first() if (isMyFeed(currentUserId)) { if (isMyComment(currentUserId, commentAuthorId)) { // 내 댓글 삭제 - showDeletePopupMenu(anchorView) + showCommentDeletePopupMenu(anchorView) } else { // 방문자 댓글 삭제/신고 showAllPopupMenu(anchorView) @@ -82,7 +102,7 @@ class DetailActivity : BindingActivity(R.layout.activity_ } else { if (isMyComment(currentUserId, commentAuthorId)) { // 내 댓글 삭제 - showDeletePopupMenu(anchorView) + showCommentDeletePopupMenu(anchorView) } else { // 다른 사람 댓글 신고 showReportPopupMenu(anchorView) @@ -91,7 +111,18 @@ class DetailActivity : BindingActivity(R.layout.activity_ } } - private fun showDeletePopupMenu(anchorView: View) { + private fun showFeedPopupMenu(anchorView: View) { + lifecycleScope.launch { + val currentUserId = dataStoreRepository.getUserId().first() + if (isMyFeed(currentUserId)) { + showFeedDeletePopupMenu(anchorView) + } else { + showReportPopupMenu(anchorView) + } + } + } + + private fun showCommentDeletePopupMenu(anchorView: View) { val deleteTitle = listOf(stringOf(R.string.popup_delete_title)) WineyPopupMenu(context = anchorView.context, titles = deleteTitle) { _, _, _ -> showCommentDeleteDialog() @@ -100,6 +131,15 @@ class DetailActivity : BindingActivity(R.layout.activity_ } } + private fun showFeedDeletePopupMenu(anchorView: View) { + val deleteTitle = listOf(stringOf(R.string.popup_delete_title)) + WineyPopupMenu(context = anchorView.context, titles = deleteTitle) { _, _, _ -> + showFeedDeleteDialog() + }.apply { + showCustomPosition(anchorView) + } + } + private fun showReportPopupMenu(anchorView: View) { val reportTitle = listOf(stringOf(R.string.popup_report_title)) WineyPopupMenu(context = anchorView.context, titles = reportTitle) { _, _, _ -> @@ -135,11 +175,24 @@ class DetailActivity : BindingActivity(R.layout.activity_ stringOf(R.string.comment_delete_dialog_negative_button), stringOf(R.string.comment_delete_dialog_positive_button), handleNegativeButton = {}, - handlePositiveButton = { /* todo: 댓글 삭제하기 */ } + handlePositiveButton = { /* todo: 댓글 삭제하기 */} ) dialog.show(supportFragmentManager, TAG_COMMENT_DELETE_DIALOG) } + private fun showFeedDeleteDialog() { + val dialog = WineyDialogFragment( + stringOf(R.string.feed_delete_dialog_title), + stringOf(R.string.feed_delete_dialog_subtitle), + stringOf(R.string.comment_delete_dialog_negative_button), + stringOf(R.string.comment_delete_dialog_positive_button), + handleNegativeButton = {}, + handlePositiveButton = { viewModel.deleteFeed(feedId) } + ) + dialog.show(supportFragmentManager, TAG_COMMENT_DELETE_DIALOG) + initDeleteFeedStateObserver() + } + private fun showCommentReportDialog() { val dialog = WineyDialogFragment( stringOf(R.string.report_dialog_title), @@ -179,8 +232,7 @@ class DetailActivity : BindingActivity(R.layout.activity_ snackBar(binding.root) { state.msg } } - else -> { - } + else -> Timber.tag("failure").e(MSG_DETAIL_ERROR) } }.launchIn(lifecycleScope) } @@ -198,24 +250,25 @@ class DetailActivity : BindingActivity(R.layout.activity_ snackBar(binding.root) { state.msg } } - else -> { - } + else -> Timber.tag("failure").e(MSG_DETAIL_ERROR) } }.launchIn(lifecycleScope) } - private fun initDetailFeedAdapter(detailFeed: DetailFeed?) { - if (detailFeed == null) { - Timber.e("DETAIL FEED IS NULL") - return - } - _detailFeedAdapter = - DetailFeedAdapter( - detailFeed, - postLike = { feedId, isLiked -> - viewModel.likeFeed(feedId, isLiked) + private fun initDeleteFeedStateObserver() { + viewModel.deleteFeedDetailState.flowWithLifecycle(lifecycle).onEach { state -> + when (state) { + is UiState.Success -> { + navigateToMain() } - ) + + is UiState.Failure -> { + wineySnackbar(binding.root, false, stringOf(R.string.snackbar_delete_fail)) + } + + else -> Timber.tag("failure").e(MSG_DETAIL_ERROR) + } + }.launchIn(lifecycleScope) } private fun switchCommentContainer(commentList: List?) { @@ -250,11 +303,20 @@ class DetailActivity : BindingActivity(R.layout.activity_ } else -> { + } } }.launchIn(lifecycleScope) } + private fun navigateToMain() { + Intent(this, MainActivity::class.java).apply { + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) + putExtra(EXTRA_DELETE_KEY, true) + startActivity(this) + } + } + companion object { private const val KEY_FEED_ID = "feedId" private const val KEY_FEED_WRITER_ID = "feedWriterId" @@ -263,5 +325,9 @@ class DetailActivity : BindingActivity(R.layout.activity_ private const val TAG_COMMENT_REPORT_DIALOG = "COMMENT_REPORT_DIALOG" private const val POPUP_MENU_OFFSET = 65 + + private const val MSG_DETAIL_ERROR = "ERROR" + + private const val EXTRA_DELETE_KEY = "delete" } } diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFeedAdapter.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFeedAdapter.kt index 5d791810..f290e5aa 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFeedAdapter.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFeedAdapter.kt @@ -1,6 +1,7 @@ package com.android.go.sopt.winey.presentation.main.feed.detail import android.view.LayoutInflater +import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.android.go.sopt.winey.databinding.ItemDetailFeedBinding @@ -9,14 +10,15 @@ import com.android.go.sopt.winey.util.view.setOnSingleClickListener class DetailFeedAdapter( private val detailFeed: DetailFeed, - private val postLike: (feedId: Int, isLiked: Boolean) -> Unit + private val onLikeButtonClicked: (feedId: Int, isLiked: Boolean) -> Unit, + private val onPopupMenuClicked: (View) -> Unit ) : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DetailFeedViewHolder { val binding = ItemDetailFeedBinding.inflate(LayoutInflater.from(parent.context), parent, false) - return DetailFeedViewHolder(binding, postLike) + return DetailFeedViewHolder(binding, onLikeButtonClicked, onPopupMenuClicked) } override fun getItemCount(): Int = FEED_ITEM_COUNT @@ -32,7 +34,8 @@ class DetailFeedAdapter( class DetailFeedViewHolder( private val binding: ItemDetailFeedBinding, - private val postLike: (feedId: Int, isLiked: Boolean) -> Unit + private val onLikeButtonClicked: (feedId: Int, isLiked: Boolean) -> Unit, + private val onPopupMenuClicked: (View) -> Unit ) : RecyclerView.ViewHolder(binding.root) { fun bind(data: DetailFeed?) { binding.apply { @@ -41,8 +44,12 @@ class DetailFeedAdapter( return } ivDetailLike.setOnSingleClickListener { - postLike(data.feedId, !data.isLiked) + onLikeButtonClicked(data.feedId, !data.isLiked) } + btnDetailMore.setOnSingleClickListener { view -> + onPopupMenuClicked(view) + } + } } } From 5f12bc7cdf704e627e91dcad1fcdcbf9b32c3b91 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Tue, 22 Aug 2023 00:40:48 +0900 Subject: [PATCH 07/11] =?UTF-8?q?[feat]=20#136=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=20=EC=8B=9C=20=EC=9C=84=EB=8B=88=ED=94=BC?= =?UTF-8?q?=EB=93=9C=EB=A1=9C=20=EB=8F=8C=EC=95=84=EA=B0=80=20=EC=8A=A4?= =?UTF-8?q?=EB=82=B5=EB=B0=94=20=EB=9C=A8=EB=8F=84=EB=A1=9D=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../go/sopt/winey/presentation/main/MainActivity.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt index 870e6492..2a82f966 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt @@ -27,7 +27,7 @@ import kotlinx.coroutines.flow.onEach class MainActivity : BindingActivity(R.layout.activity_main) { private val mainViewModel by viewModels() private val isUploadSuccess by lazy { intent.extras?.getBoolean(EXTRA_UPLOAD_KEY, false) } - + private val isDeleteSuccess by lazy { intent.extras?.getBoolean(EXTRA_DELETE_KEY, false) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -40,6 +40,7 @@ class MainActivity : BindingActivity(R.layout.activity_main setupLogoutState() showUploadSuccessSnackbar() + showDeleteSuccessSnackbar() } private fun initFragment() { @@ -57,6 +58,12 @@ class MainActivity : BindingActivity(R.layout.activity_main } } + private fun showDeleteSuccessSnackbar() { + if (isDeleteSuccess != null && isDeleteSuccess == true) { + wineySnackbar(binding.root, true, stringOf(R.string.snackbar_feed_delete_success)) + } + } + private fun initBnvItemSelectedListener() { binding.bnvMain.setOnItemSelectedListener { item -> when (item.itemId) { @@ -119,5 +126,6 @@ class MainActivity : BindingActivity(R.layout.activity_main companion object { private const val EXTRA_UPLOAD_KEY = "upload" + private const val EXTRA_DELETE_KEY = "delete" } } From bf1a2d6934f1f84348702f38159f4beca613c4aa Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Tue, 22 Aug 2023 00:51:00 +0900 Subject: [PATCH 08/11] =?UTF-8?q?[feat]=20#136=20=EC=8B=A0=EA=B3=A0=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=20=EC=8B=9C=20=EC=9C=84=EB=8B=88=ED=94=BC?= =?UTF-8?q?=EB=93=9C=EB=A1=9C=20=EB=8F=8C=EC=95=84=EA=B0=80=20=EC=8A=A4?= =?UTF-8?q?=EB=82=B5=EB=B0=94=20=EB=9C=A8=EB=8F=84=EB=A1=9D=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/main/feed/detail/DetailActivity.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt index cacb5c2d..e5fcfcea 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt @@ -175,7 +175,7 @@ class DetailActivity : BindingActivity(R.layout.activity_ stringOf(R.string.comment_delete_dialog_negative_button), stringOf(R.string.comment_delete_dialog_positive_button), handleNegativeButton = {}, - handlePositiveButton = { /* todo: 댓글 삭제하기 */} + handlePositiveButton = { /* todo: 댓글 삭제하기 */ } ) dialog.show(supportFragmentManager, TAG_COMMENT_DELETE_DIALOG) } @@ -200,7 +200,7 @@ class DetailActivity : BindingActivity(R.layout.activity_ stringOf(R.string.report_dialog_negative_button), stringOf(R.string.report_dialog_positive_button), handleNegativeButton = {}, - handlePositiveButton = { /* todo: 댓글 신고하기 */ } + handlePositiveButton = { navigateToMain(EXTRA_REPORT_KEY) } ) dialog.show(supportFragmentManager, TAG_COMMENT_REPORT_DIALOG) } @@ -259,7 +259,7 @@ class DetailActivity : BindingActivity(R.layout.activity_ viewModel.deleteFeedDetailState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { is UiState.Success -> { - navigateToMain() + navigateToMain(EXTRA_DELETE_KEY) } is UiState.Failure -> { @@ -309,10 +309,10 @@ class DetailActivity : BindingActivity(R.layout.activity_ }.launchIn(lifecycleScope) } - private fun navigateToMain() { + private fun navigateToMain(extraKey: String) { Intent(this, MainActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) - putExtra(EXTRA_DELETE_KEY, true) + putExtra(extraKey, true) startActivity(this) } } @@ -329,5 +329,6 @@ class DetailActivity : BindingActivity(R.layout.activity_ private const val MSG_DETAIL_ERROR = "ERROR" private const val EXTRA_DELETE_KEY = "delete" + private const val EXTRA_REPORT_KEY = "report" } } From 465a50205e33994b801ee1a667f9c815e1930286 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Tue, 22 Aug 2023 00:51:23 +0900 Subject: [PATCH 09/11] =?UTF-8?q?[feat]=20#136=20=EC=8A=A4=EB=82=B5?= =?UTF-8?q?=EB=B0=94=20=EB=A1=9C=EC=A7=81=20=ED=86=B5=EC=9D=BC=ED=95=B4=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../go/sopt/winey/presentation/main/MainActivity.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt index 2a82f966..52422b78 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt @@ -28,6 +28,7 @@ class MainActivity : BindingActivity(R.layout.activity_main private val mainViewModel by viewModels() private val isUploadSuccess by lazy { intent.extras?.getBoolean(EXTRA_UPLOAD_KEY, false) } private val isDeleteSuccess by lazy { intent.extras?.getBoolean(EXTRA_DELETE_KEY, false) } + private val isReportSuccess by lazy { intent.extras?.getBoolean(EXTRA_REPORT_KEY, false) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -39,8 +40,7 @@ class MainActivity : BindingActivity(R.layout.activity_main syncBottomNavigationSelection() setupLogoutState() - showUploadSuccessSnackbar() - showDeleteSuccessSnackbar() + showSuccessSnackBar() } private fun initFragment() { @@ -52,16 +52,16 @@ class MainActivity : BindingActivity(R.layout.activity_main } } - private fun showUploadSuccessSnackbar() { + private fun showSuccessSnackBar(){ if (isUploadSuccess != null && isUploadSuccess == true) { wineySnackbar(binding.root, true, stringOf(R.string.snackbar_upload_success)) } - } - - private fun showDeleteSuccessSnackbar() { if (isDeleteSuccess != null && isDeleteSuccess == true) { wineySnackbar(binding.root, true, stringOf(R.string.snackbar_feed_delete_success)) } + if (isReportSuccess != null && isReportSuccess == true) { + wineySnackbar(binding.root, true, stringOf(R.string.snackbar_report_success)) + } } private fun initBnvItemSelectedListener() { @@ -127,5 +127,6 @@ class MainActivity : BindingActivity(R.layout.activity_main companion object { private const val EXTRA_UPLOAD_KEY = "upload" private const val EXTRA_DELETE_KEY = "delete" + private const val EXTRA_REPORT_KEY = "report" } } From 603e5fcf7000272c880ef79d507b1e719844c18d Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Tue, 22 Aug 2023 01:01:28 +0900 Subject: [PATCH 10/11] =?UTF-8?q?[feat]=20#136=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=94=BC=EB=93=9C=20=EC=83=81=EC=84=B8=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=ED=94=BC=EB=93=9C=20=EC=82=AD=EC=A0=9C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../winey/presentation/main/feed/WineyFeedAdapter.kt | 2 +- .../presentation/main/mypage/myfeed/MyFeedAdapter.kt | 6 +++--- .../main/mypage/myfeed/MyFeedFragment.kt | 12 +++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedAdapter.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedAdapter.kt index 904ac6d5..fc8d2346 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedAdapter.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedAdapter.kt @@ -15,7 +15,7 @@ import com.android.go.sopt.winey.util.view.setOnSingleClickListener class WineyFeedAdapter( private val likeButtonClick: (feedId: Int, isLiked: Boolean) -> Unit, private val showPopupMenu: (View, WineyFeed) -> Unit, - private val toFeedDetail: (feedId: Int, writerLevel: Int) -> Unit + private val toFeedDetail: (feedId: Int, writerId: Int) -> Unit ) : PagingDataAdapter(diffUtil) { private val currentData: ItemSnapshotList get() = snapshot() diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedAdapter.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedAdapter.kt index 7a86698d..df599c69 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedAdapter.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedAdapter.kt @@ -15,7 +15,7 @@ import com.android.go.sopt.winey.util.view.setOnSingleClickListener class MyFeedAdapter( private val likeButtonClick: (feedId: Int, isLiked: Boolean) -> Unit, private val showPopupMenu: (View, WineyFeed) -> Unit, - private val toFeedDetail: (feedId: Int, writerLevel: Int) -> Unit + private val toFeedDetail: (feedId: Int, writerId: Int) -> Unit ) : PagingDataAdapter(diffUtil) { private val currentData: ItemSnapshotList get() = snapshot() @@ -24,7 +24,7 @@ class MyFeedAdapter( private val binding: ItemMyfeedPostBinding, private val onLikeButtonClick: (feedId: Int, isLiked: Boolean) -> Unit, private val showPopupMenu: (View, WineyFeed) -> Unit, - private val toFeedDetail: (feedId: Int, writerLevel: Int) -> Unit + private val toFeedDetail: (feedId: Int, writerId: Int) -> Unit ) : RecyclerView.ViewHolder(binding.root) { fun onBind(data: WineyFeed?) { binding.apply { @@ -40,7 +40,7 @@ class MyFeedAdapter( showPopupMenu(view, data) } lMyfeedPost.setOnSingleClickListener { - toFeedDetail(data.feedId, data.writerLevel) + toFeedDetail(data.feedId, data.userId) } } } diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedFragment.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedFragment.kt index b52c93ca..a9aec58b 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedFragment.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedFragment.kt @@ -59,7 +59,7 @@ class MyFeedFragment : BindingFragment(R.layout.fragment_ showPopupMenu = { view, wineyFeed -> showPopupMenu(view, wineyFeed) }, - toFeedDetail = { feedId, writerLevel -> navigateToDetail(feedId, writerLevel) } + toFeedDetail = { feedId, writerId -> navigateToDetail(feedId, writerId) } ) binding.rvMyfeedPost.adapter = myFeedAdapter.withLoadStateFooter(wineyFeedLoadAdapter) } @@ -182,10 +182,10 @@ class MyFeedFragment : BindingFragment(R.layout.fragment_ } } - private fun navigateToDetail(feedId: Int, writerLevel: Int) { + private fun navigateToDetail(feedId: Int, writerId: Int) { val intent = Intent(requireContext(), DetailActivity::class.java) - intent.putExtra("feedId", feedId) - intent.putExtra("writerLevel", writerLevel) + intent.putExtra(KEY_FEED_ID, feedId) + intent.putExtra(KEY_FEED_WRITER_ID, writerId) startActivity(intent) } @@ -198,7 +198,9 @@ class MyFeedFragment : BindingFragment(R.layout.fragment_ } companion object { - private const val LV_KNIGHT = 2 + private const val KEY_FEED_ID = "feedId" + private const val KEY_FEED_WRITER_ID = "feedWriterId" + private const val MSG_MYFEED_ERROR = "ERROR" private const val TAG_DELETE_DIALOG = "DELETE_DIALOG" } From a085c47a0a3ef3afb0e79364906be45b0d56f9e7 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Tue, 22 Aug 2023 01:28:00 +0900 Subject: [PATCH 11/11] =?UTF-8?q?[chore]=20#136=20ktlint=20=EC=A0=9C?= =?UTF-8?q?=EC=95=88=EC=82=AC=ED=95=AD=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/go/sopt/winey/presentation/main/MainActivity.kt | 2 +- .../winey/presentation/main/feed/detail/DetailActivity.kt | 4 +--- .../winey/presentation/main/feed/detail/DetailFeedAdapter.kt | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt index 52422b78..cbcd0ec8 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt @@ -52,7 +52,7 @@ class MainActivity : BindingActivity(R.layout.activity_main } } - private fun showSuccessSnackBar(){ + private fun showSuccessSnackBar() { if (isUploadSuccess != null && isUploadSuccess == true) { wineySnackbar(binding.root, true, stringOf(R.string.snackbar_upload_success)) } diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt index e5fcfcea..acd50c40 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt @@ -302,9 +302,7 @@ class DetailActivity : BindingActivity(R.layout.activity_ snackBar(binding.root) { state.msg } } - else -> { - - } + else -> Timber.tag("failure").e(MSG_DETAIL_ERROR) } }.launchIn(lifecycleScope) } diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFeedAdapter.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFeedAdapter.kt index f290e5aa..0c066890 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFeedAdapter.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFeedAdapter.kt @@ -49,7 +49,6 @@ class DetailFeedAdapter( btnDetailMore.setOnSingleClickListener { view -> onPopupMenuClicked(view) } - } } }