Skip to content

Commit

Permalink
Merge pull request #134 from team-winey/feature/feat-detail-getFeedDe…
Browse files Browse the repository at this point in the history
…tail

[feat] 마이 피드 / 상세페이지 피드, 댓글 조회
  • Loading branch information
sxunea authored Aug 20, 2023
2 parents cc58fd1 + 24440e5 commit 799b64b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<WineyFeed, WineyFeedAdapter.WineyFeedViewHolder>(diffUtil) {
) : PagingDataAdapter<WineyFeed, WineyFeedAdapter.WineyFeedViewHolder>(diffUtil) {
private val currentData: ItemSnapshotList<WineyFeed>
get() = snapshot()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ 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<WineyFeed, MyFeedAdapter.MyFeedViewHolder>(diffUtil) {
private val currentData: ItemSnapshotList<WineyFeed>
get() = snapshot()

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 {
Expand All @@ -37,6 +39,9 @@ class MyFeedAdapter(
btnWineyfeedMore.setOnClickListener { view ->
showPopupMenu(view, data)
}
lMyfeedPost.setOnSingleClickListener {
toFeedDetail(data.feedId, data.writerLevel)
}
}
}

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
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
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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -53,7 +58,8 @@ class MyFeedFragment : BindingFragment<FragmentMyfeedBinding>(R.layout.fragment_
},
showPopupMenu = { view, wineyFeed ->
showPopupMenu(view, wineyFeed)
}
},
toFeedDetail = { feedId, writerLevel -> navigateToDetail(feedId, writerLevel) }
)
binding.rvMyfeedPost.adapter = myFeedAdapter.withLoadStateFooter(wineyFeedLoadAdapter)
}
Expand Down Expand Up @@ -95,7 +101,8 @@ class MyFeedFragment : BindingFragment<FragmentMyfeedBinding>(R.layout.fragment_

private fun initButtonClickListener() {
binding.imgMyfeedBack.setOnSingleClickListener {
navigateToMyPage()
navigateTo<MyPageFragment>()
parentFragmentManager.popBackStack()
}
}

Expand Down Expand Up @@ -178,11 +185,19 @@ class MyFeedFragment : BindingFragment<FragmentMyfeedBinding>(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 <reified T : Fragment> navigateTo() {
parentFragmentManager.commit {
replace(R.id.fcv_main, MyPageFragment())
replace<T>(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 {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_myfeed_post.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/l_myfeed_post"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Expand Down

0 comments on commit 799b64b

Please sign in to comment.