From b3efcb083208607c7733eca889252290cc35f131 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=ED=86=A0=EB=A7=88=EC=8A=A4?=
<123928686+ki960213@users.noreply.github.com>
Date: Fri, 1 Dec 2023 17:27:53 +0900
Subject: [PATCH] =?UTF-8?q?merge:=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?=
=?UTF-8?q?=EB=AA=A8=EB=8D=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81=20(#8?=
=?UTF-8?q?60)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Related to: #719
---
.../app/src/main/AndroidManifest.xml | 2 +-
.../com/emmsale/data/mapper/CommentMapper.kt | 38 +++++++++------
.../com/emmsale/data/mapper/MyPostMapper.kt | 22 ++++-----
.../emmsale/data/mapper/NotificationMapper.kt | 17 -------
.../data/mapper/RecruitmentStatusMapper.kt | 24 ----------
.../java/com/emmsale/data/model/Comment.kt | 19 ++++----
.../main/java/com/emmsale/data/model/Feed.kt | 18 +++----
.../java/com/emmsale/data/model/MyPost.kt | 11 -----
.../com/emmsale/data/model/Recruitment.kt | 2 +-
.../data/model/RecruitmentNotification.kt | 14 ------
.../emmsale/data/model/RecruitmentStatus.kt | 7 ---
.../concretes/DefaultMyPostRepository.kt | 25 ----------
.../DefaultNotificationRepository.kt | 21 ---------
.../concretes/DefaultRecruitmentRepository.kt | 6 +++
.../repository/interfaces/MyPostRepository.kt | 9 ----
.../interfaces/NotificationRepository.kt | 9 ----
.../interfaces/RecruitmentRepository.kt | 2 +
.../data/service/RecruitmentService.kt | 6 +++
.../di/modules/repository/RepositoryModule.kt | 8 ----
.../service/KerdyFirebaseMessagingService.kt | 2 +-
.../childCommentList/ChildCommentViewModel.kt | 2 +-
.../ui/feedDetail/FeedDetailActivity.kt | 4 +-
.../ui/feedDetail/FeedDetailViewModel.kt | 2 +-
.../ui/feedDetail/uiState/CommentUiState.kt | 4 +-
.../feedDetail/uiState/FeedDetailUiState.kt | 2 +-
.../myCommentList/uiState/MyCommentUiState.kt | 10 ++--
.../ui/myPostList/MyPostViewModel.kt | 43 -----------------
.../myPostList/recyclerView/MyPostAdapter.kt | 33 -------------
.../ui/myPostList/uiState/MyPostUiState.kt | 23 ---------
.../ui/myPostList/uiState/MyPostsUiState.kt | 19 --------
.../MyRecruitmentActivity.kt} | 22 ++++-----
.../MyRecruitmentViewModel.kt | 47 +++++++++++++++++++
.../recyclerView/MyRecruitmentAdapter.kt | 33 +++++++++++++
.../recyclerView/MyRecruitmentViewHolder.kt} | 18 +++----
.../uiState/MyRecruitmentUiState.kt | 23 +++++++++
.../uiState/MyRecruitmentsUiState.kt | 17 +++++++
.../ui/setting/SettingFragment.kt | 4 +-
.../src/main/res/layout/activity_my_post.xml | 6 +--
.../src/main/res/layout/item_all_comment.xml | 14 +++---
.../app/src/main/res/layout/item_my_post.xml | 10 ++--
40 files changed, 238 insertions(+), 360 deletions(-)
delete mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/RecruitmentStatusMapper.kt
delete mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/data/model/MyPost.kt
delete mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/data/model/RecruitmentNotification.kt
delete mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/data/model/RecruitmentStatus.kt
delete mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultMyPostRepository.kt
delete mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/interfaces/MyPostRepository.kt
delete mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/MyPostViewModel.kt
delete mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/recyclerView/MyPostAdapter.kt
delete mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/uiState/MyPostUiState.kt
delete mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/uiState/MyPostsUiState.kt
rename android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/{myPostList/MyPostActivity.kt => myRecruitmentList/MyRecruitmentActivity.kt} (74%)
create mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/MyRecruitmentViewModel.kt
create mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/recyclerView/MyRecruitmentAdapter.kt
rename android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/{myPostList/recyclerView/MyPostViewHolder.kt => myRecruitmentList/recyclerView/MyRecruitmentViewHolder.kt} (60%)
create mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/uiState/MyRecruitmentUiState.kt
create mode 100644 android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/uiState/MyRecruitmentsUiState.kt
diff --git a/android/2023-emmsale/app/src/main/AndroidManifest.xml b/android/2023-emmsale/app/src/main/AndroidManifest.xml
index 1e3c673e0..49605754d 100644
--- a/android/2023-emmsale/app/src/main/AndroidManifest.xml
+++ b/android/2023-emmsale/app/src/main/AndroidManifest.xml
@@ -38,7 +38,7 @@
-
+
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/CommentMapper.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/CommentMapper.kt
index 379872f3a..f2bf58d0b 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/CommentMapper.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/CommentMapper.kt
@@ -3,6 +3,8 @@ package com.emmsale.data.mapper
import com.emmsale.data.apiModel.response.CommentFamilyApiModel
import com.emmsale.data.apiModel.response.CommentResponse
import com.emmsale.data.model.Comment
+import com.emmsale.data.model.Feed
+import com.emmsale.data.model.Member
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
@@ -11,16 +13,20 @@ fun List.toData(): List = map(CommentFamilyApiMo
fun CommentFamilyApiModel.toData() = Comment(
id = parentComment.commentId,
- feedId = parentComment.feedId,
- feedTitle = parentComment.feedTitle,
- authorId = parentComment.memberId,
- authorName = parentComment.memberName,
- authorImageUrl = parentComment.memberImageUrl,
- parentId = parentComment.parentId,
+ feed = Feed(
+ id = parentComment.feedId,
+ title = parentComment.feedTitle,
+ ),
+ writer = Member(
+ id = parentComment.memberId,
+ name = parentComment.memberName,
+ profileImageUrl = parentComment.memberImageUrl,
+ ),
+ parentCommentId = parentComment.parentId,
content = parentComment.content,
createdAt = LocalDateTime.parse(parentComment.createdAt, dateTimeFormatter),
updatedAt = LocalDateTime.parse(parentComment.updatedAt, dateTimeFormatter),
- deleted = parentComment.deleted,
+ isDeleted = parentComment.deleted,
childComments = childComments.toData(),
)
@@ -29,16 +35,20 @@ fun List.toData(): List = map(CommentResponse::toData)
fun CommentResponse.toData() = Comment(
id = commentId,
- feedId = feedId,
- feedTitle = feedTitle,
- authorId = memberId,
- authorName = memberName,
- authorImageUrl = memberImageUrl,
- parentId = parentId,
+ feed = Feed(
+ id = feedId,
+ title = feedTitle,
+ ),
+ writer = Member(
+ id = memberId,
+ name = memberName,
+ profileImageUrl = memberImageUrl,
+ ),
+ parentCommentId = parentId,
content = content,
createdAt = LocalDateTime.parse(createdAt, dateTimeFormatter),
updatedAt = LocalDateTime.parse(updatedAt, dateTimeFormatter),
- deleted = deleted,
+ isDeleted = deleted,
childComments = listOf(),
)
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/MyPostMapper.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/MyPostMapper.kt
index 3eb9f45f8..6ef009ba4 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/MyPostMapper.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/MyPostMapper.kt
@@ -1,20 +1,20 @@
package com.emmsale.data.mapper
import com.emmsale.data.apiModel.response.MyPostResponse
-import com.emmsale.data.model.MyPost
+import com.emmsale.data.model.Event
+import com.emmsale.data.model.Member
+import com.emmsale.data.model.Recruitment
import java.time.LocalDate
import java.time.format.DateTimeFormatter
-fun List.toData(): List = map { it.toData() }
-fun MyPostResponse.toData(): MyPost {
- return MyPost(
- postId = postId,
- eventId = eventId,
- eventName = eventName,
- content = content,
- updatedAt = updatedAt.toLocalDate(),
- )
-}
+fun List.toData(): List = map { it.toData() }
+fun MyPostResponse.toData() = Recruitment(
+ id = postId,
+ writer = Member(),
+ event = Event(id = eventId, name = eventName),
+ content = content,
+ updatedDate = updatedAt.toLocalDate(),
+)
private fun String.toLocalDate(): LocalDate {
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/NotificationMapper.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/NotificationMapper.kt
index b2e42113a..ce510951b 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/NotificationMapper.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/NotificationMapper.kt
@@ -4,8 +4,6 @@ import com.emmsale.data.apiModel.response.CommentTypeNotificationResponse
import com.emmsale.data.apiModel.response.EventTypeNotificationResponse
import com.emmsale.data.apiModel.response.NotificationResponse
import com.emmsale.data.apiModel.response.NotificationResponse.NotificationType
-import com.emmsale.data.apiModel.response.RecruitmentNotificationResponse
-import com.emmsale.data.model.RecruitmentNotification
import com.emmsale.data.model.updatedNotification.ChildCommentNotification
import com.emmsale.data.model.updatedNotification.InterestEventNotification
import com.emmsale.data.model.updatedNotification.UpdatedNotification
@@ -55,18 +53,3 @@ private fun String.toLocalDateTime(): LocalDateTime {
val formatter = DateTimeFormatter.ofPattern("yyyy:MM:dd:HH:mm:ss")
return LocalDateTime.parse(this, formatter)
}
-
-fun RecruitmentNotificationResponse.toData(): RecruitmentNotification = RecruitmentNotification(
- id = id,
- senderUid = senderUid,
- receiverUid = receiverUid,
- message = message,
- eventId = eventId,
- status = status.toRecruitmentStatus(),
- isRead = isRead,
- notificationDate = createdAt.toLocalDateTime(),
-)
-
-@JvmName("RecruitmentNotificationResponse")
-fun List.toData(): List =
- map { it.toData() }
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/RecruitmentStatusMapper.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/RecruitmentStatusMapper.kt
deleted file mode 100644
index 4f8ea3b53..000000000
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/mapper/RecruitmentStatusMapper.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.emmsale.data.mapper
-
-import com.emmsale.data.apiModel.request.RecruitmentNotificationStatusUpdateRequest
-import com.emmsale.data.model.RecruitmentStatus
-
-private const val IN_PROGRESS = "IN_PROGRESS"
-private const val ACCEPT = "ACCEPTED"
-private const val REJECT = "REJECTED"
-private const val INVALID_STATUS_ERROR_MESSAGE = "올바르지 않은 상태입니다."
-
-fun String.toRecruitmentStatus(): RecruitmentStatus =
- when (this) {
- IN_PROGRESS -> RecruitmentStatus.PENDING
- ACCEPT -> RecruitmentStatus.ACCEPTED
- REJECT -> RecruitmentStatus.REJECTED
- else -> throw IllegalArgumentException(INVALID_STATUS_ERROR_MESSAGE)
- }
-
-fun RecruitmentStatus.toRequestModel(): RecruitmentNotificationStatusUpdateRequest =
- when (this) {
- RecruitmentStatus.PENDING -> RecruitmentNotificationStatusUpdateRequest(IN_PROGRESS)
- RecruitmentStatus.ACCEPTED -> RecruitmentNotificationStatusUpdateRequest(ACCEPT)
- RecruitmentStatus.REJECTED -> RecruitmentNotificationStatusUpdateRequest(REJECT)
- }
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Comment.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Comment.kt
index ea8538eb0..56cf16d67 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Comment.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Comment.kt
@@ -4,15 +4,12 @@ import java.time.LocalDateTime
data class Comment(
val id: Long,
- val feedId: Long,
- val feedTitle: String,
- val authorId: Long,
- val authorName: String,
- val authorImageUrl: String,
- val parentId: Long?,
- val content: String,
- val createdAt: LocalDateTime,
- val updatedAt: LocalDateTime,
- val deleted: Boolean,
- val childComments: List,
+ val feed: Feed = Feed(),
+ val writer: Member = Member(),
+ val parentCommentId: Long? = null,
+ val content: String = "",
+ val createdAt: LocalDateTime = LocalDateTime.MAX,
+ val updatedAt: LocalDateTime = LocalDateTime.MAX,
+ val isDeleted: Boolean = false,
+ val childComments: List = emptyList(),
)
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Feed.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Feed.kt
index 4aa08e9db..f0abf3b3b 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Feed.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Feed.kt
@@ -3,15 +3,15 @@ package com.emmsale.data.model
import java.time.LocalDateTime
data class Feed(
- val id: Long,
- val eventId: Long,
- val title: String,
- val content: String,
- val writer: Member,
- val imageUrls: List,
- val commentCount: Int,
- val createdAt: LocalDateTime,
- val updatedAt: LocalDateTime,
+ val id: Long = -1,
+ val eventId: Long = -1,
+ val title: String = "",
+ val content: String = "",
+ val writer: Member = Member(),
+ val imageUrls: List = emptyList(),
+ val commentCount: Int = 0,
+ val createdAt: LocalDateTime = LocalDateTime.MAX,
+ val updatedAt: LocalDateTime = LocalDateTime.MAX,
) {
val titleImageUrl = imageUrls.firstOrNull()
}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/MyPost.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/MyPost.kt
deleted file mode 100644
index 3e40874ad..000000000
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/MyPost.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.emmsale.data.model
-
-import java.time.LocalDate
-
-data class MyPost(
- val eventId: Long,
- val postId: Long,
- val eventName: String,
- val content: String? = null,
- val updatedAt: LocalDate? = null,
-)
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Recruitment.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Recruitment.kt
index de3f84e7a..4524df079 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Recruitment.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/Recruitment.kt
@@ -6,6 +6,6 @@ data class Recruitment(
val id: Long,
val writer: Member,
val event: Event,
- val content: String?,
+ val content: String,
val updatedDate: LocalDate,
)
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/RecruitmentNotification.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/RecruitmentNotification.kt
deleted file mode 100644
index df02e6db7..000000000
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/RecruitmentNotification.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.emmsale.data.model
-
-import java.time.LocalDateTime
-
-data class RecruitmentNotification(
- val id: Long,
- val senderUid: Long,
- val receiverUid: Long,
- val message: String,
- val eventId: Long,
- val status: RecruitmentStatus,
- val isRead: Boolean,
- val notificationDate: LocalDateTime,
-)
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/RecruitmentStatus.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/RecruitmentStatus.kt
deleted file mode 100644
index 9120ebd25..000000000
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/model/RecruitmentStatus.kt
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.emmsale.data.model
-
-enum class RecruitmentStatus {
- PENDING,
- ACCEPTED,
- REJECTED,
-}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultMyPostRepository.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultMyPostRepository.kt
deleted file mode 100644
index ce352ab59..000000000
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultMyPostRepository.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.emmsale.data.repository.concretes
-
-import com.emmsale.data.apiModel.response.MyPostResponse
-import com.emmsale.data.common.retrofit.callAdapter.ApiResponse
-import com.emmsale.data.mapper.toData
-import com.emmsale.data.model.MyPost
-import com.emmsale.data.repository.interfaces.MyPostRepository
-import com.emmsale.data.repository.interfaces.TokenRepository
-import com.emmsale.data.service.MyPostService
-import javax.inject.Inject
-
-class DefaultMyPostRepository @Inject constructor(
- private val myPostService: MyPostService,
- tokenRepository: TokenRepository,
-) : MyPostRepository {
- private val myUid = requireNotNull(tokenRepository.getMyUid()) {
- "[ERROR] 로그인되지 않은 사용자입니다."
- }
-
- override suspend fun getMyPosts(): ApiResponse> {
- return myPostService
- .getMyPosts(myUid)
- .map(List::toData)
- }
-}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultNotificationRepository.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultNotificationRepository.kt
index 576eb4765..ef055336d 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultNotificationRepository.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultNotificationRepository.kt
@@ -3,12 +3,8 @@ package com.emmsale.data.repository.concretes
import com.emmsale.data.apiModel.request.NotificationListDeleteRequest
import com.emmsale.data.apiModel.request.RecruitmentNotificationReportCreateRequest
import com.emmsale.data.apiModel.response.NotificationResponse
-import com.emmsale.data.apiModel.response.RecruitmentNotificationResponse
import com.emmsale.data.common.retrofit.callAdapter.ApiResponse
import com.emmsale.data.mapper.toData
-import com.emmsale.data.mapper.toRequestModel
-import com.emmsale.data.model.RecruitmentNotification
-import com.emmsale.data.model.RecruitmentStatus
import com.emmsale.data.model.updatedNotification.UpdatedNotification
import com.emmsale.data.repository.interfaces.NotificationRepository
import com.emmsale.data.service.NotificationService
@@ -21,23 +17,6 @@ class DefaultNotificationRepository @Inject constructor(
@IoDispatcher private val dispatcher: CoroutineDispatcher,
private val notificationService: NotificationService,
) : NotificationRepository {
- override suspend fun getRecruitmentNotifications(
- memberId: Long,
- ): ApiResponse> = withContext(dispatcher) {
- notificationService
- .getRecruitmentNotifications(memberId)
- .map(List::toData)
- }
-
- override suspend fun updateRecruitmentStatus(
- notificationId: Long,
- recruitmentStatus: RecruitmentStatus,
- ): ApiResponse = withContext(dispatcher) {
- notificationService.updateRecruitmentStatus(
- notificationId = notificationId,
- newStatus = recruitmentStatus.toRequestModel(),
- )
- }
override suspend fun updateNotificationReadStatus(
notificationId: Long,
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultRecruitmentRepository.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultRecruitmentRepository.kt
index 6a39475f0..c89466b66 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultRecruitmentRepository.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultRecruitmentRepository.kt
@@ -39,6 +39,12 @@ class DefaultRecruitmentRepository @Inject constructor(
.getRecruitment(eventId, recruitmentId)
.map(RecruitmentResponse::toData)
+ override suspend fun getMemberRecruitments(
+ memberId: Long,
+ ): ApiResponse> = recruitmentService
+ .getMemberRecruitments(memberId)
+ .map { it.toData() }
+
override suspend fun postRecruitment(
eventId: Long,
content: String,
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/interfaces/MyPostRepository.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/interfaces/MyPostRepository.kt
deleted file mode 100644
index 7e3764852..000000000
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/interfaces/MyPostRepository.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.emmsale.data.repository.interfaces
-
-import com.emmsale.data.common.retrofit.callAdapter.ApiResponse
-import com.emmsale.data.model.MyPost
-
-interface MyPostRepository {
-
- suspend fun getMyPosts(): ApiResponse>
-}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/interfaces/NotificationRepository.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/interfaces/NotificationRepository.kt
index 24e547db2..5d0b92829 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/interfaces/NotificationRepository.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/interfaces/NotificationRepository.kt
@@ -1,19 +1,10 @@
package com.emmsale.data.repository.interfaces
import com.emmsale.data.common.retrofit.callAdapter.ApiResponse
-import com.emmsale.data.model.RecruitmentNotification
-import com.emmsale.data.model.RecruitmentStatus
import com.emmsale.data.model.updatedNotification.UpdatedNotification
interface NotificationRepository {
- suspend fun getRecruitmentNotifications(memberId: Long): ApiResponse>
-
- suspend fun updateRecruitmentStatus(
- notificationId: Long,
- recruitmentStatus: RecruitmentStatus,
- ): ApiResponse
-
suspend fun updateNotificationReadStatus(notificationId: Long): ApiResponse
suspend fun getUpdatedNotifications(memberId: Long): ApiResponse>
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/interfaces/RecruitmentRepository.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/interfaces/RecruitmentRepository.kt
index 8078d1475..2bf1348ad 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/interfaces/RecruitmentRepository.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/interfaces/RecruitmentRepository.kt
@@ -9,6 +9,8 @@ interface RecruitmentRepository {
eventId: Long,
): ApiResponse>
+ suspend fun getMemberRecruitments(memberId: Long): ApiResponse>
+
suspend fun getEventRecruitment(
eventId: Long,
recruitmentId: Long,
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/service/RecruitmentService.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/service/RecruitmentService.kt
index acf03378e..141304f5c 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/service/RecruitmentService.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/service/RecruitmentService.kt
@@ -3,6 +3,7 @@ package com.emmsale.data.service
import com.emmsale.data.apiModel.request.RecruitmentCreateRequest
import com.emmsale.data.apiModel.request.RecruitmentDeleteRequest
import com.emmsale.data.apiModel.request.RecruitmentReportCreateRequest
+import com.emmsale.data.apiModel.response.MyPostResponse
import com.emmsale.data.apiModel.response.RecruitmentReportResponse
import com.emmsale.data.apiModel.response.RecruitmentResponse
import com.emmsale.data.common.retrofit.callAdapter.ApiResponse
@@ -27,6 +28,11 @@ interface RecruitmentService {
@Path("recruitment-post-id") recruitmentId: Long,
): ApiResponse
+ @GET("/events/recruitment-posts")
+ suspend fun getMemberRecruitments(
+ @Query("member-id") memberId: Long,
+ ): ApiResponse>
+
@POST("/events/{eventId}/recruitment-posts")
suspend fun postRecruitment(
@Path("eventId") eventId: Long,
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/di/modules/repository/RepositoryModule.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/di/modules/repository/RepositoryModule.kt
index e93089335..01f2f9905 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/di/modules/repository/RepositoryModule.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/di/modules/repository/RepositoryModule.kt
@@ -14,7 +14,6 @@ import com.emmsale.data.repository.concretes.DefaultFeedRepository
import com.emmsale.data.repository.concretes.DefaultLoginRepository
import com.emmsale.data.repository.concretes.DefaultMemberRepository
import com.emmsale.data.repository.concretes.DefaultMessageRoomRepository
-import com.emmsale.data.repository.concretes.DefaultMyPostRepository
import com.emmsale.data.repository.concretes.DefaultNotificationRepository
import com.emmsale.data.repository.concretes.DefaultRecruitmentRepository
import com.emmsale.data.repository.concretes.DefaultTokenRepository
@@ -32,7 +31,6 @@ import com.emmsale.data.repository.interfaces.FeedRepository
import com.emmsale.data.repository.interfaces.LoginRepository
import com.emmsale.data.repository.interfaces.MemberRepository
import com.emmsale.data.repository.interfaces.MessageRoomRepository
-import com.emmsale.data.repository.interfaces.MyPostRepository
import com.emmsale.data.repository.interfaces.NotificationRepository
import com.emmsale.data.repository.interfaces.RecruitmentRepository
import com.emmsale.data.repository.interfaces.TokenRepository
@@ -140,12 +138,6 @@ abstract class RepositoryModule {
impl: DefaultConfigRepository,
): ConfigRepository
- @Binds
- @Singleton
- abstract fun bindMyPostRepository(
- impl: DefaultMyPostRepository,
- ): MyPostRepository
-
@Binds
@Singleton
abstract fun bindMessageRoomRepository(
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/service/KerdyFirebaseMessagingService.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/service/KerdyFirebaseMessagingService.kt
index 4d44ce6d5..9854b1f17 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/service/KerdyFirebaseMessagingService.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/service/KerdyFirebaseMessagingService.kt
@@ -113,7 +113,7 @@ class KerdyFirebaseMessagingService : FirebaseMessagingService() {
return runBlocking {
when (val result = commentRepository.getComment(commentId)) {
is Failure, NetworkError -> ERROR_FEED_ID to ERROR_FEED_ID
- is Success -> result.data.feedId to result.data.id
+ is Success -> result.data.feed.id to result.data.id
is Unexpected -> throw Throwable(result.error)
}
}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/childCommentList/ChildCommentViewModel.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/childCommentList/ChildCommentViewModel.kt
index 8bcf1af65..6ad070d11 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/childCommentList/ChildCommentViewModel.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/childCommentList/ChildCommentViewModel.kt
@@ -151,7 +151,7 @@ class ChildCommentViewModel @Inject constructor(
_screenUiState.value = ScreenUiState.LOADING
}
val authorId =
- _comments.value.comments.find { it.comment.id == commentId }!!.comment.authorId
+ _comments.value.comments.find { it.comment.id == commentId }!!.comment.writer.id
when (val result = commentRepository.reportComment(commentId, authorId, uid)) {
is Failure -> {
if (result.code == REPORT_DUPLICATE_ERROR_CODE) {
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/FeedDetailActivity.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/FeedDetailActivity.kt
index ddde7a25b..bcde2d704 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/FeedDetailActivity.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/FeedDetailActivity.kt
@@ -47,8 +47,8 @@ class FeedDetailActivity : AppCompatActivity() {
onCommentClick = { comment ->
ChildCommentActivity.startActivity(
context = this,
- feedId = comment.feedId,
- parentCommentId = comment.parentId ?: comment.id,
+ feedId = comment.feed.id,
+ parentCommentId = comment.parentCommentId ?: comment.id,
highlightCommentId = comment.id,
)
},
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/FeedDetailViewModel.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/FeedDetailViewModel.kt
index ceacb7b75..78290d29d 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/FeedDetailViewModel.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/FeedDetailViewModel.kt
@@ -218,7 +218,7 @@ class FeedDetailViewModel @Inject constructor(
viewModelScope.launch {
_feedDetail.value = _feedDetail.value.copy(fetchResult = FetchResult.LOADING)
val authorId =
- _feedDetail.value.comments.find { it.comment.id == commentId }?.comment?.authorId
+ _feedDetail.value.comments.find { it.comment.id == commentId }?.comment?.writer?.id
?: return@launch
when (val result = commentRepository.reportComment(commentId, authorId, uid)) {
is Failure -> {
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/uiState/CommentUiState.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/uiState/CommentUiState.kt
index 7d3b973a5..2c29cd898 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/uiState/CommentUiState.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/uiState/CommentUiState.kt
@@ -9,7 +9,7 @@ data class CommentUiState(
) {
val isUpdated: Boolean = comment.createdAt != comment.updatedAt
- val childCommentsCount = comment.childComments.count { !it.deleted }
+ val childCommentsCount = comment.childComments.count { !it.isDeleted }
fun highlight() = copy(isHighlight = true)
@@ -18,7 +18,7 @@ data class CommentUiState(
companion object {
fun create(uid: Long, comment: Comment, isHighlight: Boolean = false): CommentUiState =
CommentUiState(
- isWrittenByLoginUser = uid == comment.authorId,
+ isWrittenByLoginUser = uid == comment.writer.id,
isHighlight = isHighlight,
comment = comment,
)
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/uiState/FeedDetailUiState.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/uiState/FeedDetailUiState.kt
index 8c9269128..9f152d6cf 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/uiState/FeedDetailUiState.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/feedDetail/uiState/FeedDetailUiState.kt
@@ -14,7 +14,7 @@ data class FeedDetailUiState(
val isUpdated: Boolean = feedDetail.createdAt != feedDetail.updatedAt
- val commentsCount: Int = comments.count { !it.comment.deleted }
+ val commentsCount: Int = comments.count { !it.comment.isDeleted }
fun highlightComment(commentId: Long) = copy(
comments = comments.map { if (it.comment.id == commentId) it.highlight() else it },
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myCommentList/uiState/MyCommentUiState.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myCommentList/uiState/MyCommentUiState.kt
index d30db4c89..f3da018af 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myCommentList/uiState/MyCommentUiState.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myCommentList/uiState/MyCommentUiState.kt
@@ -20,15 +20,15 @@ data class MyCommentUiState(
fun from(comment: Comment) = MyCommentUiState(
id = comment.id,
- feedId = comment.feedId,
- feedTitle = comment.feedTitle,
- authorId = comment.authorId,
- parentId = comment.parentId,
+ feedId = comment.feed.id,
+ feedTitle = comment.feed.title,
+ authorId = comment.writer.id,
+ parentId = comment.parentCommentId,
content = comment.content,
childCount = comment.childComments.size,
lastModifiedDate = comment.updatedAt.format(dateTimeFormatter),
isUpdated = comment.createdAt != comment.updatedAt,
- isDeleted = comment.deleted,
+ isDeleted = comment.isDeleted,
)
}
}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/MyPostViewModel.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/MyPostViewModel.kt
deleted file mode 100644
index 72935d0dc..000000000
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/MyPostViewModel.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.emmsale.presentation.ui.myPostList
-
-import androidx.lifecycle.ViewModel
-import androidx.lifecycle.viewModelScope
-import com.emmsale.data.common.retrofit.callAdapter.Failure
-import com.emmsale.data.common.retrofit.callAdapter.NetworkError
-import com.emmsale.data.common.retrofit.callAdapter.Success
-import com.emmsale.data.common.retrofit.callAdapter.Unexpected
-import com.emmsale.data.repository.interfaces.MyPostRepository
-import com.emmsale.presentation.common.livedata.NotNullLiveData
-import com.emmsale.presentation.common.livedata.NotNullMutableLiveData
-import com.emmsale.presentation.common.viewModel.Refreshable
-import com.emmsale.presentation.ui.myPostList.uiState.MyPostsUiState
-import dagger.hilt.android.lifecycle.HiltViewModel
-import kotlinx.coroutines.launch
-import javax.inject.Inject
-
-@HiltViewModel
-class MyPostViewModel @Inject constructor(
- private val myPostRepository: MyPostRepository,
-) : ViewModel(), Refreshable {
- private val _myPosts: NotNullMutableLiveData =
- NotNullMutableLiveData(MyPostsUiState())
- val myPosts: NotNullLiveData = _myPosts
-
- init {
- refresh()
- }
-
- override fun refresh() {
- _myPosts.value = _myPosts.value.copy(isLoading = true)
- viewModelScope.launch {
- when (val result = myPostRepository.getMyPosts()) {
- is Failure, NetworkError ->
- _myPosts.value =
- _myPosts.value.copy(isLoading = false, isError = true)
-
- is Success -> _myPosts.value = MyPostsUiState.from(result.data)
- is Unexpected -> throw Throwable(result.error)
- }
- }
- }
-}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/recyclerView/MyPostAdapter.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/recyclerView/MyPostAdapter.kt
deleted file mode 100644
index 182fdeaaf..000000000
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/recyclerView/MyPostAdapter.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.emmsale.presentation.ui.myPostList.recyclerView
-
-import android.view.ViewGroup
-import androidx.recyclerview.widget.DiffUtil
-import androidx.recyclerview.widget.ListAdapter
-import com.emmsale.presentation.ui.myPostList.uiState.MyPostUiState
-
-class MyPostAdapter(
- private val navigateToDetail: (eventId: Long, recruitmentId: Long) -> Unit,
-) : ListAdapter(diffUtil) {
-
- override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyPostViewHolder {
- return MyPostViewHolder.create(parent, navigateToDetail)
- }
-
- override fun onBindViewHolder(holder: MyPostViewHolder, position: Int) {
- holder.bind(getItem(position))
- }
-
- companion object {
- val diffUtil = object : DiffUtil.ItemCallback() {
- override fun areItemsTheSame(
- oldItem: MyPostUiState,
- newItem: MyPostUiState,
- ): Boolean = oldItem == newItem
-
- override fun areContentsTheSame(
- oldItem: MyPostUiState,
- newItem: MyPostUiState,
- ): Boolean = (oldItem.postId == newItem.postId && oldItem.eventId == newItem.eventId)
- }
- }
-}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/uiState/MyPostUiState.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/uiState/MyPostUiState.kt
deleted file mode 100644
index c2a51132b..000000000
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/uiState/MyPostUiState.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.emmsale.presentation.ui.myPostList.uiState
-
-import com.emmsale.data.model.MyPost
-
-data class MyPostUiState(
- val postId: Long = DEFAULT_ID,
- val eventId: Long = DEFAULT_ID,
- val eventName: String = "",
- val content: String = "",
- val updatedAt: String = "",
-) {
- companion object {
- private const val DEFAULT_ID = -1L
-
- fun from(myPost: MyPost): MyPostUiState = MyPostUiState(
- postId = myPost.postId,
- eventId = myPost.eventId,
- eventName = myPost.eventName,
- content = myPost.content ?: "",
- updatedAt = myPost.updatedAt.toString(),
- )
- }
-}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/uiState/MyPostsUiState.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/uiState/MyPostsUiState.kt
deleted file mode 100644
index 267262e21..000000000
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/uiState/MyPostsUiState.kt
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.emmsale.presentation.ui.myPostList.uiState
-
-import com.emmsale.data.model.MyPost
-
-data class MyPostsUiState(
- val list: List = listOf(),
- val isLoading: Boolean = false,
- val isError: Boolean = false,
-) {
- companion object {
- fun from(myPosts: List): MyPostsUiState {
- return MyPostsUiState(
- myPosts.map { MyPostUiState.from(it) },
- isLoading = false,
- isError = false,
- )
- }
- }
-}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/MyPostActivity.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/MyRecruitmentActivity.kt
similarity index 74%
rename from android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/MyPostActivity.kt
rename to android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/MyRecruitmentActivity.kt
index 0a34130c2..f1603a2af 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/MyPostActivity.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/MyRecruitmentActivity.kt
@@ -1,4 +1,4 @@
-package com.emmsale.presentation.ui.myPostList
+package com.emmsale.presentation.ui.myRecruitmentList
import android.content.Context
import android.content.Intent
@@ -10,17 +10,17 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.emmsale.R
import com.emmsale.databinding.ActivityMyPostBinding
import com.emmsale.presentation.common.extension.showToast
-import com.emmsale.presentation.ui.myPostList.recyclerView.MyPostAdapter
+import com.emmsale.presentation.ui.myRecruitmentList.recyclerView.MyRecruitmentAdapter
import com.emmsale.presentation.ui.recruitmentDetail.RecruitmentPostDetailActivity
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
-class MyPostActivity : AppCompatActivity() {
+class MyRecruitmentActivity : AppCompatActivity() {
private val binding by lazy { ActivityMyPostBinding.inflate(layoutInflater) }
- private val viewModel: MyPostViewModel by viewModels()
+ private val viewModel: MyRecruitmentViewModel by viewModels()
- private val myPostAdapter: MyPostAdapter by lazy {
- MyPostAdapter(navigateToDetail = ::navigateToDetail)
+ private val myRecruitmentAdapter: MyRecruitmentAdapter by lazy {
+ MyRecruitmentAdapter(navigateToDetail = ::navigateToDetail)
}
private val fetchByResultActivityLauncher =
@@ -40,18 +40,18 @@ class MyPostActivity : AppCompatActivity() {
}
private fun setUpMyPosts() {
- viewModel.myPosts.observe(this) { myPosts ->
- if (myPosts.isError) {
+ viewModel.myRecruitments.observe(this) { myRecruitments ->
+ if (myRecruitments.isError) {
showToast(R.string.all_data_loading_failed_message)
} else {
- myPostAdapter.submitList(myPosts.list)
+ myRecruitmentAdapter.submitList(myRecruitments.list)
}
}
}
private fun initRecyclerView() {
binding.rvMyPost.layoutManager = LinearLayoutManager(this)
- binding.rvMyPost.adapter = myPostAdapter
+ binding.rvMyPost.adapter = myRecruitmentAdapter
}
private fun navigateToDetail(eventId: Long, recruitmentId: Long) {
@@ -72,7 +72,7 @@ class MyPostActivity : AppCompatActivity() {
companion object {
fun startActivity(context: Context) {
- val intent = Intent(context, MyPostActivity::class.java)
+ val intent = Intent(context, MyRecruitmentActivity::class.java)
context.startActivity(intent)
}
}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/MyRecruitmentViewModel.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/MyRecruitmentViewModel.kt
new file mode 100644
index 000000000..3c6f0521c
--- /dev/null
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/MyRecruitmentViewModel.kt
@@ -0,0 +1,47 @@
+package com.emmsale.presentation.ui.myRecruitmentList
+
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import com.emmsale.data.common.retrofit.callAdapter.Failure
+import com.emmsale.data.common.retrofit.callAdapter.NetworkError
+import com.emmsale.data.common.retrofit.callAdapter.Success
+import com.emmsale.data.common.retrofit.callAdapter.Unexpected
+import com.emmsale.data.repository.interfaces.RecruitmentRepository
+import com.emmsale.data.repository.interfaces.TokenRepository
+import com.emmsale.presentation.common.livedata.NotNullLiveData
+import com.emmsale.presentation.common.livedata.NotNullMutableLiveData
+import com.emmsale.presentation.common.viewModel.Refreshable
+import com.emmsale.presentation.ui.myRecruitmentList.uiState.MyRecruitmentsUiState
+import dagger.hilt.android.lifecycle.HiltViewModel
+import kotlinx.coroutines.launch
+import javax.inject.Inject
+
+@HiltViewModel
+class MyRecruitmentViewModel @Inject constructor(
+ private val tokenRepository: TokenRepository,
+ private val recruitmentRepository: RecruitmentRepository,
+) : ViewModel(), Refreshable {
+ private val uid: Long by lazy { tokenRepository.getMyUid()!! }
+
+ private val _myRecruitments: NotNullMutableLiveData =
+ NotNullMutableLiveData(MyRecruitmentsUiState())
+ val myRecruitments: NotNullLiveData = _myRecruitments
+
+ init {
+ refresh()
+ }
+
+ override fun refresh() {
+ _myRecruitments.value = _myRecruitments.value.copy(isLoading = true)
+ viewModelScope.launch {
+ when (val result = recruitmentRepository.getMemberRecruitments(uid)) {
+ is Failure, NetworkError ->
+ _myRecruitments.value =
+ _myRecruitments.value.copy(isLoading = false, isError = true)
+
+ is Success -> _myRecruitments.value = MyRecruitmentsUiState.from(result.data)
+ is Unexpected -> throw Throwable(result.error)
+ }
+ }
+ }
+}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/recyclerView/MyRecruitmentAdapter.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/recyclerView/MyRecruitmentAdapter.kt
new file mode 100644
index 000000000..7a682837b
--- /dev/null
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/recyclerView/MyRecruitmentAdapter.kt
@@ -0,0 +1,33 @@
+package com.emmsale.presentation.ui.myRecruitmentList.recyclerView
+
+import android.view.ViewGroup
+import androidx.recyclerview.widget.DiffUtil
+import androidx.recyclerview.widget.ListAdapter
+import com.emmsale.presentation.ui.myRecruitmentList.uiState.MyRecruitmentUiState
+
+class MyRecruitmentAdapter(
+ private val navigateToDetail: (eventId: Long, recruitmentId: Long) -> Unit,
+) : ListAdapter(diffUtil) {
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyRecruitmentViewHolder {
+ return MyRecruitmentViewHolder.create(parent, navigateToDetail)
+ }
+
+ override fun onBindViewHolder(holder: MyRecruitmentViewHolder, position: Int) {
+ holder.bind(getItem(position))
+ }
+
+ companion object {
+ val diffUtil = object : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(
+ oldItem: MyRecruitmentUiState,
+ newItem: MyRecruitmentUiState,
+ ): Boolean = oldItem == newItem
+
+ override fun areContentsTheSame(
+ oldItem: MyRecruitmentUiState,
+ newItem: MyRecruitmentUiState,
+ ): Boolean = (oldItem.postId == newItem.postId && oldItem.eventId == newItem.eventId)
+ }
+ }
+}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/recyclerView/MyPostViewHolder.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/recyclerView/MyRecruitmentViewHolder.kt
similarity index 60%
rename from android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/recyclerView/MyPostViewHolder.kt
rename to android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/recyclerView/MyRecruitmentViewHolder.kt
index a33ac9509..957c2f6cf 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myPostList/recyclerView/MyPostViewHolder.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/recyclerView/MyRecruitmentViewHolder.kt
@@ -1,12 +1,12 @@
-package com.emmsale.presentation.ui.myPostList.recyclerView
+package com.emmsale.presentation.ui.myRecruitmentList.recyclerView
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.emmsale.databinding.ItemMyPostBinding
-import com.emmsale.presentation.ui.myPostList.uiState.MyPostUiState
+import com.emmsale.presentation.ui.myRecruitmentList.uiState.MyRecruitmentUiState
-class MyPostViewHolder(
+class MyRecruitmentViewHolder(
private val binding: ItemMyPostBinding,
navigateToDetail: (eventId: Long, recruitmentId: Long) -> Unit,
) : RecyclerView.ViewHolder(binding.root) {
@@ -14,24 +14,24 @@ class MyPostViewHolder(
init {
itemView.setOnClickListener {
navigateToDetail(
- binding.myPost!!.eventId,
- binding.myPost!!.postId,
+ binding.recruitment!!.eventId,
+ binding.recruitment!!.postId,
)
}
}
- fun bind(myPost: MyPostUiState) {
- binding.myPost = myPost
+ fun bind(myRecruitment: MyRecruitmentUiState) {
+ binding.recruitment = myRecruitment
}
companion object {
fun create(
parent: ViewGroup,
navigateToDetail: (eventId: Long, recruitmentId: Long) -> Unit,
- ): MyPostViewHolder {
+ ): MyRecruitmentViewHolder {
val binding =
ItemMyPostBinding.inflate(LayoutInflater.from(parent.context), parent, false)
- return MyPostViewHolder(binding, navigateToDetail)
+ return MyRecruitmentViewHolder(binding, navigateToDetail)
}
}
}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/uiState/MyRecruitmentUiState.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/uiState/MyRecruitmentUiState.kt
new file mode 100644
index 000000000..58b469d4b
--- /dev/null
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/uiState/MyRecruitmentUiState.kt
@@ -0,0 +1,23 @@
+package com.emmsale.presentation.ui.myRecruitmentList.uiState
+
+import com.emmsale.data.model.Recruitment
+
+data class MyRecruitmentUiState(
+ val postId: Long = DEFAULT_ID,
+ val eventId: Long = DEFAULT_ID,
+ val eventName: String = "",
+ val content: String = "",
+ val updatedAt: String = "",
+) {
+ companion object {
+ private const val DEFAULT_ID = -1L
+
+ fun from(recruitment: Recruitment) = MyRecruitmentUiState(
+ postId = recruitment.id,
+ eventId = recruitment.event.id,
+ eventName = recruitment.event.name,
+ content = recruitment.content,
+ updatedAt = recruitment.updatedDate.toString(),
+ )
+ }
+}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/uiState/MyRecruitmentsUiState.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/uiState/MyRecruitmentsUiState.kt
new file mode 100644
index 000000000..16fcc8309
--- /dev/null
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/myRecruitmentList/uiState/MyRecruitmentsUiState.kt
@@ -0,0 +1,17 @@
+package com.emmsale.presentation.ui.myRecruitmentList.uiState
+
+import com.emmsale.data.model.Recruitment
+
+data class MyRecruitmentsUiState(
+ val list: List = listOf(),
+ val isLoading: Boolean = false,
+ val isError: Boolean = false,
+) {
+ companion object {
+ fun from(recruitments: List) = MyRecruitmentsUiState(
+ list = recruitments.map { MyRecruitmentUiState.from(it) },
+ isLoading = false,
+ isError = false,
+ )
+ }
+}
diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/setting/SettingFragment.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/setting/SettingFragment.kt
index ca4a19dff..026fb727e 100644
--- a/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/setting/SettingFragment.kt
+++ b/android/2023-emmsale/app/src/main/java/com/emmsale/presentation/ui/setting/SettingFragment.kt
@@ -15,7 +15,7 @@ import com.emmsale.presentation.common.views.WarningDialog
import com.emmsale.presentation.ui.blockMemberList.MemberBlockActivity
import com.emmsale.presentation.ui.login.LoginActivity
import com.emmsale.presentation.ui.myCommentList.MyCommentsActivity
-import com.emmsale.presentation.ui.myPostList.MyPostActivity
+import com.emmsale.presentation.ui.myRecruitmentList.MyRecruitmentActivity
import com.emmsale.presentation.ui.notificationConfig.NotificationConfigActivity
import com.emmsale.presentation.ui.setting.uiState.MemberUiState
import com.emmsale.presentation.ui.useTerm.UseTermWebViewActivity
@@ -51,7 +51,7 @@ class SettingFragment :
}
private fun showWritings() {
- MyPostActivity.startActivity(requireContext())
+ MyRecruitmentActivity.startActivity(requireContext())
}
private fun showWrittenComments() {
diff --git a/android/2023-emmsale/app/src/main/res/layout/activity_my_post.xml b/android/2023-emmsale/app/src/main/res/layout/activity_my_post.xml
index 0537a9a78..a7975cdfa 100644
--- a/android/2023-emmsale/app/src/main/res/layout/activity_my_post.xml
+++ b/android/2023-emmsale/app/src/main/res/layout/activity_my_post.xml
@@ -10,7 +10,7 @@
+ type="com.emmsale.presentation.ui.myRecruitmentList.MyRecruitmentViewModel" />
+ tools:layout_marginTop="22dp" />
+ tools:layout_marginTop="14dp" />
diff --git a/android/2023-emmsale/app/src/main/res/layout/item_my_post.xml b/android/2023-emmsale/app/src/main/res/layout/item_my_post.xml
index 29e74e05e..df1afb568 100644
--- a/android/2023-emmsale/app/src/main/res/layout/item_my_post.xml
+++ b/android/2023-emmsale/app/src/main/res/layout/item_my_post.xml
@@ -6,8 +6,8 @@
+ name="recruitment"
+ type="com.emmsale.presentation.ui.myRecruitmentList.uiState.MyRecruitmentUiState" />