From 434c24240015f8aac4e0916012d97e2bb24e3352 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Fri, 18 Aug 2023 21:29:51 +0900 Subject: [PATCH 01/16] =?UTF-8?q?[ui]=20#120=20=EC=83=81=EC=84=B8=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=ED=94=BC=EB=93=9C=20=EB=B7=B0=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 --- app/src/main/res/layout/fragment_detail.xml | 223 ++++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 app/src/main/res/layout/fragment_detail.xml diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml new file mode 100644 index 00000000..d405cbad --- /dev/null +++ b/app/src/main/res/layout/fragment_detail.xml @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 3c2612378ff2826a93a701822cd9c6a9b034b9e7 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Fri, 18 Aug 2023 21:30:21 +0900 Subject: [PATCH 02/16] =?UTF-8?q?[ui]=20#120=20=EC=83=81=EC=84=B8=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=8C=93=EA=B8=80=20=EB=B7=B0=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/res/layout/item_detail_comment.xml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 app/src/main/res/layout/item_detail_comment.xml diff --git a/app/src/main/res/layout/item_detail_comment.xml b/app/src/main/res/layout/item_detail_comment.xml new file mode 100644 index 00000000..aef25be0 --- /dev/null +++ b/app/src/main/res/layout/item_detail_comment.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + From 02ca4f8c7aeba43cb5085d26e9a0f5d0d9000034 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Fri, 18 Aug 2023 22:06:59 +0900 Subject: [PATCH 03/16] =?UTF-8?q?[ui]=20#120=20=ED=83=80=EC=9D=B4=ED=8B=80?= =?UTF-8?q?=EA=B3=BC=20=EB=8C=93=EA=B8=80=20=EC=88=98=20=EC=82=AC=EC=9D=B4?= =?UTF-8?q?=20=EA=B0=84=EA=B2=A9=20=EA=B3=A0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/fragment_detail.xml | 29 ++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml index d405cbad..75cda37c 100644 --- a/app/src/main/res/layout/fragment_detail.xml +++ b/app/src/main/res/layout/fragment_detail.xml @@ -80,8 +80,8 @@ android:layout_height="wrap_content" android:layout_marginTop="12dp" android:layout_marginEnd="10dp" - android:padding="6dp" android:background="@android:color/transparent" + android:padding="6dp" android:src="@drawable/ic_wineyfeed_more" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -99,10 +99,10 @@ + app:layout_constraintTop_toTopOf="@id/iv_detail_comment" + tools:text="12" /> + app:layout_constraintTop_toTopOf="@id/iv_detail_comment" /> Date: Sat, 19 Aug 2023 01:05:17 +0900 Subject: [PATCH 04/16] =?UTF-8?q?[add]=20#124=20dto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/ResponseGetFeedDetailDto.kt | 81 +++++++++++++++++++ .../go/sopt/winey/domain/entity/DetailFeed.kt | 26 ++++++ 2 files changed, 107 insertions(+) create mode 100644 app/src/main/java/com/android/go/sopt/winey/data/model/remote/response/ResponseGetFeedDetailDto.kt create mode 100644 app/src/main/java/com/android/go/sopt/winey/domain/entity/DetailFeed.kt diff --git a/app/src/main/java/com/android/go/sopt/winey/data/model/remote/response/ResponseGetFeedDetailDto.kt b/app/src/main/java/com/android/go/sopt/winey/data/model/remote/response/ResponseGetFeedDetailDto.kt new file mode 100644 index 00000000..879d106f --- /dev/null +++ b/app/src/main/java/com/android/go/sopt/winey/data/model/remote/response/ResponseGetFeedDetailDto.kt @@ -0,0 +1,81 @@ +package com.android.go.sopt.winey.data.model.remote.response + +import com.android.go.sopt.winey.domain.entity.CommentList +import com.android.go.sopt.winey.domain.entity.DetailFeed +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ResponseGetDetailDto( + @SerialName("getFeedResponseDto") + val getFeedResponseDto: GetFeedResponseDto, + @SerialName("getCommentResponseList") + val getCommentResponseList: List +) { + @Serializable + data class GetFeedResponseDto( + @SerialName("createdAt") + val createdAt: String, + @SerialName("feedId") + val feedId: Int, + @SerialName("feedImage") + val feedImage: String, + @SerialName("feedMoney") + val feedMoney: Long, + @SerialName("feedTitle") + val feedTitle: String, + @SerialName("isLiked") + val isLiked: Boolean, + @SerialName("likes") + val likes: Long, + @SerialName("nickName") + val nickName: String, + @SerialName("userId") + val userId: Int, + @SerialName("writerLevel") + val writerLevel: Int, + @SerialName("comments") + val comments: Long, + @SerialName("timeAgo") + val timeAgo: String + ) + + @Serializable + data class GetCommentResponseList( + @SerialName("commentId") + val commentId: Long, + @SerialName("author") + val author: String, + @SerialName("content") + val content: String, + @SerialName("createdAt") + val createdAt: String, + @SerialName("authorLevel") + val authorLevel: Int, + @SerialName("authorId") + val authorId: Int, + ) + + fun toDetailFeed(): DetailFeed = DetailFeed( + feedId = getFeedResponseDto.feedId, + feedImage = getFeedResponseDto.feedImage, + feedMoney = getFeedResponseDto.feedMoney, + feedTitle = getFeedResponseDto.feedTitle, + isLiked = getFeedResponseDto.isLiked, + likes = getFeedResponseDto.likes, + nickName = getFeedResponseDto.nickName, + userId = getFeedResponseDto.userId, + writerLevel = getFeedResponseDto.writerLevel, + comments = getFeedResponseDto.comments, + timeAgo = getFeedResponseDto.timeAgo, + commentList = getCommentResponseList.map { list -> + CommentList( + commentId = list.commentId, + author = list.author, + content = list.content, + authorId = list.authorId, + authorLevel = list.authorLevel + ) + } + ) +} diff --git a/app/src/main/java/com/android/go/sopt/winey/domain/entity/DetailFeed.kt b/app/src/main/java/com/android/go/sopt/winey/domain/entity/DetailFeed.kt new file mode 100644 index 00000000..3006170a --- /dev/null +++ b/app/src/main/java/com/android/go/sopt/winey/domain/entity/DetailFeed.kt @@ -0,0 +1,26 @@ +package com.android.go.sopt.winey.domain.entity + +data class DetailFeed( + val feedId: Int, + val feedImage: String, + val feedMoney: Long, + val feedTitle: String, + var isLiked: Boolean, + var likes: Long, + val nickName: String, + val userId: Int, + val writerLevel: Int, + val comments: Long, + val timeAgo: String, + val commentList: List +) + +data class CommentList( + val commentId: Long, + val author: String, + val content: String, + val authorLevel: Int, + val authorId: Int +) + + From 09c29910e28304687e0cf95fdfe5e1a5f93d784b Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Sat, 19 Aug 2023 02:28:31 +0900 Subject: [PATCH 05/16] =?UTF-8?q?[add]=20#124=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20GET=20service,=20datasource=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/model/remote/response/ResponseGetFeedDetailDto.kt | 4 ++-- .../com/android/go/sopt/winey/data/service/FeedService.kt | 6 ++++++ .../com/android/go/sopt/winey/data/source/FeedDataSource.kt | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/android/go/sopt/winey/data/model/remote/response/ResponseGetFeedDetailDto.kt b/app/src/main/java/com/android/go/sopt/winey/data/model/remote/response/ResponseGetFeedDetailDto.kt index 879d106f..cb14ba3d 100644 --- a/app/src/main/java/com/android/go/sopt/winey/data/model/remote/response/ResponseGetFeedDetailDto.kt +++ b/app/src/main/java/com/android/go/sopt/winey/data/model/remote/response/ResponseGetFeedDetailDto.kt @@ -6,7 +6,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class ResponseGetDetailDto( +data class ResponseGetFeedDetailDto( @SerialName("getFeedResponseDto") val getFeedResponseDto: GetFeedResponseDto, @SerialName("getCommentResponseList") @@ -53,7 +53,7 @@ data class ResponseGetDetailDto( @SerialName("authorLevel") val authorLevel: Int, @SerialName("authorId") - val authorId: Int, + val authorId: Int ) fun toDetailFeed(): DetailFeed = DetailFeed( diff --git a/app/src/main/java/com/android/go/sopt/winey/data/service/FeedService.kt b/app/src/main/java/com/android/go/sopt/winey/data/service/FeedService.kt index 82b4c251..93d6ff64 100644 --- a/app/src/main/java/com/android/go/sopt/winey/data/service/FeedService.kt +++ b/app/src/main/java/com/android/go/sopt/winey/data/service/FeedService.kt @@ -1,6 +1,7 @@ package com.android.go.sopt.winey.data.service import com.android.go.sopt.winey.data.model.remote.request.RequestPostLikeDto +import com.android.go.sopt.winey.data.model.remote.response.ResponseGetFeedDetailDto import com.android.go.sopt.winey.data.model.remote.response.ResponseGetWineyFeedListDto import com.android.go.sopt.winey.data.model.remote.response.ResponsePostLikeDto import com.android.go.sopt.winey.data.model.remote.response.ResponsePostWineyFeedDto @@ -45,4 +46,9 @@ interface FeedService { @Part file: MultipartBody.Part?, @PartMap requestMap: HashMap ): BaseResponse + + @GET("feed/{feedId}") + suspend fun getFeedDetail( + @Path("feedId") feedId: Int + ): BaseResponse } diff --git a/app/src/main/java/com/android/go/sopt/winey/data/source/FeedDataSource.kt b/app/src/main/java/com/android/go/sopt/winey/data/source/FeedDataSource.kt index 5d9dd3e6..a67e3778 100644 --- a/app/src/main/java/com/android/go/sopt/winey/data/source/FeedDataSource.kt +++ b/app/src/main/java/com/android/go/sopt/winey/data/source/FeedDataSource.kt @@ -1,6 +1,7 @@ package com.android.go.sopt.winey.data.source import com.android.go.sopt.winey.data.model.remote.request.RequestPostLikeDto +import com.android.go.sopt.winey.data.model.remote.response.ResponseGetFeedDetailDto import com.android.go.sopt.winey.data.model.remote.response.ResponsePostLikeDto import com.android.go.sopt.winey.data.model.remote.response.ResponsePostWineyFeedDto import com.android.go.sopt.winey.data.model.remote.response.base.BaseResponse @@ -26,4 +27,9 @@ class FeedDataSource @Inject constructor( requestMap: HashMap ): BaseResponse = feedService.postWineyFeed(file, requestMap) + + suspend fun getFeedDetail( + feedId: Int + ): BaseResponse = + feedService.getFeedDetail(feedId) } From 50292580ed20d288a971600460dea6af66611bce Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Sat, 19 Aug 2023 02:29:21 +0900 Subject: [PATCH 06/16] =?UTF-8?q?[feat]=20#124=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20GET=20repository=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../go/sopt/winey/data/repository/FeedRepositoryImpl.kt | 6 ++++++ .../go/sopt/winey/domain/repository/FeedRepository.kt | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/app/src/main/java/com/android/go/sopt/winey/data/repository/FeedRepositoryImpl.kt b/app/src/main/java/com/android/go/sopt/winey/data/repository/FeedRepositoryImpl.kt index 59ebd625..1105170e 100644 --- a/app/src/main/java/com/android/go/sopt/winey/data/repository/FeedRepositoryImpl.kt +++ b/app/src/main/java/com/android/go/sopt/winey/data/repository/FeedRepositoryImpl.kt @@ -9,6 +9,7 @@ import com.android.go.sopt.winey.data.service.FeedService import com.android.go.sopt.winey.data.source.FeedDataSource import com.android.go.sopt.winey.data.source.paging.MyFeedPagingSource import com.android.go.sopt.winey.data.source.paging.WineyFeedPagingSource +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.entity.WineyFeed import com.android.go.sopt.winey.domain.repository.FeedRepository @@ -52,6 +53,11 @@ class FeedRepositoryImpl @Inject constructor( feedDataSource.postFeedLike(feedId, requestPostLikeDto).toLike() } + override suspend fun getFeedDetail(feedId: Int): Result = + runCatching { + feedDataSource.getFeedDetail(feedId).data?.toDetailFeed() + } + companion object { const val WINEYFEED_PAGE_SIZE = 20 const val MYFEED_PAGE_SIZE = 10 diff --git a/app/src/main/java/com/android/go/sopt/winey/domain/repository/FeedRepository.kt b/app/src/main/java/com/android/go/sopt/winey/domain/repository/FeedRepository.kt index ee9600ae..e999f92a 100644 --- a/app/src/main/java/com/android/go/sopt/winey/domain/repository/FeedRepository.kt +++ b/app/src/main/java/com/android/go/sopt/winey/domain/repository/FeedRepository.kt @@ -2,7 +2,9 @@ package com.android.go.sopt.winey.domain.repository import androidx.paging.PagingData import com.android.go.sopt.winey.data.model.remote.request.RequestPostLikeDto +import com.android.go.sopt.winey.data.model.remote.response.ResponseGetFeedDetailDto import com.android.go.sopt.winey.data.model.remote.response.ResponsePostWineyFeedDto +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.entity.WineyFeed import kotlinx.coroutines.flow.Flow @@ -22,4 +24,6 @@ interface FeedRepository { file: MultipartBody.Part?, requestMap: HashMap ): Result + + suspend fun getFeedDetail(feedId: Int): Result } From c01d44f421e3712d977d7983c79700125933dc26 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Sat, 19 Aug 2023 02:41:44 +0900 Subject: [PATCH 07/16] =?UTF-8?q?[mod]=20#124=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EB=AC=B8=EC=9E=90=EC=97=B4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feed/WineyFeedDeleteDialogFragment.kt | 83 ----------------- .../main/feed/WineyFeedFragment.kt | 15 +--- .../myfeed/MyFeedDeleteDialogFragment.kt | 83 ----------------- .../main/mypage/myfeed/MyFeedFragment.kt | 15 +--- .../layout/fragment_feed_delete_dialog.xml | 89 ------------------- app/src/main/res/values/strings.xml | 4 +- 6 files changed, 10 insertions(+), 279 deletions(-) delete mode 100644 app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedDeleteDialogFragment.kt delete mode 100644 app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedDeleteDialogFragment.kt delete mode 100644 app/src/main/res/layout/fragment_feed_delete_dialog.xml diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedDeleteDialogFragment.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedDeleteDialogFragment.kt deleted file mode 100644 index 6e5b1332..00000000 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedDeleteDialogFragment.kt +++ /dev/null @@ -1,83 +0,0 @@ -package com.android.go.sopt.winey.presentation.main.feed - -import android.os.Bundle -import android.view.View -import androidx.fragment.app.viewModels -import androidx.lifecycle.flowWithLifecycle -import com.android.go.sopt.winey.R -import com.android.go.sopt.winey.databinding.FragmentFeedDeleteDialogBinding -import com.android.go.sopt.winey.util.binding.BindingDialogFragment -import com.android.go.sopt.winey.util.fragment.snackBar -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 dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach -import timber.log.Timber - -@AndroidEntryPoint -class WineyFeedDeleteDialogFragment(private val feedId: Int, private val userLevel: Int) : - BindingDialogFragment(R.layout.fragment_feed_delete_dialog) { - lateinit var wineyFeedFragment: WineyFeedFragment - private val wineyFeedViewModel by viewModels() - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - initButtonClickListener() - initDeleteFeedStateObserver() - setDialogSubByLevel() - } - - private fun setDialogSubByLevel() { - binding.tvDialogSub.text.apply { - if (userLevel <= LV_KNIGHT) { - getString(R.string.myfeed_dialog_lowlevel_sub) - } else { - getString(R.string.myfeed_dialog_highlevel_sub) - } - } - } - - private fun initButtonClickListener() { - binding.btnDialogCancel.setOnClickListener { - this.dismiss() - } - binding.btnDialogDelete.setOnClickListener { - wineyFeedViewModel.deleteFeed(feedId) - initDeleteFeedStateObserver() - } - } - - private fun initDeleteFeedStateObserver() { - wineyFeedViewModel.deleteWineyFeedState.flowWithLifecycle(viewLifeCycle).onEach { state -> - when (state) { - is UiState.Success -> { - this.dismiss() - refreshWineyFeed() - snackBar(binding.root) { state.toString() } - } - - is UiState.Failure -> { - snackBar(binding.root) { state.msg } - } - - else -> Timber.tag("failure").e(MSG_MYFEED_ERROR) - } - }.launchIn(viewLifeCycleScope) - } - - private fun refreshWineyFeed() { - val fragmentManager = parentFragmentManager - fragmentManager.beginTransaction().apply { - wineyFeedFragment = WineyFeedFragment() - replace(R.id.fcv_main, wineyFeedFragment) - commit() - } - } - - companion object { - private const val MSG_MYFEED_ERROR = "ERROR" - private const val LV_KNIGHT = 2 - } -} 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 098741f5..59a06eac 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 @@ -95,7 +95,7 @@ class WineyFeedFragment : BindingFragment(R.layout.fra menuDelete.isVisible = false } menuDelete.setOnSingleClickListener { - showDeleteDialog(wineyFeed.feedId, wineyFeed.writerLevel) + showDeleteDialog(wineyFeed.feedId) popupWindow.dismiss() } popupWindow.showAsDropDown(view) @@ -109,17 +109,10 @@ class WineyFeedFragment : BindingFragment(R.layout.fra } } - private fun showDeleteDialog(feedId: Int, userLevel: Int) { - val dialogSub: Int = - if (userLevel <= LV_KNIGHT) { - R.string.myfeed_dialog_lowlevel_sub - } else { - R.string.myfeed_dialog_highlevel_sub - } - + private fun showDeleteDialog(feedId: Int) { val deleteDialog = AlertDialogFragment( - getString(R.string.wineyfeed_dialog_title), - getString(dialogSub), + getString(R.string.myfeed_dialog_title), + getString(R.string.myfeed_dialog_sub), getString(R.string.wineyfeed_dialog_cancel), getString(R.string.myfeed_dialog_delete), handleNegativeButton = { }, diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedDeleteDialogFragment.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedDeleteDialogFragment.kt deleted file mode 100644 index e115b443..00000000 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/mypage/myfeed/MyFeedDeleteDialogFragment.kt +++ /dev/null @@ -1,83 +0,0 @@ -package com.android.go.sopt.winey.presentation.main.mypage.myfeed - -import android.os.Bundle -import android.view.View -import androidx.fragment.app.viewModels -import androidx.lifecycle.flowWithLifecycle -import com.android.go.sopt.winey.R -import com.android.go.sopt.winey.databinding.FragmentFeedDeleteDialogBinding -import com.android.go.sopt.winey.util.binding.BindingDialogFragment -import com.android.go.sopt.winey.util.fragment.snackBar -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 dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach -import timber.log.Timber - -@AndroidEntryPoint -class MyFeedDeleteDialogFragment(private val feedId: Int, private val userLevel: Int) : - BindingDialogFragment(R.layout.fragment_feed_delete_dialog) { - lateinit var myFeedFragment: MyFeedFragment - private val myFeedViewModel by viewModels() - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - initButtonClickListener() - initDeleteFeedStateObserver() - setDialogSubByLevel() - } - - private fun setDialogSubByLevel() { - binding.tvDialogSub.text.apply { - if (userLevel <= LV_KNIGHT) { - getString(R.string.myfeed_dialog_lowlevel_sub) - } else { - getString(R.string.myfeed_dialog_highlevel_sub) - } - } - } - - private fun initButtonClickListener() { - binding.btnDialogCancel.setOnClickListener { - this.dismiss() - } - binding.btnDialogDelete.setOnClickListener { - myFeedViewModel.deleteFeed(feedId) - initDeleteFeedStateObserver() - } - } - - private fun initDeleteFeedStateObserver() { - myFeedViewModel.deleteMyFeedState.flowWithLifecycle(viewLifeCycle).onEach { state -> - when (state) { - is UiState.Success -> { - this.dismiss() - refreshMyFeed() - snackBar(binding.root) { state.toString() } - } - - is UiState.Failure -> { - snackBar(binding.root) { state.msg } - } - - else -> Timber.tag("failure").e(MSG_MYFEED_ERROR) - } - }.launchIn(viewLifeCycleScope) - } - - private fun refreshMyFeed() { - val fragmentManager = requireActivity().supportFragmentManager - fragmentManager.beginTransaction().apply { - myFeedFragment = MyFeedFragment() - replace(R.id.fcv_main, myFeedFragment) - commit() - } - } - - companion object { - private const val MSG_MYFEED_ERROR = "ERROR" - private const val LV_KNIGHT = 2 - } -} 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 0fdc3185..86a4a57b 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 @@ -71,23 +71,16 @@ class MyFeedFragment : BindingFragment(R.layout.fragment_ val menuReport = popupView.findViewById(R.id.tv_popup_report) menuReport.isVisible = false menuDelete.setOnSingleClickListener { - showDeleteDialog(wineyFeed.feedId, wineyFeed.writerLevel) + showDeleteDialog(wineyFeed.feedId) popupWindow.dismiss() } popupWindow.showAsDropDown(view) } - private fun showDeleteDialog(feedId: Int, userLevel: Int) { - val dialogSub: Int = - if (userLevel <= LV_KNIGHT) { - R.string.myfeed_dialog_lowlevel_sub - } else { - R.string.myfeed_dialog_highlevel_sub - } - + private fun showDeleteDialog(feedId: Int) { val deleteDialog = AlertDialogFragment( - getString(R.string.wineyfeed_dialog_title), - getString(dialogSub), + getString(R.string.myfeed_dialog_title), + getString(R.string.myfeed_dialog_sub), getString(R.string.wineyfeed_dialog_cancel), getString(R.string.myfeed_dialog_delete), handleNegativeButton = { }, diff --git a/app/src/main/res/layout/fragment_feed_delete_dialog.xml b/app/src/main/res/layout/fragment_feed_delete_dialog.xml deleted file mode 100644 index 8c4ffa76..00000000 --- a/app/src/main/res/layout/fragment_feed_delete_dialog.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 948f6f60..819fe55e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -89,8 +89,8 @@ 루이당 4세 오늘은 자네가 자주 타는\n대중교통비를 줄여보는 거 어떤가? 원 절약 - 진짜 게시물을 삭제하시겠어요? - 지금 게시물을 삭제하면\n누적 금액이 삭감되니 주의하세요! + 삭제하시겠습니까? + 삭제한 글은 다시 복구할 수 없습니다. 지금 게시물을 삭제하면 누적 금액이\n 삭감되어 레벨이 내려갈 수 있으니 주의하세요! 취소 삭제하기 From 37c4134fe5c23ce9ede0bdf955a8442cfba103a1 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Sat, 19 Aug 2023 05:03:09 +0900 Subject: [PATCH 08/16] =?UTF-8?q?[feat]=20#124=20=EC=9C=84=EB=8B=88?= =?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=EB=B6=88=EB=9F=AC=EC=98=A4=EA=B8=B0=20=EC=84=9C?= =?UTF-8?q?=EB=B2=84=ED=86=B5=EC=8B=A0=20=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 | 15 +++-- .../main/feed/WineyFeedFragment.kt | 14 ++++- .../main/feed/detail/DetailFragment.kt | 51 +++++++++++++++++ .../main/feed/detail/DetailViewModel.kt | 57 +++++++++++++++++++ 4 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt create mode 100644 app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt 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 d593604f..9860c1c6 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 @@ -14,7 +14,8 @@ 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 showPopupMenu: (View, WineyFeed) -> Unit, + private val toFeedDetail: (feedId:Int) -> Unit ) : PagingDataAdapter(diffUtil) { private val currentData: ItemSnapshotList @@ -23,7 +24,8 @@ class WineyFeedAdapter( class WineyFeedViewHolder( private val binding: ItemWineyfeedPostBinding, 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) -> Unit ) : RecyclerView.ViewHolder(binding.root) { fun onBind(data: WineyFeed?) { @@ -37,9 +39,14 @@ class WineyFeedAdapter( onLikeButtonClick(data.feedId, !data.isLiked) } - btnWineyfeedMore.setOnClickListener { view -> + btnWineyfeedMore.setOnSingleClickListener { view -> showPopupMenu(view, data) } + + lWineyfeedPost.setOnSingleClickListener { + toFeedDetail(data.feedId) + } + } } @@ -60,7 +67,7 @@ class WineyFeedAdapter( ): WineyFeedViewHolder { val binding = ItemWineyfeedPostBinding.inflate(LayoutInflater.from(parent.context), parent, false) - return WineyFeedViewHolder(binding, likeButtonClick, showPopupMenu) + return WineyFeedViewHolder(binding, likeButtonClick, showPopupMenu, toFeedDetail) } override fun onBindViewHolder(holder: WineyFeedViewHolder, position: Int) { 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 59a06eac..f1983e4c 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 @@ -1,5 +1,6 @@ package com.android.go.sopt.winey.presentation.main.feed +import android.app.Activity import android.content.Intent import android.os.Bundle import android.view.LayoutInflater @@ -9,6 +10,7 @@ import android.widget.PopupWindow import android.widget.TextView import androidx.core.view.isVisible import androidx.fragment.app.activityViewModels +import androidx.fragment.app.commit import androidx.fragment.app.viewModels import androidx.lifecycle.Lifecycle import androidx.lifecycle.flowWithLifecycle @@ -22,7 +24,10 @@ import com.android.go.sopt.winey.domain.entity.WineyFeed import com.android.go.sopt.winey.domain.repository.DataStoreRepository import com.android.go.sopt.winey.presentation.main.AlertDialogFragment import com.android.go.sopt.winey.presentation.main.MainViewModel +import com.android.go.sopt.winey.presentation.main.feed.detail.DetailFragment +import com.android.go.sopt.winey.presentation.main.feed.detail.DetailViewModel import com.android.go.sopt.winey.presentation.main.feed.upload.UploadActivity +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.snackBar import com.android.go.sopt.winey.util.fragment.viewLifeCycle @@ -70,7 +75,8 @@ class WineyFeedFragment : BindingFragment(R.layout.fra }, showPopupMenu = { view, wineyFeed -> showPopupMenu(view, wineyFeed) - } + }, + toFeedDetail = { feedId -> navigateDetail(feedId) } ) binding.rvWineyfeedPost.adapter = ConcatAdapter( wineyFeedHeaderAdapter, @@ -227,6 +233,12 @@ class WineyFeedFragment : BindingFragment(R.layout.fra startActivity(intent) } + private fun navigateDetail(feedId: Int) { + parentFragmentManager.commit { + replace(R.id.fcv_main, DetailFragment(feedId)) + } + } + companion object { private const val LV_KNIGHT = 2 private const val TAG_WINEYFEED_DIALOG = "NO_GOAL_DIALOG" diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt new file mode 100644 index 00000000..02640255 --- /dev/null +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt @@ -0,0 +1,51 @@ +package com.android.go.sopt.winey.presentation.main.feed.detail + +import android.os.Bundle +import android.util.Log +import android.view.View +import androidx.fragment.app.viewModels +import androidx.lifecycle.flowWithLifecycle +import com.android.go.sopt.winey.R +import com.android.go.sopt.winey.databinding.FragmentDetailBinding +import com.android.go.sopt.winey.util.binding.BindingFragment +import com.android.go.sopt.winey.util.fragment.snackBar +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 dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach +import timber.log.Timber + +@AndroidEntryPoint +class DetailFragment(feedId: Int) : + BindingFragment(R.layout.fragment_detail) { + val feedId = feedId + private val viewModel by viewModels() + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + viewModel.getFeedDetail(feedId) + initGetFeedDetailObserver() + Log.e("feedId", feedId.toString()) + } + + private fun initGetFeedDetailObserver() { + viewModel.getFeedDetailState.flowWithLifecycle(viewLifeCycle).onEach { state -> + when (state) { + is UiState.Success -> { + binding.data = state.data + } + + is UiState.Failure -> { + snackBar(binding.root) { state.msg } + } + + else -> Timber.tag("failure").e(MSG_DETAIL_ERROR) + } + }.launchIn(viewLifeCycleScope) + } + + companion object { + private const val MSG_DETAIL_ERROR = "ERROR" + } +} 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 new file mode 100644 index 00000000..59edce94 --- /dev/null +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailViewModel.kt @@ -0,0 +1,57 @@ +package com.android.go.sopt.winey.presentation.main.feed.detail + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import androidx.paging.PagingData +import androidx.paging.cachedIn +import com.android.go.sopt.winey.domain.entity.DetailFeed +import com.android.go.sopt.winey.domain.entity.WineyFeed +import com.android.go.sopt.winey.domain.repository.FeedRepository +import com.android.go.sopt.winey.util.view.UiState +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.launch +import retrofit2.HttpException +import timber.log.Timber +import javax.inject.Inject + +@HiltViewModel +class DetailViewModel @Inject constructor( + private val feedRepository: FeedRepository +) : ViewModel() { + private val _getFeedDetailState = + MutableStateFlow>(UiState.Loading) + val getFeedDetailState: StateFlow> = + _getFeedDetailState.asStateFlow() + + fun getFeedDetail(feedId: Int) { + viewModelScope.launch { + feedRepository.getFeedDetail(feedId) + .onSuccess { response -> + _getFeedDetailState.emit(UiState.Success(response)) + } + .onFailure { t -> handleFailureState(_getFeedDetailState, t) } + } + } + + private fun handleFailureState(loadingState: MutableStateFlow>, t: Throwable) { + if (t is HttpException) { + val errorMessage = when (t.code()) { + CODE_DETAIL_INVALID_USER_OR_FEED -> t.message() + CODE_DETAIL_INVALID_REQUEST -> t.message() + else -> t.message() + } + loadingState.value = UiState.Failure(errorMessage) + Timber.e("$MSG_DETAIL_FAIL : ${t.code()} : ${t.message()}") + } + } + + companion object { + private const val CODE_DETAIL_INVALID_USER_OR_FEED = 404 + private const val CODE_DETAIL_INVALID_REQUEST = 400 + private const val MSG_DETAIL_FAIL = "FAIL" + } +} From 33bc487795393516ce8f239074294b2108c56b56 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Sat, 19 Aug 2023 05:03:56 +0900 Subject: [PATCH 09/16] =?UTF-8?q?[mod]=20#124=20imageUrl=20String=3F?= =?UTF-8?q?=EB=8F=84=20=EB=B0=9B=EC=9D=84=20=EC=88=98=20=EC=9E=88=EA=B2=8C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../go/sopt/winey/util/binding/BindingAdapter.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/android/go/sopt/winey/util/binding/BindingAdapter.kt b/app/src/main/java/com/android/go/sopt/winey/util/binding/BindingAdapter.kt index a970dba6..519bbe6a 100644 --- a/app/src/main/java/com/android/go/sopt/winey/util/binding/BindingAdapter.kt +++ b/app/src/main/java/com/android/go/sopt/winey/util/binding/BindingAdapter.kt @@ -42,13 +42,15 @@ fun TextView.setFormattedNumber(amount: Long, prefix: String?, suffix: String?) } @BindingAdapter("imageUrl") -fun loadImager(view: ImageView, imageurl: String) { - view.load(imageurl) { - placeholder(R.drawable.img_wineyfeed_default) - transformations(RoundedCornersTransformation(10F)) +fun loadImager(view: ImageView, imageurl: String?) { + if (imageurl != null) { + val uri = Uri.parse(imageurl) + view.load(uri) { + placeholder(R.drawable.img_wineyfeed_default) + transformations(RoundedCornersTransformation(10F)) + } } } - @BindingAdapter("setImageUriWithCoil", "setDefaultDrawable") fun ImageView.setRoundedImage(imageUri: Uri?, drawable: Drawable) { if (imageUri == null) { From 0721362ae47b154b34c332b32f9996575808a7ac Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Sat, 19 Aug 2023 05:04:36 +0900 Subject: [PATCH 10/16] =?UTF-8?q?[feat]=20#124=20DetailFeed=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EB=B0=94=EC=9D=B8=EB=94=A9=ED=95=B4=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=ED=8E=98=EC=9D=B4=EC=A7=80=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 --- app/src/main/res/layout/fragment_detail.xml | 22 +++++++++++-------- .../main/res/layout/item_wineyfeed_post.xml | 1 + 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml index 75cda37c..afc79801 100644 --- a/app/src/main/res/layout/fragment_detail.xml +++ b/app/src/main/res/layout/fragment_detail.xml @@ -4,7 +4,9 @@ xmlns:tools="http://schemas.android.com/tools"> - + @@ -142,7 +146,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" - android:text="222" + likedAmount="@{data.likes}" android:textAppearance="@style/TextAppearance.WINEY.body_m_14" android:textColor="@color/gray_700" app:layout_constraintEnd_toEndOf="@id/iv_detail_like" @@ -156,7 +160,7 @@ android:layout_height="wrap_content" android:layout_marginTop="16dp" android:layout_marginEnd="5dp" - android:text="@string/wineyfeed_title" + android:text="@{data.feedTitle}" android:textAppearance="@style/TextAppearance.WINEY.body_b_16" android:textColor="@color/gray_900" app:layout_constraintEnd_toStartOf="@id/iv_detail_like" @@ -180,7 +184,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="4dp" - android:text="2" + android:text="@{String.valueOf(data.comments)}" android:textAppearance="@style/TextAppearance.WINEY.body_m_14" android:textColor="@color/gray_500" app:layout_constraintStart_toEndOf="@id/iv_detail_comment" @@ -203,7 +207,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="10dp" - android:text="5분 전" + android:text="@{data.timeAgo}" android:textAppearance="@style/TextAppearance.WINEY.body_m_14" android:textColor="@color/gray_500" app:layout_constraintStart_toEndOf="@id/iv_detail_seperator" diff --git a/app/src/main/res/layout/item_wineyfeed_post.xml b/app/src/main/res/layout/item_wineyfeed_post.xml index d57e657a..ddd2b3bf 100644 --- a/app/src/main/res/layout/item_wineyfeed_post.xml +++ b/app/src/main/res/layout/item_wineyfeed_post.xml @@ -11,6 +11,7 @@ From 3b17049942c438ba8df3ceb3d796a88aa5fd2e4d Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Sat, 19 Aug 2023 05:59:29 +0900 Subject: [PATCH 11/16] =?UTF-8?q?[feat]=20#124=20=EB=8C=93=EA=B8=80=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=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/CommentAdapter.kt | 41 +++++++++++++++++++ .../main/feed/detail/DetailFragment.kt | 14 +++++-- app/src/main/res/layout/fragment_detail.xml | 21 +++++++--- .../main/res/layout/item_detail_comment.xml | 14 ++++--- 4 files changed, 76 insertions(+), 14 deletions(-) create mode 100644 app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/CommentAdapter.kt diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/CommentAdapter.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/CommentAdapter.kt new file mode 100644 index 00000000..e65ff15d --- /dev/null +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/CommentAdapter.kt @@ -0,0 +1,41 @@ +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView +import com.android.go.sopt.winey.databinding.ItemDetailCommentBinding +import com.android.go.sopt.winey.domain.entity.CommentList +import com.android.go.sopt.winey.util.view.ItemDiffCallback + +class CommentAdapter() : ListAdapter(diffUtil) { + class CommentViewHolder( + private val binding: ItemDetailCommentBinding + ) : RecyclerView.ViewHolder(binding.root) { + fun onBind(data: CommentList) { + binding.apply { + this.data = data + executePendingBindings() + } + } + } + + + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int + ): CommentViewHolder { + val binding = + ItemDetailCommentBinding.inflate(LayoutInflater.from(parent.context), parent, false) + return CommentViewHolder(binding) + } + + override fun onBindViewHolder(holder: CommentViewHolder, position: Int) { + holder.onBind(getItem(position)) + } + + companion object { + private val diffUtil = ItemDiffCallback( + onItemsTheSame = { old, new -> old.commentId == new.commentId }, + onContentsTheSame = { old, new -> old == new } + ) + } +} diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt index 02640255..0af5362c 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt @@ -1,7 +1,7 @@ package com.android.go.sopt.winey.presentation.main.feed.detail +import CommentAdapter import android.os.Bundle -import android.util.Log import android.view.View import androidx.fragment.app.viewModels import androidx.lifecycle.flowWithLifecycle @@ -18,15 +18,20 @@ import kotlinx.coroutines.flow.onEach import timber.log.Timber @AndroidEntryPoint -class DetailFragment(feedId: Int) : +class DetailFragment(private val feedId: Int) : BindingFragment(R.layout.fragment_detail) { - val feedId = feedId + private lateinit var commentAdapter: CommentAdapter private val viewModel by viewModels() override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + initAdapter() viewModel.getFeedDetail(feedId) initGetFeedDetailObserver() - Log.e("feedId", feedId.toString()) + } + + private fun initAdapter() { + commentAdapter = CommentAdapter() + binding.rvDetailComment.adapter = commentAdapter } private fun initGetFeedDetailObserver() { @@ -34,6 +39,7 @@ class DetailFragment(feedId: Int) : when (state) { is UiState.Success -> { binding.data = state.data + commentAdapter.submitList(state.data?.commentList) } is UiState.Failure -> { diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml index afc79801..4488170e 100644 --- a/app/src/main/res/layout/fragment_detail.xml +++ b/app/src/main/res/layout/fragment_detail.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools"> + @@ -11,7 +12,7 @@ + android:layout_height="wrap_content"> + + diff --git a/app/src/main/res/layout/item_detail_comment.xml b/app/src/main/res/layout/item_detail_comment.xml index aef25be0..a6825eb1 100644 --- a/app/src/main/res/layout/item_detail_comment.xml +++ b/app/src/main/res/layout/item_detail_comment.xml @@ -3,7 +3,9 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> - + Date: Sat, 19 Aug 2023 06:47:32 +0900 Subject: [PATCH 12/16] =?UTF-8?q?[feat]=20#124=20=EB=8C=93=EA=B8=80=20?= =?UTF-8?q?=EB=A0=88=EB=B2=A8=EB=B3=84=20bindingAdapter=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/main/feed/WineyFeedAdapter.kt | 6 +++--- .../presentation/main/feed/WineyFeedFragment.kt | 11 ++++------- .../presentation/main/feed/detail/DetailFragment.kt | 13 ++++++++++++- .../go/sopt/winey/util/binding/BindingAdapter.kt | 13 +++++++++++++ app/src/main/res/layout/item_detail_comment.xml | 8 +++++--- app/src/main/res/values/strings.xml | 6 ++++++ 6 files changed, 43 insertions(+), 14 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 9860c1c6..af760b8a 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) -> Unit + private val toFeedDetail: (feedId: Int, writerLevel: Int) -> Unit ) : PagingDataAdapter(diffUtil) { private val currentData: ItemSnapshotList @@ -25,7 +25,7 @@ class WineyFeedAdapter( private val binding: ItemWineyfeedPostBinding, private val onLikeButtonClick: (feedId: Int, isLiked: Boolean) -> Unit, private val showPopupMenu: (View, WineyFeed) -> Unit, - private val toFeedDetail: (feedId:Int) -> Unit + private val toFeedDetail: (feedId: Int, writerLevel: Int) -> Unit ) : RecyclerView.ViewHolder(binding.root) { fun onBind(data: WineyFeed?) { @@ -44,7 +44,7 @@ class WineyFeedAdapter( } lWineyfeedPost.setOnSingleClickListener { - toFeedDetail(data.feedId) + toFeedDetail(data.feedId, data.writerLevel) } } 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 f1983e4c..20a96ded 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 @@ -1,6 +1,5 @@ package com.android.go.sopt.winey.presentation.main.feed -import android.app.Activity import android.content.Intent import android.os.Bundle import android.view.LayoutInflater @@ -25,9 +24,7 @@ import com.android.go.sopt.winey.domain.repository.DataStoreRepository import com.android.go.sopt.winey.presentation.main.AlertDialogFragment import com.android.go.sopt.winey.presentation.main.MainViewModel import com.android.go.sopt.winey.presentation.main.feed.detail.DetailFragment -import com.android.go.sopt.winey.presentation.main.feed.detail.DetailViewModel import com.android.go.sopt.winey.presentation.main.feed.upload.UploadActivity -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.snackBar import com.android.go.sopt.winey.util.fragment.viewLifeCycle @@ -76,7 +73,7 @@ class WineyFeedFragment : BindingFragment(R.layout.fra showPopupMenu = { view, wineyFeed -> showPopupMenu(view, wineyFeed) }, - toFeedDetail = { feedId -> navigateDetail(feedId) } + toFeedDetail = { feedId, writerLevel -> navigateDetail(feedId, writerLevel) } ) binding.rvWineyfeedPost.adapter = ConcatAdapter( wineyFeedHeaderAdapter, @@ -233,14 +230,14 @@ class WineyFeedFragment : BindingFragment(R.layout.fra startActivity(intent) } - private fun navigateDetail(feedId: Int) { + private fun navigateDetail(feedId: Int, writerLevel: Int) { parentFragmentManager.commit { - replace(R.id.fcv_main, DetailFragment(feedId)) + replace(R.id.fcv_main, DetailFragment(feedId, writerLevel)) + addToBackStack(null) } } companion object { - private const val LV_KNIGHT = 2 private const val TAG_WINEYFEED_DIALOG = "NO_GOAL_DIALOG" private const val MSG_WINEYFEED_ERROR = "ERROR" private const val TAG_DELETE_DIALOG = "DELETE_DIALOG" diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt index 0af5362c..c2db60e0 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt @@ -18,7 +18,7 @@ import kotlinx.coroutines.flow.onEach import timber.log.Timber @AndroidEntryPoint -class DetailFragment(private val feedId: Int) : +class DetailFragment(private val feedId: Int, private val writerLevel: Int) : BindingFragment(R.layout.fragment_detail) { private lateinit var commentAdapter: CommentAdapter private val viewModel by viewModels() @@ -32,6 +32,7 @@ class DetailFragment(private val feedId: Int) : private fun initAdapter() { commentAdapter = CommentAdapter() binding.rvDetailComment.adapter = commentAdapter + binding.ivDetailProfilephoto.setImageResource(setUserProfile(writerLevel)) } private fun initGetFeedDetailObserver() { @@ -51,6 +52,16 @@ class DetailFragment(private val feedId: Int) : }.launchIn(viewLifeCycleScope) } + private fun setUserProfile(userLevel: Int): Int { + return when (userLevel) { + 1 -> R.drawable.img_wineyfeed_profile_1 + 2 -> R.drawable.img_wineyfeed_profile_2 + 3 -> R.drawable.img_wineyfeed_profile_3 + 4 -> R.drawable.img_wineyfeed_profile_4 + else -> R.drawable.img_wineyfeed_profile + } + } + companion object { private const val MSG_DETAIL_ERROR = "ERROR" } diff --git a/app/src/main/java/com/android/go/sopt/winey/util/binding/BindingAdapter.kt b/app/src/main/java/com/android/go/sopt/winey/util/binding/BindingAdapter.kt index 519bbe6a..033f113c 100644 --- a/app/src/main/java/com/android/go/sopt/winey/util/binding/BindingAdapter.kt +++ b/app/src/main/java/com/android/go/sopt/winey/util/binding/BindingAdapter.kt @@ -51,6 +51,7 @@ fun loadImager(view: ImageView, imageurl: String?) { } } } + @BindingAdapter("setImageUriWithCoil", "setDefaultDrawable") fun ImageView.setRoundedImage(imageUri: Uri?, drawable: Drawable) { if (imageUri == null) { @@ -115,3 +116,15 @@ fun setLikeImage(view: ImageView, isLiked: Boolean) { } view.setImageResource(imageRes) } + +@BindingAdapter("setLevelText") +fun TextView.setLevelText(level: Int?) { + level?.let { + when (it) { + 1 -> text = resources.getString(R.string.comment_level_1) + 2 -> text = resources.getString(R.string.comment_level_2) + 3 -> text = resources.getString(R.string.comment_level_3) + 4 -> text = resources.getString(R.string.comment_level_4) + } + } +} diff --git a/app/src/main/res/layout/item_detail_comment.xml b/app/src/main/res/layout/item_detail_comment.xml index a6825eb1..b1e3a518 100644 --- a/app/src/main/res/layout/item_detail_comment.xml +++ b/app/src/main/res/layout/item_detail_comment.xml @@ -3,6 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> + @@ -14,11 +15,11 @@ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 819fe55e..1aa8c2c2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -151,4 +151,10 @@ 서브 메시지 입니다.\n서브 메시지 입니다. 버튼1 버튼2 + + + LV.평민 ㆍ + LV.기사 ㆍ + LV.귀족 ㆍ + LV.황제 ㆍ From 4350d92816b26035c8a3bedefe4a053ee392b391 Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Sat, 19 Aug 2023 07:03:09 +0900 Subject: [PATCH 13/16] =?UTF-8?q?[feat]=20#124=20=EB=92=A4=EB=A1=9C?= =?UTF-8?q?=EA=B0=80=EA=B8=B0,=20=EB=B0=B1=EC=8A=A4=ED=83=9D=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/android/go/sopt/winey/domain/entity/DetailFeed.kt | 2 -- .../go/sopt/winey/domain/repository/FeedRepository.kt | 1 - .../sopt/winey/presentation/main/feed/WineyFeedAdapter.kt | 1 - .../winey/presentation/main/feed/detail/CommentAdapter.kt | 1 - .../winey/presentation/main/feed/detail/DetailFragment.kt | 6 +++++- .../winey/presentation/main/feed/detail/DetailViewModel.kt | 4 ---- app/src/main/res/layout/fragment_detail.xml | 2 +- 7 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/android/go/sopt/winey/domain/entity/DetailFeed.kt b/app/src/main/java/com/android/go/sopt/winey/domain/entity/DetailFeed.kt index 3006170a..993d0e27 100644 --- a/app/src/main/java/com/android/go/sopt/winey/domain/entity/DetailFeed.kt +++ b/app/src/main/java/com/android/go/sopt/winey/domain/entity/DetailFeed.kt @@ -22,5 +22,3 @@ data class CommentList( val authorLevel: Int, val authorId: Int ) - - diff --git a/app/src/main/java/com/android/go/sopt/winey/domain/repository/FeedRepository.kt b/app/src/main/java/com/android/go/sopt/winey/domain/repository/FeedRepository.kt index e999f92a..890a1d18 100644 --- a/app/src/main/java/com/android/go/sopt/winey/domain/repository/FeedRepository.kt +++ b/app/src/main/java/com/android/go/sopt/winey/domain/repository/FeedRepository.kt @@ -2,7 +2,6 @@ package com.android.go.sopt.winey.domain.repository import androidx.paging.PagingData import com.android.go.sopt.winey.data.model.remote.request.RequestPostLikeDto -import com.android.go.sopt.winey.data.model.remote.response.ResponseGetFeedDetailDto import com.android.go.sopt.winey.data.model.remote.response.ResponsePostWineyFeedDto import com.android.go.sopt.winey.domain.entity.DetailFeed import com.android.go.sopt.winey.domain.entity.Like 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 af760b8a..78e7b47e 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 @@ -46,7 +46,6 @@ class WineyFeedAdapter( lWineyfeedPost.setOnSingleClickListener { toFeedDetail(data.feedId, data.writerLevel) } - } } diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/CommentAdapter.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/CommentAdapter.kt index e65ff15d..978ec736 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/CommentAdapter.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/CommentAdapter.kt @@ -18,7 +18,6 @@ class CommentAdapter() : ListAdapter() override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - initAdapter() viewModel.getFeedDetail(feedId) + initAdapter() initGetFeedDetailObserver() + binding.ivDetailBack.setOnSingleClickListener { + requireActivity().supportFragmentManager.popBackStack() + } } private fun initAdapter() { 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 59edce94..ef1318d3 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,17 +2,13 @@ package com.android.go.sopt.winey.presentation.main.feed.detail import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import androidx.paging.PagingData -import androidx.paging.cachedIn import com.android.go.sopt.winey.domain.entity.DetailFeed -import com.android.go.sopt.winey.domain.entity.WineyFeed import com.android.go.sopt.winey.domain.repository.FeedRepository import com.android.go.sopt.winey.util.view.UiState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch import retrofit2.HttpException import timber.log.Timber diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml index 4488170e..c12af6ba 100644 --- a/app/src/main/res/layout/fragment_detail.xml +++ b/app/src/main/res/layout/fragment_detail.xml @@ -23,7 +23,7 @@ app:layout_constraintTop_toTopOf="parent"> Date: Sat, 19 Aug 2023 11:37:49 +0900 Subject: [PATCH 14/16] =?UTF-8?q?[ui]=20#124=20=EB=8C=93=EA=B8=80=20?= =?UTF-8?q?=EC=97=86=EC=9D=84=EB=95=8C=20=EB=B7=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/res/drawable/img_comment_empty.xml | 123 +++++++++--------- app/src/main/res/layout/fragment_detail.xml | 53 +++++++- app/src/main/res/values/strings.xml | 1 + 3 files changed, 110 insertions(+), 67 deletions(-) diff --git a/app/src/main/res/drawable/img_comment_empty.xml b/app/src/main/res/drawable/img_comment_empty.xml index 54b23a92..2ce14cfa 100644 --- a/app/src/main/res/drawable/img_comment_empty.xml +++ b/app/src/main/res/drawable/img_comment_empty.xml @@ -1,177 +1,174 @@ + android:width="38dp" + android:height="37dp" + android:viewportWidth="38" + android:viewportHeight="37"> - diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml index c12af6ba..17599495 100644 --- a/app/src/main/res/layout/fragment_detail.xml +++ b/app/src/main/res/layout/fragment_detail.xml @@ -221,17 +221,62 @@ android:layout_marginTop="20dp" android:background="@color/gray_100" app:layout_constraintTop_toBottomOf="@id/tv_detail_createdAt" /> + + + + + + + + + + - - + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1aa8c2c2..c81510eb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -157,4 +157,5 @@ LV.기사 ㆍ LV.귀족 ㆍ LV.황제 ㆍ + 아직 댓글이 없어요 From 68301d01fb25898e120cb28acf3fc121c463e61e Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Sat, 19 Aug 2023 11:38:09 +0900 Subject: [PATCH 15/16] =?UTF-8?q?[feat]=20#124=20=EB=8C=93=EA=B8=80=20?= =?UTF-8?q?=EC=97=86=EC=9D=84=EB=95=8C=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/main/feed/detail/DetailFragment.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt index 057b3254..429caca2 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt @@ -3,6 +3,7 @@ package com.android.go.sopt.winey.presentation.main.feed.detail import CommentAdapter import android.os.Bundle import android.view.View +import androidx.core.view.isVisible import androidx.fragment.app.viewModels import androidx.lifecycle.flowWithLifecycle import com.android.go.sopt.winey.R @@ -43,10 +44,21 @@ class DetailFragment(private val feedId: Int, private val writerLevel: Int) : viewModel.getFeedDetailState.flowWithLifecycle(viewLifeCycle).onEach { state -> when (state) { is UiState.Success -> { + if (state.data?.commentList?.isEmpty() == true) { + binding.rvDetailComment.isVisible = false + binding.lCommentEmpty.isVisible = true + } else { + binding.rvDetailComment.isVisible = true + } binding.data = state.data commentAdapter.submitList(state.data?.commentList) } + is UiState.Loading -> { + binding.rvDetailComment.isVisible = false + binding.lCommentEmpty.isVisible = false + } + is UiState.Failure -> { snackBar(binding.root) { state.msg } } From d1d6574d4e555f8df421959e0b1210520ec1d91b Mon Sep 17 00:00:00 2001 From: HyeseonBaek Date: Sun, 20 Aug 2023 14:24:34 +0900 Subject: [PATCH 16/16] =?UTF-8?q?[mod]=20#124=20=EC=95=A1=ED=8B=B0?= =?UTF-8?q?=EB=B9=84=ED=8B=B0=20=EC=9C=84=20=ED=94=84=EB=9E=98=EA=B7=B8?= =?UTF-8?q?=EB=A8=BC=ED=8A=B8=20=EB=B0=A9=EC=8B=9D=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 4 ++ .../main/feed/WineyFeedFragment.kt | 21 +++++------ .../main/feed/detail/DetailActivity.kt | 37 +++++++++++++++++++ .../main/feed/detail/DetailFragment.kt | 19 +++++++++- .../main/mypage/myfeed/MyFeedFragment.kt | 1 - app/src/main/res/layout/activity_detail.xml | 26 +++++++++++++ 6 files changed, 94 insertions(+), 14 deletions(-) create mode 100644 app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt create mode 100644 app/src/main/res/layout/activity_detail.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7bfcf7c7..ce7649b7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -56,6 +56,10 @@ android:name=".presentation.main.feed.upload.loading.LoadingActivity" android:exported="false" android:screenOrientation="portrait" /> + (R.layout.fragment_winey_feed) { private val viewModel by viewModels() private val mainViewModel by activityViewModels() - private lateinit var wineyFeedDialogFragment: WineyFeedDialogFragment private lateinit var wineyFeedAdapter: WineyFeedAdapter private lateinit var wineyFeedHeaderAdapter: WineyFeedHeaderAdapter private lateinit var wineyFeedLoadAdapter: WineyFeedLoadAdapter @@ -76,7 +77,7 @@ class WineyFeedFragment : BindingFragment(R.layout.fra showPopupMenu = { view, wineyFeed -> showPopupMenu(view, wineyFeed) }, - toFeedDetail = { feedId, writerLevel -> navigateDetail(feedId, writerLevel) } + toFeedDetail = { feedId, writerLevel -> navigateToDetail(feedId, writerLevel) } ) binding.rvWineyfeedPost.adapter = ConcatAdapter( wineyFeedHeaderAdapter, @@ -253,17 +254,15 @@ class WineyFeedFragment : BindingFragment(R.layout.fra startActivity(intent) } - private fun navigateDetail(feedId: Int, writerLevel: Int) { - parentFragmentManager.commit { - replace(R.id.fcv_main, DetailFragment(feedId, writerLevel)) - addToBackStack(null) - } + private fun navigateToDetail(feedId: Int, writerLevel: Int) { + val intent = Intent(requireContext(), DetailActivity::class.java) + intent.putExtra("feedId", feedId) + intent.putExtra("writerLevel", writerLevel) + startActivity(intent) } companion object { - private const val TAG_WINEYFEED_DIALOG = "NO_GOAL_DIALOG" private const val MSG_WINEYFEED_ERROR = "ERROR" - private const val TAG_GOAL_DIALOG = "NO_GOAL_DIALOG" private const val TAG_DELETE_DIALOG = "DELETE_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 new file mode 100644 index 00000000..cf960d0e --- /dev/null +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailActivity.kt @@ -0,0 +1,37 @@ +package com.android.go.sopt.winey.presentation.main.feed.detail + +import android.os.Bundle +import androidx.fragment.app.commit +import com.android.go.sopt.winey.R +import com.android.go.sopt.winey.databinding.ActivityDetailBinding +import com.android.go.sopt.winey.util.binding.BindingActivity +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class DetailActivity : BindingActivity(R.layout.activity_detail) { + private lateinit var detailFragment: DetailFragment + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val feedId = intent.getIntExtra("feedId", 0) + val writerLevel = intent.getIntExtra("writerLevel", 0) + putArgsToDetail(feedId, writerLevel) + setDefaultFragment(savedInstanceState) + } + + private fun putArgsToDetail(feedId: Int, writerLevel: Int) { + detailFragment = DetailFragment() + detailFragment.arguments = Bundle().apply { + putInt("feedId", feedId) + putInt("writerLevel", writerLevel) + } + } + + private fun setDefaultFragment(savedInstanceState: Bundle?) { + if (savedInstanceState == null) { + supportFragmentManager.commit { + replace(R.id.fcv_detail, detailFragment) + } + } + } +} diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt index 429caca2..98ce3b1b 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/detail/DetailFragment.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.View import androidx.core.view.isVisible @@ -8,6 +9,7 @@ import androidx.fragment.app.viewModels import androidx.lifecycle.flowWithLifecycle import com.android.go.sopt.winey.R import com.android.go.sopt.winey.databinding.FragmentDetailBinding +import com.android.go.sopt.winey.presentation.main.MainActivity import com.android.go.sopt.winey.util.binding.BindingFragment import com.android.go.sopt.winey.util.fragment.snackBar import com.android.go.sopt.winey.util.fragment.viewLifeCycle @@ -20,17 +22,23 @@ import kotlinx.coroutines.flow.onEach import timber.log.Timber @AndroidEntryPoint -class DetailFragment(private val feedId: Int, private val writerLevel: Int) : +class DetailFragment() : BindingFragment(R.layout.fragment_detail) { + private var writerLevel: Int = 0 + private var feedId: Int = 0 private lateinit var commentAdapter: CommentAdapter private val viewModel by viewModels() override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + arguments?.let { + feedId = it.getInt("feedId", 0) + writerLevel = it.getInt("writerLevel", 0) + } viewModel.getFeedDetail(feedId) initAdapter() initGetFeedDetailObserver() binding.ivDetailBack.setOnSingleClickListener { - requireActivity().supportFragmentManager.popBackStack() + navigateToWineyFeed() } } @@ -78,6 +86,13 @@ class DetailFragment(private val feedId: Int, private val writerLevel: Int) : } } + private fun navigateToWineyFeed() { + val intent = Intent(requireContext(), MainActivity::class.java) + intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP + startActivity(intent) + requireActivity().finish() + } + companion object { private const val MSG_DETAIL_ERROR = "ERROR" } 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 976b66c2..a72bd29b 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 @@ -16,7 +16,6 @@ import androidx.lifecycle.repeatOnLifecycle 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.AlertDialogFragment import com.android.go.sopt.winey.presentation.main.feed.WineyFeedLoadAdapter import com.android.go.sopt.winey.presentation.main.mypage.MyPageFragment import com.android.go.sopt.winey.util.binding.BindingFragment diff --git a/app/src/main/res/layout/activity_detail.xml b/app/src/main/res/layout/activity_detail.xml new file mode 100644 index 00000000..1b4b12c5 --- /dev/null +++ b/app/src/main/res/layout/activity_detail.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + +