From b6bdbed9f13371a8ba6fd1712cdf0829588f9aba Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Sun, 20 Aug 2023 23:09:13 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20#124=20=EB=A7=88=EC=9D=B4=ED=94=BC?= =?UTF-8?q?=EB=93=9C=20=EC=83=81=EC=84=B8=ED=8E=98=EC=9D=B4=EC=A7=80(?= =?UTF-8?q?=ED=94=BC=EB=93=9C,=EB=8C=93=EA=B8=80)=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/feed/WineyFeedAdapter.kt | 3 +-- .../main/mypage/myfeed/MyFeedAdapter.kt | 11 +++++--- .../main/mypage/myfeed/MyFeedFragment.kt | 25 +++++++++++++++---- app/src/main/res/layout/item_myfeed_post.xml | 1 + 4 files changed, 30 insertions(+), 10 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 78e7b47e..b5b0152f 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 @@ -16,8 +16,7 @@ class WineyFeedAdapter( private val likeButtonClick: (feedId: Int, isLiked: Boolean) -> Unit, private val showPopupMenu: (View, WineyFeed) -> Unit, private val toFeedDetail: (feedId: Int, writerLevel: Int) -> Unit -) : - PagingDataAdapter(diffUtil) { +) : 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 82734192..336924c7 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 @@ -14,7 +14,8 @@ 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 showPopupMenu: (View, WineyFeed) -> Unit, + private val toFeedDetail: (feedId: Int, writerLevel: Int) -> Unit ) : PagingDataAdapter(diffUtil) { private val currentData: ItemSnapshotList get() = snapshot() @@ -22,7 +23,8 @@ class MyFeedAdapter( class MyFeedViewHolder( private val binding: ItemMyfeedPostBinding, private val onLikeButtonClick: (feedId: Int, isLiked: Boolean) -> Unit, - private val showPopupMenu: (View, WineyFeed) -> Unit + private val showPopupMenu: (View, WineyFeed) -> Unit, + private val toFeedDetail: (feedId: Int, writerLevel: Int) -> Unit ) : RecyclerView.ViewHolder(binding.root) { fun onBind(data: WineyFeed?) { binding.apply { @@ -37,6 +39,9 @@ class MyFeedAdapter( btnWineyfeedMore.setOnClickListener { view -> showPopupMenu(view, data) } + lMyfeedPost.setOnSingleClickListener { + toFeedDetail(data.feedId, data.writerLevel) + } } } @@ -58,7 +63,7 @@ class MyFeedAdapter( viewType: Int ): MyFeedViewHolder { val binding = ItemMyfeedPostBinding.inflate(LayoutInflater.from(parent.context), parent, false) - return MyFeedViewHolder(binding, likeButtonClick, showPopupMenu) + return MyFeedViewHolder(binding, likeButtonClick, showPopupMenu, toFeedDetail) } override fun onBindViewHolder(holder: MyFeedViewHolder, position: Int) { 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 a72bd29b..4a4cff71 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 @@ -1,5 +1,6 @@ package com.android.go.sopt.winey.presentation.main.mypage.myfeed +import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -7,7 +8,9 @@ import android.view.WindowManager import android.widget.PopupWindow import android.widget.TextView import androidx.core.view.isVisible +import androidx.fragment.app.Fragment import androidx.fragment.app.commit +import androidx.fragment.app.replace import androidx.fragment.app.viewModels import androidx.lifecycle.Lifecycle import androidx.lifecycle.flowWithLifecycle @@ -17,6 +20,7 @@ import com.android.go.sopt.winey.R import com.android.go.sopt.winey.databinding.FragmentMyfeedBinding import com.android.go.sopt.winey.domain.entity.WineyFeed import com.android.go.sopt.winey.presentation.main.feed.WineyFeedLoadAdapter +import com.android.go.sopt.winey.presentation.main.feed.detail.DetailActivity import com.android.go.sopt.winey.presentation.main.mypage.MyPageFragment import com.android.go.sopt.winey.util.binding.BindingFragment import com.android.go.sopt.winey.util.fragment.WineyDialogFragment @@ -25,6 +29,7 @@ import com.android.go.sopt.winey.util.fragment.viewLifeCycle import com.android.go.sopt.winey.util.fragment.viewLifeCycleScope import com.android.go.sopt.winey.util.view.UiState import com.android.go.sopt.winey.util.view.setOnSingleClickListener +import com.google.android.material.bottomnavigation.BottomNavigationView import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.launchIn @@ -53,7 +58,8 @@ class MyFeedFragment : BindingFragment(R.layout.fragment_ }, showPopupMenu = { view, wineyFeed -> showPopupMenu(view, wineyFeed) - } + }, + toFeedDetail = { feedId, writerLevel -> navigateToDetail(feedId, writerLevel) } ) binding.rvMyfeedPost.adapter = myFeedAdapter.withLoadStateFooter(wineyFeedLoadAdapter) } @@ -95,7 +101,8 @@ class MyFeedFragment : BindingFragment(R.layout.fragment_ private fun initButtonClickListener() { binding.imgMyfeedBack.setOnSingleClickListener { - navigateToMyPage() + navigateTo() + parentFragmentManager.popBackStack() } } @@ -178,11 +185,19 @@ class MyFeedFragment : BindingFragment(R.layout.fragment_ } } - private fun navigateToMyPage() { + private fun navigateToDetail(feedId: Int, writerLevel: Int) { + val intent = Intent(requireContext(), DetailActivity::class.java) + intent.putExtra("feedId", feedId) + intent.putExtra("writerLevel", writerLevel) + startActivity(intent) + } + + private inline fun navigateTo() { parentFragmentManager.commit { - replace(R.id.fcv_main, MyPageFragment()) + replace(R.id.fcv_main, T::class.simpleName) } - parentFragmentManager.popBackStack() + val bottomNav: BottomNavigationView = requireActivity().findViewById(R.id.bnv_main) + bottomNav.selectedItemId = R.id.menu_mypage } companion object { diff --git a/app/src/main/res/layout/item_myfeed_post.xml b/app/src/main/res/layout/item_myfeed_post.xml index 20f14129..c8a6993a 100644 --- a/app/src/main/res/layout/item_myfeed_post.xml +++ b/app/src/main/res/layout/item_myfeed_post.xml @@ -11,6 +11,7 @@