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..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 @@ -27,7 +27,8 @@ 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) } + private val isReportSuccess by lazy { intent.extras?.getBoolean(EXTRA_REPORT_KEY, false) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -39,7 +40,7 @@ class MainActivity : BindingActivity(R.layout.activity_main syncBottomNavigationSelection() setupLogoutState() - showUploadSuccessSnackbar() + showSuccessSnackBar() } private fun initFragment() { @@ -51,10 +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)) } + 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() { @@ -119,5 +126,7 @@ 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" } } 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 b1d3d017..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() @@ -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 b9742eee..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 @@ -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 @@ -49,7 +50,8 @@ 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 @@ -61,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() @@ -105,8 +108,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(R.id.tv_popup_delete) + val menuReport = + popupView.findViewById(R.id.tv_popup_report) if (wineyFeed.userId == runBlocking { dataStoreRepository.getUserId().first() }) { menuReport.isVisible = false @@ -188,10 +193,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 -> { @@ -256,7 +258,8 @@ class WineyFeedFragment : BindingFragment(R.layout.fra parentFragmentManager.commit { replace(R.id.fcv_main, T::class.simpleName) } - val bottomNav: BottomNavigationView = requireActivity().findViewById(R.id.bnv_main) + val bottomNav: BottomNavigationView = + requireActivity().findViewById(R.id.bnv_main) bottomNav.selectedItemId = R.id.menu_mypage } 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 eef58ae2..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 @@ -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 @@ -52,6 +55,7 @@ class DetailActivity : BindingActivity(R.layout.activity_ viewModel.getFeedDetail(feedId) initGetFeedDetailObserver() initBackButtonClickListener() + initPostLikeStateObserver() initCommentAdapter() initCommentCreateButtonClickListener() @@ -61,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) @@ -81,7 +102,7 @@ class DetailActivity : BindingActivity(R.layout.activity_ } else { if (isMyComment(currentUserId, commentAuthorId)) { // 내 댓글 삭제 - showDeletePopupMenu(anchorView) + showCommentDeletePopupMenu(anchorView) } else { // 다른 사람 댓글 신고 showReportPopupMenu(anchorView) @@ -90,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() @@ -99,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) { _, _, _ -> @@ -139,6 +180,19 @@ class DetailActivity : BindingActivity(R.layout.activity_ 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), @@ -146,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) } @@ -178,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) } @@ -197,18 +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) + private fun initDeleteFeedStateObserver() { + viewModel.deleteFeedDetailState.flowWithLifecycle(lifecycle).onEach { state -> + when (state) { + is UiState.Success -> { + navigateToMain(EXTRA_DELETE_KEY) + } + + 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?) { @@ -231,6 +291,30 @@ 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 -> Timber.tag("failure").e(MSG_DETAIL_ERROR) + } + }.launchIn(lifecycleScope) + } + + private fun navigateToMain(extraKey: String) { + Intent(this, MainActivity::class.java).apply { + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) + putExtra(extraKey, true) + startActivity(this) + } + } + companion object { private const val KEY_FEED_ID = "feedId" private const val KEY_FEED_WRITER_ID = "feedWriterId" @@ -239,5 +323,10 @@ 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" + private const val EXTRA_REPORT_KEY = "report" } } 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 163b3587..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 @@ -1,30 +1,24 @@ 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 import com.android.go.sopt.winey.domain.entity.DetailFeed +import com.android.go.sopt.winey.util.view.setOnSingleClickListener class DetailFeedAdapter( - private val detailFeed: DetailFeed -) : RecyclerView.Adapter() { - class DetailFeedViewHolder( - private val binding: ItemDetailFeedBinding - ) : RecyclerView.ViewHolder(binding.root) { - fun bind(data: DetailFeed) { - binding.data = data - } - } + private val detailFeed: DetailFeed, + private val onLikeButtonClicked: (feedId: Int, isLiked: Boolean) -> Unit, + private val onPopupMenuClicked: (View) -> 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, onLikeButtonClicked, onPopupMenuClicked) } override fun getItemCount(): Int = FEED_ITEM_COUNT @@ -38,6 +32,27 @@ class DetailFeedAdapter( notifyItemChanged(0) } + class DetailFeedViewHolder( + private val binding: ItemDetailFeedBinding, + private val onLikeButtonClicked: (feedId: Int, isLiked: Boolean) -> Unit, + private val onPopupMenuClicked: (View) -> Unit + ) : RecyclerView.ViewHolder(binding.root) { + fun bind(data: DetailFeed?) { + binding.apply { + this.data = data + if (data == null) { + return + } + ivDetailLike.setOnSingleClickListener { + onLikeButtonClicked(data.feedId, !data.isLiked) + } + btnDetailMore.setOnSingleClickListener { view -> + onPopupMenuClicked(view) + } + } + } + } + companion object { private const val FEED_ITEM_COUNT = 1 } 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 dcb07797..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 @@ -4,7 +4,9 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.android.go.sopt.winey.data.model.remote.request.RequestPostCommentDto import com.android.go.sopt.winey.domain.entity.Comment +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 @@ -54,6 +56,17 @@ class DetailViewModel @Inject constructor( private val _postCommentState = MutableStateFlow>(UiState.Loading) val postCommentState: StateFlow> = _postCommentState.asStateFlow() + 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) + } + fun getFeedDetail(feedId: Int) { viewModelScope.launch { feedRepository.getFeedDetail(feedId) @@ -83,6 +96,26 @@ 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) } + } + } + + 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()) { 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..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) } } } @@ -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,23 +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( onItemsTheSame = { old, new -> old.feedId == new.feedId }, 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..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) } @@ -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 -> { @@ -185,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) } @@ -201,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" } 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. 평민 ㆍ