diff --git a/.gitignore b/.gitignore
index 68b1aab3..8cb31e8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@ build
captures
.externalNativeBuild
.cxx
+google-services.json
local.properties
.idea
constant.xml
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..ec852c25
--- /dev/null
+++ b/README.md
@@ -0,0 +1,17 @@
+![in1.png](https://raw.githubusercontent.com/ttoklip/BackEnd/main/introduce/in1.png)
+
+![in2.png](https://raw.githubusercontent.com/ttoklip/BackEnd/main/introduce/in2.png)
+
+![in3.png](https://raw.githubusercontent.com/ttoklip/BackEnd/main/introduce/in3.png)
+
+![in4.png](https://raw.githubusercontent.com/ttoklip/BackEnd/main/introduce/in4.png)
+
+
+## 아키텍쳐
+
+
+
+## 맴버
+| [한건희](https://github.com/hangunhee39) | [김규진](https://github.com/kyujin0911) | [박승연](https://github.com/40food) | [심영수](https://github.com/posite) |
+|:------------------------------------------------------------------:|:------------------------------------------------------------------:|:------------------------------------------------------------------:|:---------------------------------------------------------------:|
+| 24.01. ~ | 24.01. ~ | 24.01. ~ | 24.01. ~ 24.02. |
diff --git a/app/build.gradle b/app/build.gradle
index 2863acb6..3e20f8f3 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -4,6 +4,7 @@ plugins {
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'
id 'dagger.hilt.android.plugin'
+ id 'com.google.gms.google-services'
}
Properties properties = new Properties()
@@ -119,6 +120,9 @@ dependencies {
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.6'
implementation 'androidx.navigation:navigation-ui-ktx:2.7.6'
+ implementation platform('com.google.firebase:firebase-bom:32.7.2')
+ implementation 'com.google.firebase:firebase-messaging-ktx'
+
//flexBox(flexLayout)
implementation 'com.google.android.flexbox:flexbox:3.0.0'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ef22e1e7..85c6e9e5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -10,6 +10,9 @@
+
+ android:exported="true" />
+
+
+
@@ -221,6 +236,15 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/FCMApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/FCMApi.kt
new file mode 100644
index 00000000..56989334
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/api/FCMApi.kt
@@ -0,0 +1,15 @@
+package com.umc.ttoklip.data.api
+
+import com.umc.ttoklip.data.model.CommonResponse
+import com.umc.ttoklip.data.model.ResponseBody
+import com.umc.ttoklip.data.model.fcm.FCMTokenRequest
+import retrofit2.Response
+import retrofit2.http.Body
+import retrofit2.http.PATCH
+
+interface FCMApi {
+ @PATCH("/api/v1/notification/fcm_token")
+ suspend fun patchFCMToken(
+ @Body request : FCMTokenRequest
+ ): Response>
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/HomeApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/HomeApi.kt
index 3ed88d11..a350971c 100644
--- a/app/src/main/java/com/umc/ttoklip/data/api/HomeApi.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/api/HomeApi.kt
@@ -2,12 +2,19 @@ package com.umc.ttoklip.data.api
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.home.HomeResponse
+import com.umc.ttoklip.data.model.home.NotificationResponse
import retrofit2.Response
import retrofit2.http.GET
+import retrofit2.http.Query
interface HomeApi {
@GET("/api/v1/home")
suspend fun getHomeMainApi(): Response>
+ @GET("/api/v1/notification/my-notification")
+ suspend fun getNotifications(
+ @Query("notificationCategory") category: String
+ ): Response>
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/HoneyTipApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/HoneyTipApi.kt
index 465d03cd..54c200dc 100644
--- a/app/src/main/java/com/umc/ttoklip/data/api/HoneyTipApi.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/api/HoneyTipApi.kt
@@ -33,7 +33,7 @@ interface HoneyTipApi {
@Part("title") title: RequestBody,
@Part("content") content: RequestBody,
@Part("category") category: RequestBody,
- @Part images: Array,
+ @Part images: List,
@Part("url") url: RequestBody
): Response>
@@ -68,7 +68,7 @@ interface HoneyTipApi {
@Part("title") title: RequestBody,
@Part("content") content: RequestBody,
@Part("category") category: RequestBody,
- @Part images: Array,
+ @Part images: List,
@Part("url") url: RequestBody
): Response>
@@ -96,7 +96,7 @@ interface HoneyTipApi {
@Part("title") title: RequestBody,
@Part("content") content: RequestBody,
@Part("category") category: RequestBody,
- @Part images: Array
+ @Part images: List
): Response>
@GET("/api/v1/question/post/{postId}")
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/KakaoApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/KakaoApi.kt
index cdaf8f67..efe1a993 100644
--- a/app/src/main/java/com/umc/ttoklip/data/api/KakaoApi.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/api/KakaoApi.kt
@@ -2,7 +2,10 @@ package com.umc.ttoklip.data.api
import com.umc.ttoklip.R
import com.umc.ttoklip.data.model.KakaoResponse
+import com.umc.ttoklip.data.model.ResponseBody
+import com.umc.ttoklip.data.model.login.LoginResponse
import retrofit2.Call
+import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Query
@@ -12,5 +15,5 @@ interface KakaoApi {
fun getSearchKeyword(
@Header("Authorization") key: String,
@Query("query") query:String
- ): Call
+ ): Response>
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/MyAccountRestrictApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/MyAccountRestrictApi.kt
deleted file mode 100644
index abc9f5e4..00000000
--- a/app/src/main/java/com/umc/ttoklip/data/api/MyAccountRestrictApi.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.umc.ttoklip.data.api
-
-import com.umc.ttoklip.data.model.ResponseBody
-import com.umc.ttoklip.data.model.mypage.RestrictedResponse
-import retrofit2.Response
-import retrofit2.http.GET
-
-interface MyAccountRestrictApi {
- @GET("/api/v1/my-page/restricted")
- suspend fun getRestrictedReason(): Response>
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/MyBlockUserApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/MyPage3Api.kt
similarity index 59%
rename from app/src/main/java/com/umc/ttoklip/data/api/MyBlockUserApi.kt
rename to app/src/main/java/com/umc/ttoklip/data/api/MyPage3Api.kt
index d867f5ca..b8762612 100644
--- a/app/src/main/java/com/umc/ttoklip/data/api/MyBlockUserApi.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/api/MyPage3Api.kt
@@ -2,16 +2,23 @@ package com.umc.ttoklip.data.api
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.mypage.MyBlockUserResponse
+import com.umc.ttoklip.data.model.mypage.NoticeResponse
+import com.umc.ttoklip.data.model.mypage.RestrictedResponse
import retrofit2.Response
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.Path
-interface MyBlockUserApi {
+interface MyPage3Api {
+ @GET("/api/v1/my-page/restricted")
+ suspend fun getRestrictedReason(): Response>
+
@GET("/api/v1/my-page/blocked")
suspend fun getMyBlockedUser(): Response>
@DELETE("/api/v1/my-page/unblock/{targetId}")
suspend fun deleteBlockUser(@Path("targetId") userId: Long): Response>
+ @GET("api/v1/notice")
+ suspend fun getNotices(): Response>
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/MyPostApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/MyPostApi.kt
index 594344a6..1c6de33f 100644
--- a/app/src/main/java/com/umc/ttoklip/data/api/MyPostApi.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/api/MyPostApi.kt
@@ -7,6 +7,7 @@ import com.umc.ttoklip.data.model.mypage.MyQuestionResponse
import com.umc.ttoklip.data.model.mypage.MyTogetherResponse
import retrofit2.Response
import retrofit2.http.GET
+import retrofit2.http.Path
import retrofit2.http.Query
interface MyPostApi {
@@ -16,6 +17,13 @@ interface MyPostApi {
@GET("/api/v1/my-page/participate-deals")
suspend fun getMyTogethers(@Query("page") page: Int): Response>
+ @GET("/api/v1/stranger/participate-deals/{userId}")
+ suspend fun getStrangerDeals(
+ @Query("page") page: Int,
+ @Path("userId") userId: Int
+ ): Response>
+
+
@GET("/api/v1/my-page/honeytip")
suspend fun getMyHoneyTips(@Query("page") page: Int): Response>
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/NaverApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/NaverApi.kt
new file mode 100644
index 00000000..94ae86b7
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/api/NaverApi.kt
@@ -0,0 +1,13 @@
+package com.umc.ttoklip.data.api
+
+import com.umc.ttoklip.data.model.naver.GeocodingResponse
+import retrofit2.Response
+import retrofit2.http.GET
+import retrofit2.http.Query
+
+interface NaverApi {
+ @GET("map-geocode/v2/geocode")
+ suspend fun fetchGeocoding(
+ @Query("query") query: String
+ ): Response
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/OtherApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/OtherApi.kt
new file mode 100644
index 00000000..219905e2
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/api/OtherApi.kt
@@ -0,0 +1,24 @@
+package com.umc.ttoklip.data.api
+
+import com.umc.ttoklip.data.model.ResponseBody
+import com.umc.ttoklip.data.model.mypage.MyHoneyTipsResponse
+import com.umc.ttoklip.data.model.stranger.OtherUserInfoResponse
+import retrofit2.Response
+import retrofit2.http.GET
+import retrofit2.http.Path
+import retrofit2.http.Query
+
+interface OtherApi {
+
+ @GET("/api/v1/stranger")
+ suspend fun getStrangeInfo(
+ @Query("nickname") nickname : String,
+ ): Response>
+
+ @GET("/api/v1/stranger/honeytip/{userId}")
+ suspend fun getStrangerTip(
+ @Path("userId") userId : Int,
+ @Query("page") page : Int,
+ ): Response>
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/ReadCommsApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/ReadCommsApi.kt
index 1e5c9242..ad98fc09 100644
--- a/app/src/main/java/com/umc/ttoklip/data/api/ReadCommsApi.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/api/ReadCommsApi.kt
@@ -2,6 +2,7 @@ package com.umc.ttoklip.data.api
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.StandardResponse
+import com.umc.ttoklip.data.model.town.CommentResponse
import com.umc.ttoklip.data.model.town.CreateCommentRequest
import com.umc.ttoklip.data.model.town.DeleteCommunicationResponse
import com.umc.ttoklip.data.model.town.ReportRequest
@@ -31,13 +32,13 @@ interface ReadCommsApi {
suspend fun createCommunicationComment(
@Body body: CreateCommentRequest,
@Path("postId") postId: Long
- ): Response>
+ ): Response>
//소통해요 댓글 삭제
@DELETE("/api/v1/town/comms/comment/{commentId}")
suspend fun deleteCommunicationComment(
@Path("commentId") commentId: Long
- ): Response>
+ ): Response>
//소통해요 스크랩 추가
@POST("/api/v1/town/comms/scrap/{postId}")
@@ -73,9 +74,9 @@ interface ReadCommsApi {
): Response>
//소통해요 댓글 신고
- @POST("/api/v1/town/comms/comment/report/{postId}")
+ @POST("/api/v1/town/comms/comment/report/{commentId}")
suspend fun reportCommunicationComment(
- @Body body: ReportRequest,
+ @Body body: com.umc.ttoklip.data.model.honeytip.request.ReportRequest,
@Path("commentId") commentId: Long
- ): Response>
+ ): Response>
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/ReadTogetherApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/ReadTogetherApi.kt
index 733bb74a..d357a752 100644
--- a/app/src/main/java/com/umc/ttoklip/data/api/ReadTogetherApi.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/api/ReadTogetherApi.kt
@@ -3,13 +3,16 @@ package com.umc.ttoklip.data.api
import com.umc.ttoklip.data.model.CommonResponse
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.StandardResponse
+import com.umc.ttoklip.data.model.town.CommentResponse
import com.umc.ttoklip.data.model.town.CreateCommentRequest
+import com.umc.ttoklip.data.model.town.PatchCartStatusRequest
import com.umc.ttoklip.data.model.town.ReportRequest
import com.umc.ttoklip.data.model.town.ViewTogetherResponse
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
+import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.Path
@@ -26,13 +29,13 @@ interface ReadTogetherApi {
suspend fun createTogetherComment(
@Body body: CreateCommentRequest,
@Path("postId") postId: Long
- ): Response>
+ ): Response>
//함께해요 댓글 삭제
@DELETE("/api/v1/town/carts/comment/{commentId}")
suspend fun deleteTogetherComment(
@Path("commentId") commentId: Long
- ): Response>
+ ): Response>
//함께해요 글 신고
@POST("/api/v1/town/carts/report/{postId}")
@@ -42,11 +45,11 @@ interface ReadTogetherApi {
): Response>
//함께해요 댓글 신고
- @POST("/api/v1/town/carts/comment/report/{postId}")
+ @POST("/api/v1/town/carts/comment/report/{commentId}")
suspend fun reportTogetherComment(
@Body body: ReportRequest,
@Path("commentId") commentId: Long
- ): Response>
+ ): Response>
@POST("/api/v1/town/carts/participants/{cartId}")
suspend fun joinTogether(
@@ -57,4 +60,15 @@ interface ReadTogetherApi {
suspend fun cancelTogether(
@Path("cartId") postId: Long
): Response>
+
+ @GET("/api/v1/town/carts/participants/count/{cartId}")
+ suspend fun fetchParticipantsCount(
+ @Path("cartId") postId: Long
+ ): Response>
+
+ @PATCH("/api/v1/town/carts/{postId}/status")
+ suspend fun patchPostStatus(
+ @Path("postId") postId: Long,
+ @Body request: PatchCartStatusRequest
+ ): Response>
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/StrangerApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/StrangerApi.kt
deleted file mode 100644
index 91fc3249..00000000
--- a/app/src/main/java/com/umc/ttoklip/data/api/StrangerApi.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.umc.ttoklip.data.api
-
-import com.umc.ttoklip.data.model.ResponseBody
-import com.umc.ttoklip.data.model.stranger.StrangerResponse
-import retrofit2.Response
-import retrofit2.http.POST
-import retrofit2.http.Query
-
-interface StrangerApi {
- @POST("/api/v1/stranger")
- suspend fun getStranger(@Query("nickname") nick: String)
- : Response>
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/api/WriteTogetherApi.kt b/app/src/main/java/com/umc/ttoklip/data/api/WriteTogetherApi.kt
index 63e89122..a989efe7 100644
--- a/app/src/main/java/com/umc/ttoklip/data/api/WriteTogetherApi.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/api/WriteTogetherApi.kt
@@ -1,5 +1,6 @@
package com.umc.ttoklip.data.api
+import com.umc.ttoklip.data.model.CommonResponse
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.town.CreateTogethersResponse
import com.umc.ttoklip.data.model.town.PatchTogetherResponse
@@ -24,7 +25,7 @@ interface WriteTogetherApi {
@Part("partyMax") party: Long,
@Part images: List,
@Part("itemUrls") itemUrls: List
- ): Response>
+ ): Response>
//함께해요 게시글 수정
@Multipart
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/fcm/FCMTokenRequest.kt b/app/src/main/java/com/umc/ttoklip/data/model/fcm/FCMTokenRequest.kt
new file mode 100644
index 00000000..68c6a7a9
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/model/fcm/FCMTokenRequest.kt
@@ -0,0 +1,5 @@
+package com.umc.ttoklip.data.model.fcm
+
+data class FCMTokenRequest(
+ val fcmToken : String
+)
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/home/NotificationItem.kt b/app/src/main/java/com/umc/ttoklip/data/model/home/NotificationItem.kt
new file mode 100644
index 00000000..9c841963
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/model/home/NotificationItem.kt
@@ -0,0 +1,10 @@
+package com.umc.ttoklip.data.model.home
+
+data class NotificationItem(
+ val noticeSuccess: Boolean,
+ val notificationId: Int,
+ val targetClassId: Int,
+ val targetClassName: String,
+ val text: String,
+ val title: String
+)
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/home/NotificationResponse.kt b/app/src/main/java/com/umc/ttoklip/data/model/home/NotificationResponse.kt
new file mode 100644
index 00000000..9bb81386
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/model/home/NotificationResponse.kt
@@ -0,0 +1,5 @@
+package com.umc.ttoklip.data.model.home
+
+data class NotificationResponse (
+ val responses : List
+)
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/mypage/HoneyTip.kt b/app/src/main/java/com/umc/ttoklip/data/model/mypage/HoneyTip.kt
index 02549c13..af31b16a 100644
--- a/app/src/main/java/com/umc/ttoklip/data/model/mypage/HoneyTip.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/model/mypage/HoneyTip.kt
@@ -9,4 +9,6 @@ data class HoneyTip(
val likeCount: Int,
val scrapCount: Int,
val commentCount: Int
-)
\ No newline at end of file
+){
+ constructor() : this("",0,"","","",0,0,0)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/mypage/MyBlockUserResponse.kt b/app/src/main/java/com/umc/ttoklip/data/model/mypage/MyBlockUserResponse.kt
index ad4084f0..ec4289dd 100644
--- a/app/src/main/java/com/umc/ttoklip/data/model/mypage/MyBlockUserResponse.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/model/mypage/MyBlockUserResponse.kt
@@ -2,4 +2,6 @@ package com.umc.ttoklip.data.model.mypage
data class MyBlockUserResponse(
val blockedUsers: List
-)
\ No newline at end of file
+){
+ constructor(): this(emptyList())
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/mypage/MyTogetherResponse.kt b/app/src/main/java/com/umc/ttoklip/data/model/mypage/MyTogetherResponse.kt
index a0a438b5..86470cca 100644
--- a/app/src/main/java/com/umc/ttoklip/data/model/mypage/MyTogetherResponse.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/model/mypage/MyTogetherResponse.kt
@@ -1,5 +1,11 @@
package com.umc.ttoklip.data.model.mypage
+import com.umc.ttoklip.data.model.town.Togethers
+
data class MyTogetherResponse(
- val participatedDeals: List
+ val carts: List,
+ val totalPage: Int,
+ val totalElements: Int,
+ val isFirst: Boolean,
+ val isLast: Boolean,
)
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/mypage/NoticeDetail.kt b/app/src/main/java/com/umc/ttoklip/data/model/mypage/NoticeDetail.kt
new file mode 100644
index 00000000..deee63c5
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/model/mypage/NoticeDetail.kt
@@ -0,0 +1,8 @@
+package com.umc.ttoklip.data.model.mypage
+
+data class NoticeDetail(
+ val noticeId:Int,
+ val title:String,
+ val content:String,
+ var visibility: Boolean=false,
+)
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/mypage/NoticeResponse.kt b/app/src/main/java/com/umc/ttoklip/data/model/mypage/NoticeResponse.kt
new file mode 100644
index 00000000..210270ec
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/model/mypage/NoticeResponse.kt
@@ -0,0 +1,5 @@
+package com.umc.ttoklip.data.model.mypage
+
+data class NoticeResponse(
+ val notices:List
+)
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/naver/AddressElements.kt b/app/src/main/java/com/umc/ttoklip/data/model/naver/AddressElements.kt
new file mode 100644
index 00000000..7fd8f470
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/model/naver/AddressElements.kt
@@ -0,0 +1,8 @@
+package com.umc.ttoklip.data.model.naver
+
+data class AddressElements(
+ val types: List,
+ val longName: String,
+ val shortName: String,
+ val code: String
+)
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/naver/Addresses.kt b/app/src/main/java/com/umc/ttoklip/data/model/naver/Addresses.kt
new file mode 100644
index 00000000..1de4b90b
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/model/naver/Addresses.kt
@@ -0,0 +1,11 @@
+package com.umc.ttoklip.data.model.naver
+
+data class Addresses(
+ val roadAddress: String,
+ val jibunAddress: String,
+ val englishAddress: String,
+ val addressElements: List,
+ val x: String,
+ val y: String,
+ val distance: Double
+)
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/naver/GeocodingResponse.kt b/app/src/main/java/com/umc/ttoklip/data/model/naver/GeocodingResponse.kt
new file mode 100644
index 00000000..63eb28cf
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/model/naver/GeocodingResponse.kt
@@ -0,0 +1,8 @@
+package com.umc.ttoklip.data.model.naver
+
+data class GeocodingResponse(
+ val status: String,
+ val meta: Meta,
+ val addresses: Addresses,
+ val errorMessage: String
+)
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/naver/Meta.kt b/app/src/main/java/com/umc/ttoklip/data/model/naver/Meta.kt
new file mode 100644
index 00000000..de862535
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/model/naver/Meta.kt
@@ -0,0 +1,7 @@
+package com.umc.ttoklip.data.model.naver
+
+data class Meta(
+ val totalCount: Int,
+ val page: Int,
+ val count: Int
+)
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/stranger/OtherUserInfoResponse.kt b/app/src/main/java/com/umc/ttoklip/data/model/stranger/OtherUserInfoResponse.kt
new file mode 100644
index 00000000..7e3c7a46
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/model/stranger/OtherUserInfoResponse.kt
@@ -0,0 +1,12 @@
+package com.umc.ttoklip.data.model.stranger
+
+data class OtherUserInfoResponse(
+ val independentMonth: Int,
+ val independentYear: Int,
+ val nickname: String,
+ val profileImage: String,
+ val street: String?,
+ val userId: Int
+) {
+ constructor() : this(0, 0, "", "", "", 0)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/town/CommentResponse.kt b/app/src/main/java/com/umc/ttoklip/data/model/town/CommentResponse.kt
index 8a640ce8..4eea2c24 100644
--- a/app/src/main/java/com/umc/ttoklip/data/model/town/CommentResponse.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/model/town/CommentResponse.kt
@@ -2,8 +2,8 @@ package com.umc.ttoklip.data.model.town
data class CommentResponse(
val commentId: Long,
- val commentContent: String?,
- val parentId: Long?,
+ val commentContent: String,
+ val parentId: Long,
val writer: String,
val writtenTime: String
)
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/town/PatchCartStatusRequest.kt b/app/src/main/java/com/umc/ttoklip/data/model/town/PatchCartStatusRequest.kt
new file mode 100644
index 00000000..6d3b87d6
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/model/town/PatchCartStatusRequest.kt
@@ -0,0 +1,5 @@
+package com.umc.ttoklip.data.model.town
+
+data class PatchCartStatusRequest(
+ val status: String
+)
diff --git a/app/src/main/java/com/umc/ttoklip/data/model/town/ViewCommunicationResponse.kt b/app/src/main/java/com/umc/ttoklip/data/model/town/ViewCommunicationResponse.kt
index e1dfb2ea..a3ad2e1d 100644
--- a/app/src/main/java/com/umc/ttoklip/data/model/town/ViewCommunicationResponse.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/model/town/ViewCommunicationResponse.kt
@@ -7,9 +7,9 @@ data class ViewCommunicationResponse(
val imageUrls: List,
val title: String,
val writtenTime: String,
- val scrapCount: Long,
- val likeCount: Long,
- val commentCount: Int,
+ var scrapCount: Long,
+ var likeCount: Long,
+ var commentCount: Int,
val commentResponses: List,
val likedByCurrentUser: Boolean,
val scrapedByCurrentUser: Boolean
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/fcm/FCMRepository.kt b/app/src/main/java/com/umc/ttoklip/data/repository/fcm/FCMRepository.kt
new file mode 100644
index 00000000..16025bd0
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/fcm/FCMRepository.kt
@@ -0,0 +1,9 @@
+package com.umc.ttoklip.data.repository.fcm
+
+import com.umc.ttoklip.data.model.CommonResponse
+import com.umc.ttoklip.data.model.fcm.FCMTokenRequest
+import com.umc.ttoklip.module.NetworkResult
+
+interface FCMRepository {
+ suspend fun patchFCMToken(request : FCMTokenRequest) : NetworkResult
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/fcm/FCMRepositoryImpl.kt b/app/src/main/java/com/umc/ttoklip/data/repository/fcm/FCMRepositoryImpl.kt
new file mode 100644
index 00000000..7cc9adf4
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/fcm/FCMRepositoryImpl.kt
@@ -0,0 +1,18 @@
+package com.umc.ttoklip.data.repository.fcm
+
+import com.umc.ttoklip.data.api.FCMApi
+import com.umc.ttoklip.data.model.CommonResponse
+import com.umc.ttoklip.data.model.ResponseBody
+import com.umc.ttoklip.data.model.fcm.FCMTokenRequest
+import com.umc.ttoklip.module.NetworkResult
+import com.umc.ttoklip.module.handleApi
+import javax.inject.Inject
+
+class FCMRepositoryImpl @Inject constructor(
+ private val api : FCMApi
+) : FCMRepository {
+
+ override suspend fun patchFCMToken(request : FCMTokenRequest): NetworkResult {
+ return handleApi({api.patchFCMToken(request)}) {response: ResponseBody -> response.result}
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/home/HomeRepository.kt b/app/src/main/java/com/umc/ttoklip/data/repository/home/HomeRepository.kt
index 49bcf096..56a931d6 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/home/HomeRepository.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/home/HomeRepository.kt
@@ -1,9 +1,12 @@
package com.umc.ttoklip.data.repository.home
import com.umc.ttoklip.data.model.home.HomeResponse
+import com.umc.ttoklip.data.model.home.NotificationResponse
import com.umc.ttoklip.module.NetworkResult
interface HomeRepository {
suspend fun getHomeMain(): NetworkResult
+
+ suspend fun getNotifications(category: String) : NetworkResult
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/home/HomeRepositoryImpl.kt b/app/src/main/java/com/umc/ttoklip/data/repository/home/HomeRepositoryImpl.kt
index 970531bc..a23230be 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/home/HomeRepositoryImpl.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/home/HomeRepositoryImpl.kt
@@ -1,14 +1,9 @@
package com.umc.ttoklip.data.repository.home
import com.umc.ttoklip.data.api.HomeApi
-import com.umc.ttoklip.data.api.SearchApi
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.home.HomeResponse
-import com.umc.ttoklip.data.model.news.MainNewsResponse
-import com.umc.ttoklip.data.model.search.NewsSearchResponse
-import com.umc.ttoklip.data.model.search.SearchModel
-import com.umc.ttoklip.data.model.search.TipSearchResponse
-import com.umc.ttoklip.data.model.search.TownSearchResponse
+import com.umc.ttoklip.data.model.home.NotificationResponse
import com.umc.ttoklip.module.NetworkResult
import com.umc.ttoklip.module.handleApi
import javax.inject.Inject
@@ -21,4 +16,9 @@ class HomeRepositoryImpl @Inject constructor(
override suspend fun getHomeMain(): NetworkResult {
return handleApi({api.getHomeMainApi()}) {response: ResponseBody -> response.result}
}
+
+ override suspend fun getNotifications(category: String): NetworkResult {
+ return handleApi({api.getNotifications(category = category)}) {response: ResponseBody -> response.result}
+
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/honeytip/HoneyTipRepository.kt b/app/src/main/java/com/umc/ttoklip/data/repository/honeytip/HoneyTipRepository.kt
index 80dc3ee1..4bc980e1 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/honeytip/HoneyTipRepository.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/honeytip/HoneyTipRepository.kt
@@ -31,7 +31,7 @@ interface HoneyTipRepository {
title: RequestBody,
content: RequestBody,
category: RequestBody,
- images: Array,
+ images: List,
url: RequestBody
): NetworkResult
@@ -44,7 +44,7 @@ interface HoneyTipRepository {
title: RequestBody,
content: RequestBody,
category: RequestBody,
- images: Array,
+ images: List,
url: RequestBody
): NetworkResult
@@ -73,7 +73,7 @@ interface HoneyTipRepository {
title: RequestBody,
content: RequestBody,
category: RequestBody,
- images: Array
+ images: List
): NetworkResult
suspend fun inquireQuestion(questionId: Int): NetworkResult
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/honeytip/HoneyTipRepositoryImpl.kt b/app/src/main/java/com/umc/ttoklip/data/repository/honeytip/HoneyTipRepositoryImpl.kt
index 0a9ef909..183b50a6 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/honeytip/HoneyTipRepositoryImpl.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/honeytip/HoneyTipRepositoryImpl.kt
@@ -44,7 +44,7 @@ class HoneyTipRepositoryImpl @Inject constructor(
title: RequestBody,
content: RequestBody,
category: RequestBody,
- images: Array,
+ images: List,
uri: RequestBody
): NetworkResult {
return handleApi({
@@ -65,7 +65,7 @@ class HoneyTipRepositoryImpl @Inject constructor(
title: RequestBody,
content: RequestBody,
category: RequestBody,
- images: Array,
+ images: List,
url: RequestBody
): NetworkResult {
return handleApi({ api.patchHoneyTip(honeyTipId, title, content, category, images, url) })
@@ -119,7 +119,7 @@ class HoneyTipRepositoryImpl @Inject constructor(
title: RequestBody,
content: RequestBody,
category: RequestBody,
- images: Array
+ images: List
): NetworkResult {
return handleApi({
api.postNewQuestion(title, content, category, images)
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/location/DirectLocationRepository.kt b/app/src/main/java/com/umc/ttoklip/data/repository/location/DirectLocationRepository.kt
index c790509d..f5d6e616 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/location/DirectLocationRepository.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/location/DirectLocationRepository.kt
@@ -1,8 +1,8 @@
package com.umc.ttoklip.data.repository.location
import com.umc.ttoklip.data.model.KakaoResponse
-import retrofit2.Call
+import com.umc.ttoklip.module.NetworkResult
interface DirectLocationRepository {
- suspend fun getDirectAddress(address:String): Call
+ suspend fun getDirectAddress(address:String): NetworkResult
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/location/DirectLocationRepositoryImpl.kt b/app/src/main/java/com/umc/ttoklip/data/repository/location/DirectLocationRepositoryImpl.kt
index fc60cd38..e03a6f27 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/location/DirectLocationRepositoryImpl.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/location/DirectLocationRepositoryImpl.kt
@@ -1,17 +1,24 @@
package com.umc.ttoklip.data.repository.location
import com.umc.ttoklip.R
+import com.umc.ttoklip.TtoklipApplication
import com.umc.ttoklip.data.api.KakaoApi
import com.umc.ttoklip.data.model.KakaoResponse
+import com.umc.ttoklip.data.model.ResponseBody
+import com.umc.ttoklip.data.model.login.LoginResponse
+import com.umc.ttoklip.module.NetworkResult
+import com.umc.ttoklip.module.handleApi
import retrofit2.Call
import javax.inject.Inject
class DirectLocationRepositoryImpl @Inject constructor(
private val api: KakaoApi
): DirectLocationRepository {
+ companion object{
+ val api_key=TtoklipApplication.getString(R.string.kakao_api_key)
+ }
- override suspend fun getDirectAddress(address: String): Call {
- val call = api.getSearchKeyword(R.string.kakao_api_key.toString(), address)
- return call
+ override suspend fun getDirectAddress(address: String): NetworkResult {
+ return handleApi({api.getSearchKeyword(api_key,address)}){response: ResponseBody ->response.result}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyAccountRestrictRepository.kt b/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyAccountRestrictRepository.kt
deleted file mode 100644
index c3ffbd2f..00000000
--- a/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyAccountRestrictRepository.kt
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.umc.ttoklip.data.repository.mypage
-
-import com.umc.ttoklip.data.model.mypage.RestrictedResponse
-import com.umc.ttoklip.module.NetworkResult
-
-interface MyAccountRestrictRepository {
- suspend fun getRestrictedReason(): NetworkResult
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyAccountRestrictRepositoryImpl.kt b/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyAccountRestrictRepositoryImpl.kt
deleted file mode 100644
index a4fba174..00000000
--- a/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyAccountRestrictRepositoryImpl.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.umc.ttoklip.data.repository.mypage
-
-import com.umc.ttoklip.data.api.MyAccountRestrictApi
-import com.umc.ttoklip.data.model.ResponseBody
-import com.umc.ttoklip.data.model.mypage.RestrictedResponse
-import com.umc.ttoklip.module.NetworkResult
-import com.umc.ttoklip.module.handleApi
-import javax.inject.Inject
-
-class MyAccountRestrictRepositoryImpl @Inject constructor(private val api: MyAccountRestrictApi) :
- MyAccountRestrictRepository {
- override suspend fun getRestrictedReason(): NetworkResult {
- return handleApi({ api.getRestrictedReason() }) { response: ResponseBody -> response.result }
- }
-
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyBlockUserRepository.kt b/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyPageRepository3.kt
similarity index 51%
rename from app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyBlockUserRepository.kt
rename to app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyPageRepository3.kt
index e7b37613..5f836d52 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyBlockUserRepository.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyPageRepository3.kt
@@ -1,9 +1,14 @@
package com.umc.ttoklip.data.repository.mypage
import com.umc.ttoklip.data.model.mypage.MyBlockUserResponse
+import com.umc.ttoklip.data.model.mypage.NoticeResponse
+import com.umc.ttoklip.data.model.mypage.RestrictedResponse
import com.umc.ttoklip.module.NetworkResult
-interface MyBlockUserRepository {
+interface MyPageRepository3 {
+ suspend fun getRestrictedReason(): NetworkResult
suspend fun getBlockedUser(): NetworkResult
suspend fun deleteBlockUser(userId: Long): NetworkResult
+
+ suspend fun getNotice(): NetworkResult
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyBlockUserRepositoryImpl.kt b/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyPageRepository3Impl.kt
similarity index 50%
rename from app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyBlockUserRepositoryImpl.kt
rename to app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyPageRepository3Impl.kt
index e042123e..8a2d2959 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyBlockUserRepositoryImpl.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyPageRepository3Impl.kt
@@ -1,14 +1,21 @@
package com.umc.ttoklip.data.repository.mypage
-import com.umc.ttoklip.data.api.MyBlockUserApi
+import com.umc.ttoklip.data.api.MyPage3Api
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.mypage.MyBlockUserResponse
+import com.umc.ttoklip.data.model.mypage.NoticeResponse
+import com.umc.ttoklip.data.model.mypage.RestrictedResponse
import com.umc.ttoklip.module.NetworkResult
import com.umc.ttoklip.module.handleApi
import javax.inject.Inject
-class MyBlockUserRepositoryImpl @Inject constructor(private val api: MyBlockUserApi) :
- MyBlockUserRepository {
+class MyPageRepository3Impl @Inject constructor(
+ private val api: MyPage3Api
+) : MyPageRepository3 {
+ override suspend fun getRestrictedReason(): NetworkResult {
+ return handleApi({ api.getRestrictedReason() }) { response: ResponseBody -> response.result }
+ }
+
override suspend fun getBlockedUser(): NetworkResult {
return handleApi({ api.getMyBlockedUser() }) { response: ResponseBody -> response.result }
}
@@ -16,4 +23,9 @@ class MyBlockUserRepositoryImpl @Inject constructor(private val api: MyBlockUser
override suspend fun deleteBlockUser(userId: Long): NetworkResult {
return handleApi({ api.deleteBlockUser(userId) }) { response: ResponseBody -> response.result }
}
+
+ override suspend fun getNotice(): NetworkResult {
+ return handleApi({api.getNotices()}){response:ResponseBody->response.result}
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyPostRepositoryImpl.kt b/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyPostRepositoryImpl.kt
index 96f71e73..27b9aac1 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyPostRepositoryImpl.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/mypage/MyPostRepositoryImpl.kt
@@ -10,6 +10,7 @@ import com.umc.ttoklip.module.NetworkResult
import com.umc.ttoklip.module.handleApi
import javax.inject.Inject
+
class MyPostRepositoryImpl @Inject constructor(private val api: MyPostApi) : MyPostRepository {
override suspend fun getMyQuestions(page: Int): NetworkResult {
return handleApi({ api.getMyQuestions(page) }) { response: ResponseBody -> response.result }
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/naver/NaverRepository.kt b/app/src/main/java/com/umc/ttoklip/data/repository/naver/NaverRepository.kt
new file mode 100644
index 00000000..6fa34d3a
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/naver/NaverRepository.kt
@@ -0,0 +1,8 @@
+package com.umc.ttoklip.data.repository.naver
+
+import com.umc.ttoklip.data.model.naver.GeocodingResponse
+import com.umc.ttoklip.module.NetworkResult
+
+interface NaverRepository {
+ suspend fun fetchGeocoding(query: String): NetworkResult
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/naver/NaverRepositoryImpl.kt b/app/src/main/java/com/umc/ttoklip/data/repository/naver/NaverRepositoryImpl.kt
new file mode 100644
index 00000000..7c469299
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/naver/NaverRepositoryImpl.kt
@@ -0,0 +1,16 @@
+package com.umc.ttoklip.data.repository.naver
+
+import com.umc.ttoklip.data.api.NaverApi
+import com.umc.ttoklip.data.model.naver.GeocodingResponse
+import com.umc.ttoklip.module.NetworkResult
+import com.umc.ttoklip.module.handleApi
+import javax.inject.Inject
+
+class NaverRepositoryImpl @Inject constructor(
+ private val api: NaverApi
+) : NaverRepository {
+ override suspend fun fetchGeocoding(query: String): NetworkResult {
+ return handleApi({api.fetchGeocoding(query)}) {response: GeocodingResponse -> response}
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/stranger/StrangerRepository.kt b/app/src/main/java/com/umc/ttoklip/data/repository/stranger/StrangerRepository.kt
index d8dc1849..9fc61a92 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/stranger/StrangerRepository.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/stranger/StrangerRepository.kt
@@ -1,9 +1,13 @@
package com.umc.ttoklip.data.repository.stranger
+import com.umc.ttoklip.data.model.mypage.MyHoneyTipsResponse
import com.umc.ttoklip.data.model.signup.SignupResponse
+import com.umc.ttoklip.data.model.stranger.OtherUserInfoResponse
import com.umc.ttoklip.data.model.stranger.StrangerResponse
import com.umc.ttoklip.module.NetworkResult
interface StrangerRepository {
- suspend fun getStranger(nick:String): NetworkResult
+ suspend fun getStranger(nick:String): NetworkResult
+
+ suspend fun getStrangerTip(page : Int, id : Int) : NetworkResult
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/stranger/StrangerRepositoryImpl.kt b/app/src/main/java/com/umc/ttoklip/data/repository/stranger/StrangerRepositoryImpl.kt
new file mode 100644
index 00000000..f495838d
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/stranger/StrangerRepositoryImpl.kt
@@ -0,0 +1,24 @@
+package com.umc.ttoklip.data.repository.stranger
+
+import com.umc.ttoklip.data.api.OtherApi
+import com.umc.ttoklip.data.model.ResponseBody
+import com.umc.ttoklip.data.model.mypage.MyHoneyTipsResponse
+import com.umc.ttoklip.data.model.stranger.OtherUserInfoResponse
+import com.umc.ttoklip.module.NetworkResult
+import com.umc.ttoklip.module.handleApi
+import javax.inject.Inject
+
+class StrangerRepositoryImpl @Inject constructor(
+ private val api : OtherApi
+) : StrangerRepository {
+
+ override suspend fun getStranger(nick: String): NetworkResult {
+ return handleApi({api.getStrangeInfo(nick)}) {response: ResponseBody ->response.result}
+ }
+
+ override suspend fun getStrangerTip(page: Int, id: Int): NetworkResult {
+ return handleApi({api.getStrangerTip(id,page)}) {response: ResponseBody -> response.result}
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadCommsRepository.kt b/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadCommsRepository.kt
index bf0a1e0c..642ced6d 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadCommsRepository.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadCommsRepository.kt
@@ -1,6 +1,7 @@
package com.umc.ttoklip.data.repository.town
import com.umc.ttoklip.data.model.StandardResponse
+import com.umc.ttoklip.data.model.town.CommentResponse
import com.umc.ttoklip.data.model.town.CreateCommentRequest
import com.umc.ttoklip.data.model.town.DeleteCommunicationResponse
import com.umc.ttoklip.data.model.town.ReportRequest
@@ -15,7 +16,7 @@ interface ReadCommsRepository {
suspend fun reportComms(postId: Long, body: ReportRequest): NetworkResult
suspend fun addCommsLike(postId: Long): NetworkResult
suspend fun cancelCommsLike(postId: Long): NetworkResult
- suspend fun createCommsComment(postId: Long, body: CreateCommentRequest): NetworkResult
- suspend fun reportCommsComment(commentId: Long, body: ReportRequest): NetworkResult
- suspend fun deleteCommsComment(commentId: Long): NetworkResult
+ suspend fun createCommsComment(postId: Long, body: CreateCommentRequest): NetworkResult
+ suspend fun reportCommsComment(commentId: Long, body: com.umc.ttoklip.data.model.honeytip.request.ReportRequest): NetworkResult
+ suspend fun deleteCommsComment(commentId: Long): NetworkResult
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadCommsRepositoryImpl.kt b/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadCommsRepositoryImpl.kt
index 0d4f39bd..f322ad2a 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadCommsRepositoryImpl.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadCommsRepositoryImpl.kt
@@ -3,6 +3,7 @@ package com.umc.ttoklip.data.repository.town
import com.umc.ttoklip.data.api.ReadCommsApi
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.StandardResponse
+import com.umc.ttoklip.data.model.town.CommentResponse
import com.umc.ttoklip.data.model.town.CreateCommentRequest
import com.umc.ttoklip.data.model.town.DeleteCommunicationResponse
import com.umc.ttoklip.data.model.town.ReportRequest
@@ -52,29 +53,29 @@ class ReadCommsRepositoryImpl @Inject constructor(private val api: ReadCommsApi)
override suspend fun createCommsComment(
postId: Long,
body: CreateCommentRequest
- ): NetworkResult {
+ ): NetworkResult {
return handleApi({
api.createCommunicationComment(
postId = postId,
body = body
)
- }) { response: ResponseBody -> response.result }
+ }) { response: ResponseBody -> response.result }
}
override suspend fun reportCommsComment(
commentId: Long,
- body: ReportRequest
- ): NetworkResult {
+ body: com.umc.ttoklip.data.model.honeytip.request.ReportRequest
+ ): NetworkResult {
return handleApi({
api.reportCommunicationComment(
commentId = commentId,
body = body
)
- }) { response: ResponseBody -> response.result }
+ }) { response: ResponseBody -> response.result }
}
- override suspend fun deleteCommsComment(commentId: Long): NetworkResult {
- return handleApi({ api.deleteCommunicationComment(commentId) }) { response: ResponseBody -> response.result }
+ override suspend fun deleteCommsComment(commentId: Long): NetworkResult {
+ return handleApi({ api.deleteCommunicationComment(commentId) }) { response: ResponseBody -> response.result }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadTogetherRepository.kt b/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadTogetherRepository.kt
index 0c2a6633..345879a4 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadTogetherRepository.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadTogetherRepository.kt
@@ -2,18 +2,24 @@ package com.umc.ttoklip.data.repository.town
import com.umc.ttoklip.data.model.CommonResponse
import com.umc.ttoklip.data.model.StandardResponse
+import com.umc.ttoklip.data.model.town.CommentResponse
import com.umc.ttoklip.data.model.town.CreateCommentRequest
+import com.umc.ttoklip.data.model.town.PatchCartStatusRequest
import com.umc.ttoklip.data.model.town.ReportRequest
import com.umc.ttoklip.data.model.town.ViewTogetherResponse
import com.umc.ttoklip.module.NetworkResult
interface ReadTogetherRepository {
suspend fun viewTogether(postId: Long): NetworkResult
- suspend fun createTogetherComment(postId: Long, body: CreateCommentRequest): NetworkResult
- suspend fun deleteTogetherComment(commentId: Long): NetworkResult
+ suspend fun createTogetherComment(postId: Long, body: CreateCommentRequest): NetworkResult
+ suspend fun deleteTogetherComment(commentId: Long): NetworkResult
suspend fun reportTogether(postId: Long, body: ReportRequest): NetworkResult
- suspend fun reportTogetherComment(commentId: Long, body: ReportRequest): NetworkResult
+ suspend fun reportTogetherComment(commentId: Long, body: ReportRequest): NetworkResult
suspend fun joinTogether(postId: Long): NetworkResult
suspend fun cancelTogether(postId: Long): NetworkResult
+
+ suspend fun fetchParticipantsCount(postId: Long): NetworkResult
+
+ suspend fun patchPostStatus(postId: Long, request: PatchCartStatusRequest): NetworkResult
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadTogetherRepositoryImpl.kt b/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadTogetherRepositoryImpl.kt
index c9abe96a..f23c6175 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadTogetherRepositoryImpl.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/town/ReadTogetherRepositoryImpl.kt
@@ -4,7 +4,9 @@ import com.umc.ttoklip.data.api.ReadTogetherApi
import com.umc.ttoklip.data.model.CommonResponse
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.StandardResponse
+import com.umc.ttoklip.data.model.town.CommentResponse
import com.umc.ttoklip.data.model.town.CreateCommentRequest
+import com.umc.ttoklip.data.model.town.PatchCartStatusRequest
import com.umc.ttoklip.data.model.town.ReportRequest
import com.umc.ttoklip.data.model.town.ViewTogetherResponse
import com.umc.ttoklip.module.NetworkResult
@@ -20,17 +22,17 @@ class ReadTogetherRepositoryImpl @Inject constructor(private val api: ReadTogeth
override suspend fun createTogetherComment(
postId: Long,
body: CreateCommentRequest
- ): NetworkResult {
+ ): NetworkResult {
return handleApi({
api.createTogetherComment(
postId = postId,
body = body
)
- }) { response: ResponseBody -> response.result }
+ }) { response: ResponseBody -> response.result }
}
- override suspend fun deleteTogetherComment(commentId: Long): NetworkResult {
- return handleApi({ api.deleteTogetherComment(commentId) }) { response: ResponseBody -> response.result }
+ override suspend fun deleteTogetherComment(commentId: Long): NetworkResult {
+ return handleApi({ api.deleteTogetherComment(commentId) }) { response: ResponseBody -> response.result }
}
override suspend fun reportTogether(
@@ -48,13 +50,13 @@ class ReadTogetherRepositoryImpl @Inject constructor(private val api: ReadTogeth
override suspend fun reportTogetherComment(
commentId: Long,
body: ReportRequest
- ): NetworkResult {
+ ): NetworkResult {
return handleApi({
api.reportTogetherComment(
commentId = commentId,
body = body
)
- }) { response: ResponseBody -> response.result }
+ }) { response: ResponseBody -> response.result }
}
override suspend fun joinTogether(postId: Long): NetworkResult {
@@ -64,4 +66,12 @@ class ReadTogetherRepositoryImpl @Inject constructor(private val api: ReadTogeth
override suspend fun cancelTogether(postId: Long): NetworkResult {
return handleApi({ api.cancelTogether(postId) }) { response: ResponseBody -> response.result }
}
+
+ override suspend fun fetchParticipantsCount(postId: Long): NetworkResult {
+ return handleApi({api.fetchParticipantsCount(postId)}) {response: ResponseBody -> response.result}
+ }
+
+ override suspend fun patchPostStatus(postId: Long, request: PatchCartStatusRequest): NetworkResult {
+ return handleApi({api.patchPostStatus(postId, request)}) {response: ResponseBody -> response.result}
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/town/WriteTogetherRepository.kt b/app/src/main/java/com/umc/ttoklip/data/repository/town/WriteTogetherRepository.kt
index d5c01f9c..2b284f0b 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/town/WriteTogetherRepository.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/town/WriteTogetherRepository.kt
@@ -1,12 +1,13 @@
package com.umc.ttoklip.data.repository.town
+import com.umc.ttoklip.data.model.CommonResponse
import com.umc.ttoklip.data.model.town.CreateTogethersRequest
import com.umc.ttoklip.data.model.town.CreateTogethersResponse
import com.umc.ttoklip.data.model.town.PatchTogetherResponse
import com.umc.ttoklip.module.NetworkResult
interface WriteTogetherRepository {
- suspend fun createTogether(body: CreateTogethersRequest): NetworkResult
+ suspend fun createTogether(body: CreateTogethersRequest): NetworkResult
suspend fun patchTogether(
postId: Long,
body: CreateTogethersRequest
diff --git a/app/src/main/java/com/umc/ttoklip/data/repository/town/WriteTogetherRepositoryImpl.kt b/app/src/main/java/com/umc/ttoklip/data/repository/town/WriteTogetherRepositoryImpl.kt
index 9b846819..3a6eb019 100644
--- a/app/src/main/java/com/umc/ttoklip/data/repository/town/WriteTogetherRepositoryImpl.kt
+++ b/app/src/main/java/com/umc/ttoklip/data/repository/town/WriteTogetherRepositoryImpl.kt
@@ -1,6 +1,7 @@
package com.umc.ttoklip.data.repository.town
import com.umc.ttoklip.data.api.WriteTogetherApi
+import com.umc.ttoklip.data.model.CommonResponse
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.town.CreateTogethersRequest
import com.umc.ttoklip.data.model.town.CreateTogethersResponse
@@ -11,7 +12,7 @@ import javax.inject.Inject
class WriteTogetherRepositoryImpl @Inject constructor(private val api: WriteTogetherApi) :
WriteTogetherRepository {
- override suspend fun createTogether(body: CreateTogethersRequest): NetworkResult {
+ override suspend fun createTogether(body: CreateTogethersRequest): NetworkResult {
return handleApi({
api.createTogethers(
title = body.title,
@@ -23,7 +24,7 @@ class WriteTogetherRepositoryImpl @Inject constructor(private val api: WriteToge
images = body.images,
itemUrls = body.itemUrls
)
- }) { response: ResponseBody -> response.result }
+ }) { response: ResponseBody -> response.result }
}
override suspend fun patchTogether(
diff --git a/app/src/main/java/com/umc/ttoklip/di/KakaoModule.kt b/app/src/main/java/com/umc/ttoklip/di/KakaoModule.kt
deleted file mode 100644
index ed5eef7b..00000000
--- a/app/src/main/java/com/umc/ttoklip/di/KakaoModule.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.umc.ttoklip.di
-
-import android.util.Log
-import com.umc.ttoklip.R
-import com.umc.ttoklip.data.api.KakaoApi
-import com.umc.ttoklip.data.api.TermApi
-import com.umc.ttoklip.data.model.KakaoResponse
-import dagger.Module
-import dagger.Provides
-import dagger.hilt.InstallIn
-import dagger.hilt.components.SingletonComponent
-import retrofit2.Call
-import retrofit2.Callback
-import retrofit2.Response
-import retrofit2.Retrofit
-import retrofit2.converter.gson.GsonConverterFactory
-import javax.inject.Singleton
-
-@Module
-@InstallIn(SingletonComponent::class)
-object KakaoModule {
-
-// private val BASE_URL = R.string.kakao.toString()
-// @Provides
-// @Singleton
-// fun kakaoApiRetrofitClient(keyword: String) {
-// val retrofit = Retrofit.Builder()
-// .baseUrl(BASE_URL)
-// .addConverterFactory(GsonConverterFactory.create())
-// .build()
-// val api = retrofit.create(KakaoApi::class.java)
-// }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/di/NetworkModule.kt b/app/src/main/java/com/umc/ttoklip/di/NetworkModule.kt
index 932bdb77..728d38ce 100644
--- a/app/src/main/java/com/umc/ttoklip/di/NetworkModule.kt
+++ b/app/src/main/java/com/umc/ttoklip/di/NetworkModule.kt
@@ -2,6 +2,8 @@ package com.umc.ttoklip.di
import com.umc.ttoklip.R
import com.umc.ttoklip.TtoklipApplication
+import com.umc.ttoklip.TtoklipApplication.Companion.getString
+import com.umc.ttoklip.data.api.FCMApi
import com.umc.ttoklip.data.api.HomeApi
import com.umc.ttoklip.data.api.HoneyTipApi
import com.umc.ttoklip.data.api.KakaoApi
@@ -10,10 +12,11 @@ import com.umc.ttoklip.data.api.MyPage2Api
import com.umc.ttoklip.data.api.MyPageApi
import com.umc.ttoklip.data.api.MainCommsApi
import com.umc.ttoklip.data.api.MainTogethersApi
-import com.umc.ttoklip.data.api.MyAccountRestrictApi
-import com.umc.ttoklip.data.api.MyBlockUserApi
+import com.umc.ttoklip.data.api.MyPage3Api
import com.umc.ttoklip.data.api.MyPostApi
+import com.umc.ttoklip.data.api.NaverApi
import com.umc.ttoklip.data.api.NewsApi
+import com.umc.ttoklip.data.api.OtherApi
import com.umc.ttoklip.data.api.ReadCommsApi
import com.umc.ttoklip.data.api.ReadTogetherApi
import com.umc.ttoklip.data.api.Search2Api
@@ -24,18 +27,19 @@ import com.umc.ttoklip.data.api.TestApi
import com.umc.ttoklip.data.api.TownMainApi
import com.umc.ttoklip.data.api.WriteCommsApi
import com.umc.ttoklip.data.api.WriteTogetherApi
+import com.umc.ttoklip.util.NaverInterceptor
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import okhttp3.Interceptor
import okhttp3.OkHttpClient
+import okhttp3.Request
import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory
-import retrofit2.create
import java.util.concurrent.TimeUnit
import javax.inject.Named
import javax.inject.Singleton
@@ -77,6 +81,31 @@ object NetworkModule {
}.build()
}
+ @Provides
+ @Singleton
+ @Named("NaverClient")
+ fun provideNaverOKHttpClient(): OkHttpClient {
+ val interceptor = HttpLoggingInterceptor().apply {
+ level = HttpLoggingInterceptor.Level.BODY
+ }
+
+ val closeInterceptor = Interceptor { chain ->
+ val request: Request =
+ chain.request().newBuilder().addHeader("Connection", "close").build()
+ chain.proceed(request)
+ }
+
+ return OkHttpClient.Builder()
+ .connectTimeout(10, TimeUnit.SECONDS)
+ .readTimeout(10, TimeUnit.SECONDS)
+ .writeTimeout(5, TimeUnit.SECONDS)
+ .addInterceptor(NaverInterceptor())
+ .addInterceptor(interceptor)
+ .addNetworkInterceptor(closeInterceptor)
+ .retryOnConnectionFailure(false)
+ .build()
+ }
+
@Provides
@Singleton
@@ -111,15 +140,28 @@ object NetworkModule {
@Named("kakao")
fun providesKakaoRetrofit(
@Named("kakaoClient") client: OkHttpClient,
- gsonConverterFactory: GsonConverterFactory
): Retrofit {
return Retrofit.Builder()
- .baseUrl(R.string.kakao.toString())
- .addConverterFactory(gsonConverterFactory)
+ .baseUrl(TtoklipApplication.getString(R.string.kakao))
+ .addConverterFactory(GsonConverterFactory.create())
.client(client)
.build()
}
+ @Provides
+ @Singleton
+ @Named("naver")
+ fun providesNaverRetrofit(
+ @Named("NaverClient") client: OkHttpClient,
+ ): Retrofit{
+ return Retrofit.Builder()
+ .client(client)
+ .baseUrl(getString(R.string. naver_url))
+ .addConverterFactory(ScalarsConverterFactory.create())
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+ }
+
@Provides
@Singleton
fun provideTestApi(retrofit: Retrofit): TestApi {
@@ -196,21 +238,15 @@ object NetworkModule {
fun provideMyPage2Api(retrofit: Retrofit): MyPage2Api{
return retrofit.buildService()
}
- @Provides
- @Singleton
- fun providesAccountRestrictApi(retrofit: Retrofit): MyAccountRestrictApi {
- return retrofit.buildService()
- }
-
@Provides
@Singleton
- fun providesMyPostApi(retrofit: Retrofit): MyPostApi {
+ fun provideMyPage3Api(retrofit: Retrofit): MyPage3Api {
return retrofit.buildService()
}
@Provides
@Singleton
- fun providesMyBlockUserApi(retrofit: Retrofit): MyBlockUserApi {
+ fun providesMyPostApi(retrofit: Retrofit): MyPostApi {
return retrofit.buildService()
}
@@ -250,6 +286,23 @@ object NetworkModule {
return retrofit.buildService()
}
+ @Provides
+ @Singleton
+ fun provideStrangerApi(retrofit: Retrofit): OtherApi {
+ return retrofit.buildService()
+ }
+
+ @Provides
+ @Singleton
+ fun provideFCMApi(retrofit: Retrofit): FCMApi {
+ return retrofit.buildService()
+ }
+
+ @Provides
+ @Singleton
+ fun provideNaverApi(@Named("naver") retrofit: Retrofit): NaverApi{
+ return retrofit.buildService()
+ }
private inline fun Retrofit.buildService(): T {
diff --git a/app/src/main/java/com/umc/ttoklip/di/RepositoryModule.kt b/app/src/main/java/com/umc/ttoklip/di/RepositoryModule.kt
index 52c71fba..0227f29b 100644
--- a/app/src/main/java/com/umc/ttoklip/di/RepositoryModule.kt
+++ b/app/src/main/java/com/umc/ttoklip/di/RepositoryModule.kt
@@ -1,14 +1,17 @@
package com.umc.ttoklip.di
+import com.umc.ttoklip.data.api.FCMApi
import com.umc.ttoklip.data.api.HomeApi
import com.umc.ttoklip.data.api.MainCommsApi
import com.umc.ttoklip.data.api.MainTogethersApi
-import com.umc.ttoklip.data.api.MyAccountRestrictApi
-import com.umc.ttoklip.data.api.MyBlockUserApi
+//import com.umc.ttoklip.data.api.MyAccountRestrictApi
import com.umc.ttoklip.data.api.MyPage2Api
+import com.umc.ttoklip.data.api.MyPage3Api
import com.umc.ttoklip.data.api.MyPageApi
import com.umc.ttoklip.data.api.MyPostApi
+import com.umc.ttoklip.data.api.NaverApi
import com.umc.ttoklip.data.api.NewsApi
+import com.umc.ttoklip.data.api.OtherApi
import com.umc.ttoklip.data.api.ReadCommsApi
import com.umc.ttoklip.data.api.ReadTogetherApi
import com.umc.ttoklip.data.api.Search2Api
@@ -16,16 +19,18 @@ import com.umc.ttoklip.data.api.SearchApi
import com.umc.ttoklip.data.api.TownMainApi
import com.umc.ttoklip.data.api.WriteCommsApi
import com.umc.ttoklip.data.api.WriteTogetherApi
+import com.umc.ttoklip.data.repository.fcm.FCMRepository
+import com.umc.ttoklip.data.repository.fcm.FCMRepositoryImpl
import com.umc.ttoklip.data.repository.home.HomeRepository
import com.umc.ttoklip.data.repository.home.HomeRepositoryImpl
-import com.umc.ttoklip.data.repository.mypage.MyAccountRestrictRepository
-import com.umc.ttoklip.data.repository.mypage.MyAccountRestrictRepositoryImpl
-import com.umc.ttoklip.data.repository.mypage.MyBlockUserRepository
-import com.umc.ttoklip.data.repository.mypage.MyBlockUserRepositoryImpl
import com.umc.ttoklip.data.repository.mypage.MyPageRepository2
import com.umc.ttoklip.data.repository.mypage.MyPageRepository2Impl
+import com.umc.ttoklip.data.repository.mypage.MyPageRepository3
+import com.umc.ttoklip.data.repository.mypage.MyPageRepository3Impl
import com.umc.ttoklip.data.repository.mypage.MyPostRepository
import com.umc.ttoklip.data.repository.mypage.MyPostRepositoryImpl
+import com.umc.ttoklip.data.repository.naver.NaverRepository
+import com.umc.ttoklip.data.repository.naver.NaverRepositoryImpl
import com.umc.ttoklip.data.repository.news.NewsRepository
import com.umc.ttoklip.data.repository.news.NewsRepositoryImpl
import com.umc.ttoklip.data.repository.scrap.ScrapRepository
@@ -34,6 +39,8 @@ import com.umc.ttoklip.data.repository.search.Search2Repository
import com.umc.ttoklip.data.repository.search.Search2RepositoryImpl
import com.umc.ttoklip.data.repository.search.SearchRepository
import com.umc.ttoklip.data.repository.search.SearchRepositoryImpl
+import com.umc.ttoklip.data.repository.stranger.StrangerRepository
+import com.umc.ttoklip.data.repository.stranger.StrangerRepositoryImpl
import com.umc.ttoklip.data.repository.town.MainCommsRepository
import com.umc.ttoklip.data.repository.town.MainCommsRepositoryImpl
import com.umc.ttoklip.data.repository.town.MainTogethersRepository
@@ -126,8 +133,8 @@ object RepositoryModule {
@Provides
@Singleton
- fun providesMyAccountRestrictRepository(api: MyAccountRestrictApi): MyAccountRestrictRepository =
- MyAccountRestrictRepositoryImpl(api)
+ fun providesMyPage3Repository(api: MyPage3Api): MyPageRepository3 =
+ MyPageRepository3Impl(api)
@Provides
@Singleton
@@ -136,12 +143,21 @@ object RepositoryModule {
@Provides
@Singleton
- fun providesMyBlockUserRepository(api: MyBlockUserApi): MyBlockUserRepository =
- MyBlockUserRepositoryImpl(api)
+ fun providesTownMainRepository(api: TownMainApi): TownMainRepository =
+ TownMainRepositoryImpl(api)
@Provides
@Singleton
- fun providesTownMainRepository(api: TownMainApi): TownMainRepository =
- TownMainRepositoryImpl(api)
+ fun providesStrangerRepository(api: OtherApi): StrangerRepository =
+ StrangerRepositoryImpl(api)
+ @Provides
+ @Singleton
+ fun providesFCMRepository(api: FCMApi): FCMRepository =
+ FCMRepositoryImpl(api)
+
+ @Provides
+ @Singleton
+ fun providesNaverRepository(api: NaverApi): NaverRepository =
+ NaverRepositoryImpl(api)
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/MainActivity.kt b/app/src/main/java/com/umc/ttoklip/presentation/MainActivity.kt
index 9e31aff9..35116041 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/MainActivity.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/MainActivity.kt
@@ -7,7 +7,11 @@ import androidx.navigation.ui.setupWithNavController
import com.umc.ttoklip.R
import com.umc.ttoklip.TtoklipApplication
import com.umc.ttoklip.databinding.ActivityMainBinding
+import com.umc.ttoklip.util.TtoklipFirebaseMessagingService
import dagger.hilt.android.AndroidEntryPoint
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
@@ -24,6 +28,7 @@ class MainActivity : AppCompatActivity() {
val navController = navHostFragment.navController
binding.bottomNav.setupWithNavController(navController)
+
}
fun goNews() {
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/alarm/AlarmActivity.kt b/app/src/main/java/com/umc/ttoklip/presentation/alarm/AlarmActivity.kt
index 664e3f0b..00580cd2 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/alarm/AlarmActivity.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/alarm/AlarmActivity.kt
@@ -2,19 +2,43 @@ package com.umc.ttoklip.presentation.alarm
import android.content.Context
import android.content.Intent
-import androidx.activity.viewModels
import com.umc.ttoklip.R
+import android.util.Log
+import androidx.activity.viewModels
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.lifecycleScope
+import androidx.lifecycle.repeatOnLifecycle
import com.umc.ttoklip.databinding.ActivityAlarmBinding
import com.umc.ttoklip.presentation.base.BaseActivity
-import com.umc.ttoklip.presentation.news.adapter.Dummy
+import com.umc.ttoklip.presentation.hometown.together.read.ReadTogetherActivity
+import com.umc.ttoklip.presentation.honeytip.read.ReadHoneyTipActivity
+import com.umc.ttoklip.presentation.honeytip.read.ReadQuestionActivity
import com.umc.ttoklip.presentation.search.adapter.AlarmRVA
-import com.umc.ttoklip.presentation.search.adapter.SearchRVA
+import dagger.hilt.android.AndroidEntryPoint
+import kotlinx.coroutines.launch
+@AndroidEntryPoint
class AlarmActivity : BaseActivity(R.layout.activity_alarm) {
- private val viewModel: AlarmViewModel by viewModels()
+ private val viewModel: AlarmViewModel by viewModels()
private val alarmRVA by lazy {
- AlarmRVA({})
+ AlarmRVA {
+ when (it.title) {
+ "꿀팁 공유해요" -> {
+ startActivity(ReadHoneyTipActivity.newIntent(this, it.targetClassId))
+ }
+
+ "우리동네 덧글", "우리동네 답글" -> {
+ startActivity(ReadTogetherActivity.newIntent(this, it.targetClassId.toLong()))
+ }
+
+ "질문해요" -> {
+ startActivity(ReadQuestionActivity.newIntent(this, it.targetClassId))
+ }
+
+ else -> Unit
+ }
+ }
}
override fun initView() {
@@ -23,22 +47,23 @@ class AlarmActivity : BaseActivity(R.layout.activity_alarm
finish()
}
binding.alarmRV.adapter = alarmRVA
- alarmRVA.submitList(
- listOf(
- Dummy("1"),
- Dummy("2")
- )
- )
}
override fun initObserver() {
-
+ lifecycleScope.launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.notiList.collect {
+ alarmRVA.submitList(it)
+ Log.d("확인", "${it.map { it.notificationId }}")
+ }
+ }
+ }
}
- companion object{
+ companion object {
const val ALARM = "alarm"
- fun newIntent(context : Context) =
+ fun newIntent(context: Context) =
Intent(context, AlarmActivity::class.java)
}
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/alarm/AlarmViewModel.kt b/app/src/main/java/com/umc/ttoklip/presentation/alarm/AlarmViewModel.kt
index a65e0679..b6288ba4 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/alarm/AlarmViewModel.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/alarm/AlarmViewModel.kt
@@ -1,4 +1,115 @@
package com.umc.ttoklip.presentation.alarm
-interface AlarmViewModel {
+import android.util.Log
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import com.umc.ttoklip.TtoklipApplication
+import com.umc.ttoklip.data.model.home.NotificationItem
+import com.umc.ttoklip.data.model.home.NotificationResponse
+import com.umc.ttoklip.data.model.news.News
+import com.umc.ttoklip.data.repository.home.HomeRepository
+import com.umc.ttoklip.module.onException
+import com.umc.ttoklip.module.onFail
+import com.umc.ttoklip.module.onSuccess
+import dagger.hilt.android.lifecycle.HiltViewModel
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.launch
+import javax.inject.Inject
+
+@HiltViewModel
+class AlarmViewModel @Inject constructor(
+ private val repository: HomeRepository
+) : ViewModel() {
+
+ private val _notiList = MutableStateFlow>(listOf())
+ val notiList: StateFlow>
+ get() = _notiList
+
+ init {
+ viewModelScope.launch {
+ getNotificationsHoney()
+ getNotificationsQuestion()
+ getNotificationsTown()
+ notiList.value.sortedBy { it.notificationId }
+ }
+ }
+
+ private fun getNotificationsHoney() {
+ viewModelScope.launch {
+ try {
+ repository.getNotifications("HONEY_TIP_COMMENT")
+ .onSuccess {
+ _notiList.emit(notiList.value + it.responses)
+ repository.getNotifications("HONEY_TIP_CHILD_COMMENT")
+ .onSuccess {
+ _notiList.emit(notiList.value + it.responses)
+ }.onFail {
+
+ }.onException {
+ throw it
+ }
+ }.onFail {
+
+ }.onException {
+ throw it
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ Log.d("예외", "$e")
+ }
+ }
+ }
+
+ private fun getNotificationsQuestion() {
+ viewModelScope.launch {
+ try {
+ repository.getNotifications("QUESTION_COMMENT")
+ .onSuccess {
+ _notiList.emit(notiList.value + it.responses)
+ repository.getNotifications("QUESTION_CHILD_COMMENT")
+ .onSuccess {
+ _notiList.emit(notiList.value + it.responses)
+ }.onFail {
+
+ }.onException {
+ throw it
+ }
+ }.onFail {
+
+ }.onException {
+ throw it
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ Log.d("예외", "$e")
+ }
+ }
+ }
+
+ private fun getNotificationsTown() {
+ viewModelScope.launch {
+ try {
+ repository.getNotifications("OUR_TOWN_COMMENT")
+ .onSuccess {
+ _notiList.emit(notiList.value + it.responses)
+ repository.getNotifications("OUR_TOWN_CHILD_COMMENT")
+ .onSuccess {
+ _notiList.emit(notiList.value + it.responses)
+ }.onFail {
+
+ }.onException {
+ throw it
+ }
+ }.onFail {
+
+ }.onException {
+ throw it
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ Log.d("예외", "$e")
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/alarm/AlarmViewModelImpl.kt b/app/src/main/java/com/umc/ttoklip/presentation/alarm/AlarmViewModelImpl.kt
deleted file mode 100644
index 43dd896f..00000000
--- a/app/src/main/java/com/umc/ttoklip/presentation/alarm/AlarmViewModelImpl.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-package com.umc.ttoklip.presentation.alarm
-
-import androidx.lifecycle.ViewModel
-
-class AlarmViewModelImpl: AlarmViewModel, ViewModel() {
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/alarm/adapter/AlarmRVA.kt b/app/src/main/java/com/umc/ttoklip/presentation/alarm/adapter/AlarmRVA.kt
index 20e4db9d..966d7843 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/alarm/adapter/AlarmRVA.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/alarm/adapter/AlarmRVA.kt
@@ -5,17 +5,21 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
+import com.umc.ttoklip.data.model.home.NotificationItem
import com.umc.ttoklip.databinding.ItemAlarmBinding
import com.umc.ttoklip.presentation.news.adapter.Dummy
-class AlarmRVA(val onClick: () -> Unit) : ListAdapter(differ) {
+class AlarmRVA(val onClick: (NotificationItem) -> Unit) : ListAdapter(differ) {
inner class ItemViewHolder(
private val binding: ItemAlarmBinding
) : RecyclerView.ViewHolder(binding.root) {
- fun bind(data: Dummy) {
-
+ fun bind(data: NotificationItem) {
+ binding.item = data
+ binding.root.setOnClickListener {
+ onClick(data)
+ }
}
}
@@ -37,12 +41,12 @@ class AlarmRVA(val onClick: () -> Unit) : ListAdapter() {
- override fun areItemsTheSame(oldItem: Dummy, newItem: Dummy): Boolean {
- return oldItem.name == newItem.name
+ val differ = object : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(oldItem: NotificationItem, newItem: NotificationItem): Boolean {
+ return oldItem.notificationId == newItem.notificationId
}
- override fun areContentsTheSame(oldItem: Dummy, newItem: Dummy): Boolean {
+ override fun areContentsTheSame(oldItem: NotificationItem, newItem: NotificationItem): Boolean {
return oldItem == newItem
}
}
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/base/BaseDialogFragment.kt b/app/src/main/java/com/umc/ttoklip/presentation/base/BaseDialogFragment.kt
index 05db9ded..abb65df0 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/base/BaseDialogFragment.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/base/BaseDialogFragment.kt
@@ -29,7 +29,7 @@ abstract class BaseDialogFragment(@LayoutRes val layoutReso
null,
false
)
- binding.lifecycleOwner = this
+ binding.lifecycleOwner = this.viewLifecycleOwner
return binding.root
}
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/honeytip/dialog/DeleteDialogFragment.kt b/app/src/main/java/com/umc/ttoklip/presentation/dialog/DeleteDialogFragment.kt
similarity index 77%
rename from app/src/main/java/com/umc/ttoklip/presentation/honeytip/dialog/DeleteDialogFragment.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/dialog/DeleteDialogFragment.kt
index c011fd87..b8003258 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/honeytip/dialog/DeleteDialogFragment.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/dialog/DeleteDialogFragment.kt
@@ -1,30 +1,30 @@
-package com.umc.ttoklip.presentation.honeytip.dialog
-
-import com.umc.ttoklip.R
-import com.umc.ttoklip.databinding.DialogDeleteBinding
-import com.umc.ttoklip.presentation.base.BaseDialogFragment
-
-class DeleteDialogFragment: BaseDialogFragment(R.layout.dialog_delete) {
- private lateinit var dialogClickListener: DialogClickListener
- override fun initObserver() {
-
- }
-
- override fun initView() {
- binding.cancelBtn.setOnClickListener {
- dismiss()
- }
- binding.acceptBtn.setOnClickListener {
- dialogClickListener.onClick()
- dismiss()
- }
- }
-
- fun setDialogClickListener(dialogClickListener: DialogClickListener){
- this.dialogClickListener = dialogClickListener
- }
-
- interface DialogClickListener{
- fun onClick()
- }
+package com.umc.ttoklip.presentation.dialog
+
+import com.umc.ttoklip.R
+import com.umc.ttoklip.databinding.DialogDeleteBinding
+import com.umc.ttoklip.presentation.base.BaseDialogFragment
+
+class DeleteDialogFragment: BaseDialogFragment(R.layout.dialog_delete) {
+ private var dialogClickListener: DialogClickListener? = null
+ override fun initObserver() {
+
+ }
+
+ override fun initView() {
+ binding.cancelBtn.setOnClickListener {
+ dismiss()
+ }
+ binding.acceptBtn.setOnClickListener {
+ dialogClickListener?.onClick()
+ dismiss()
+ }
+ }
+
+ fun setDialogClickListener(dialogClickListener: DialogClickListener){
+ this.dialogClickListener = dialogClickListener
+ }
+
+ interface DialogClickListener{
+ fun onClick()
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/dialog/FinishCartDialogFragment.kt b/app/src/main/java/com/umc/ttoklip/presentation/dialog/FinishCartDialogFragment.kt
new file mode 100644
index 00000000..72154e90
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/presentation/dialog/FinishCartDialogFragment.kt
@@ -0,0 +1,31 @@
+package com.umc.ttoklip.presentation.dialog
+
+import com.umc.ttoklip.R
+import com.umc.ttoklip.databinding.DialogCartFinishBinding
+import com.umc.ttoklip.databinding.DialogDeleteBinding
+import com.umc.ttoklip.presentation.base.BaseDialogFragment
+
+class FinishCartDialogFragment: BaseDialogFragment(R.layout.dialog_cart_finish) {
+ private var dialogClickListener: DialogClickListener? = null
+ override fun initObserver() {
+
+ }
+
+ override fun initView() {
+ binding.cancelBtn.setOnClickListener {
+ dismiss()
+ }
+ binding.acceptBtn.setOnClickListener {
+ dialogClickListener?.onClick()
+ dismiss()
+ }
+ }
+
+ fun setDialogClickListener(dialogClickListener: DialogClickListener){
+ this.dialogClickListener = dialogClickListener
+ }
+
+ interface DialogClickListener{
+ fun onClick()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/honeytip/dialog/ImageDialog.kt b/app/src/main/java/com/umc/ttoklip/presentation/dialog/ImageDialog.kt
similarity index 95%
rename from app/src/main/java/com/umc/ttoklip/presentation/honeytip/dialog/ImageDialog.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/dialog/ImageDialog.kt
index 51957799..0961ea83 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/honeytip/dialog/ImageDialog.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/dialog/ImageDialog.kt
@@ -1,4 +1,4 @@
-package com.umc.ttoklip.presentation.honeytip.dialog
+package com.umc.ttoklip.presentation.dialog
import android.app.Dialog
import android.content.Context
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/honeytip/dialog/ImageDialogFragment.kt b/app/src/main/java/com/umc/ttoklip/presentation/dialog/ImageDialogFragment.kt
similarity index 93%
rename from app/src/main/java/com/umc/ttoklip/presentation/honeytip/dialog/ImageDialogFragment.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/dialog/ImageDialogFragment.kt
index 3b81ddf0..65f6905e 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/honeytip/dialog/ImageDialogFragment.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/dialog/ImageDialogFragment.kt
@@ -1,4 +1,4 @@
-package com.umc.ttoklip.presentation.honeytip.dialog
+package com.umc.ttoklip.presentation.dialog
import com.umc.ttoklip.R
import com.umc.ttoklip.databinding.DialogImageBinding
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/honeytip/dialog/ReportDialogFragment.kt b/app/src/main/java/com/umc/ttoklip/presentation/dialog/ReportDialogFragment.kt
similarity index 94%
rename from app/src/main/java/com/umc/ttoklip/presentation/honeytip/dialog/ReportDialogFragment.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/dialog/ReportDialogFragment.kt
index 71c3d657..18af936a 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/honeytip/dialog/ReportDialogFragment.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/dialog/ReportDialogFragment.kt
@@ -1,96 +1,97 @@
-package com.umc.ttoklip.presentation.honeytip.dialog
-
-import CustomSpinnerAdapter
-import android.app.Dialog
-import android.content.Context
-import android.graphics.Point
-import android.os.Build
-import android.util.Log
-import android.view.WindowManager
-import com.umc.ttoklip.R
-import com.umc.ttoklip.data.model.honeytip.request.ReportRequest
-import com.umc.ttoklip.databinding.DialogReportBinding
-import com.umc.ttoklip.presentation.base.BaseDialogFragment
-
-class ReportDialogFragment: BaseDialogFragment(R.layout.dialog_report), CustomSpinnerAdapter.GetSpinnerTextListener {
- private lateinit var dialogClickListener: DialogClickListener
- private var reportType = ""
- override fun initObserver() {
-
- }
-
- override fun initView() {
- val list = arrayListOf(
- "신고사유",
- "낚시 / 중복 / 도배성 게시물",
- "상업적 광고 / 홍보 글",
- "선정적 / 불쾌함이 느껴지는 부적절한 글",
- "비방 / 욕설 / 혐오 표현이 사용된 글",
- "종교 / 포교 관련 글",
- "게시판 성격에 부적절",
- "유출 / 사칭 / 사기",
- )
- val adapter = CustomSpinnerAdapter(requireContext(), list, this)
- binding.spinner.adapter = adapter
- binding.cancelBtn.setOnClickListener {
- dismiss()
- }
- binding.acceptBtn.setOnClickListener {
- dialogClickListener.onClick(content = binding.reasonEt.text.toString(), type = stringToEnum(reportType))
- dismiss()
- }
- }
-
- fun setDialogClickListener(dialogClickListener: DialogClickListener){
- this.dialogClickListener = dialogClickListener
- }
-
- interface DialogClickListener{
- fun onClick(type: String, content : String)
- }
-
- private fun resize(dialog: Dialog, width: Float, height: Float){
- val windowManager = context?.getSystemService(Context.WINDOW_SERVICE) as WindowManager
-
- if (Build.VERSION.SDK_INT < 30) {
- val size = Point()
- windowManager.defaultDisplay.getSize(size)
-
- val x = (size.x * width).toInt()
- val y = (size.y * height).toInt()
- dialog.window?.setLayout(x, y)
- } else {
- val rect = windowManager.currentWindowMetrics.bounds
-
- val x = (rect.width() * width).toInt()
- val y = (rect.height() * height).toInt()
- dialog.window?.setLayout(x, y)
- }
- }
-
- override fun getText(text: String) {
- reportType = text
- Log.d("reportType", reportType.toString())
- }
-
- private fun stringToEnum(reportType: String): String {
- return when (reportType) {
- "낚시 / 중복 / 도배성 게시물" -> ReportType.FISHING_DUPLICATE_SPAM.toString()
- "상업적 광고 / 홍보 글" -> ReportType.COMMERCIAL_ADVERTISING.toString()
- "선정적 / 불쾌함이 느껴지는 부적절한 글" -> ReportType.INAPPROPRIATE_CONTENT.toString()
- "비방 / 욕설 / 혐오 표현이 사용된 글" -> ReportType.ABUSE.toString()
- "종교 / 포교 관련 글" -> ReportType.RELIGIOUS_PROSELYTIZING.toString()
- "게시판 성격에 부적절" -> ReportType.INAPPROPRIATE_FOR_FORUM.toString()
- else -> ReportType.LEAK_IMPERSONATION_FRAUD.toString()
- }
- }
- enum class ReportType{
- FISHING_DUPLICATE_SPAM,
- COMMERCIAL_ADVERTISING,
- INAPPROPRIATE_CONTENT,
- ABUSE,
- RELIGIOUS_PROSELYTIZING,
- INAPPROPRIATE_FOR_FORUM,
- LEAK_IMPERSONATION_FRAUD
- }
+package com.umc.ttoklip.presentation.dialog
+
+import CustomSpinnerAdapter
+import android.app.Dialog
+import android.content.Context
+import android.graphics.Point
+import android.os.Build
+import android.util.Log
+import android.view.WindowManager
+import com.umc.ttoklip.R
+import com.umc.ttoklip.data.model.honeytip.request.ReportRequest
+import com.umc.ttoklip.databinding.DialogReportBinding
+import com.umc.ttoklip.presentation.base.BaseDialogFragment
+
+class ReportDialogFragment: BaseDialogFragment(R.layout.dialog_report), CustomSpinnerAdapter.GetSpinnerTextListener {
+ private lateinit var dialogClickListener: DialogClickListener
+ private var reportType = ""
+ override fun initObserver() {
+
+ }
+
+ override fun initView() {
+ val list = arrayListOf(
+ "신고사유",
+ "낚시 / 중복 / 도배성 게시물",
+ "상업적 광고 / 홍보 글",
+ "선정적 / 불쾌함이 느껴지는 부적절한 글",
+ "비방 / 욕설 / 혐오 표현이 사용된 글",
+ "종교 / 포교 관련 글",
+ "게시판 성격에 부적절",
+ "유출 / 사칭 / 사기",
+ )
+ val adapter = CustomSpinnerAdapter(requireContext(), list, this)
+ binding.spinner.adapter = adapter
+ binding.cancelBtn.setOnClickListener {
+ dismiss()
+ }
+ binding.acceptBtn.setOnClickListener {
+ dialogClickListener.onClick(content = binding.reasonEt.text.toString(), type = stringToEnum(reportType))
+ dismiss()
+ }
+ }
+
+ fun setDialogClickListener(dialogClickListener: DialogClickListener){
+ this.dialogClickListener = dialogClickListener
+ }
+
+ interface DialogClickListener{
+ fun onClick(type: String, content : String)
+ }
+
+ private fun resize(dialog: Dialog, width: Float, height: Float){
+ val windowManager = context?.getSystemService(Context.WINDOW_SERVICE) as WindowManager
+
+ if (Build.VERSION.SDK_INT < 30) {
+ val size = Point()
+ windowManager.defaultDisplay.getSize(size)
+
+ val x = (size.x * width).toInt()
+ val y = (size.y * height).toInt()
+ dialog.window?.setLayout(x, y)
+ } else {
+ val rect = windowManager.currentWindowMetrics.bounds
+
+ val x = (rect.width() * width).toInt()
+ val y = (rect.height() * height).toInt()
+ dialog.window?.setLayout(x, y)
+ }
+ }
+
+ override fun getText(text: String) {
+ reportType = text
+ Log.d("reportType", reportType.toString())
+ }
+
+ private fun stringToEnum(reportType: String): String {
+ return when (reportType) {
+ "낚시 / 중복 / 도배성 게시물" -> ReportType.FISHING_DUPLICATE_SPAM.toString()
+ "상업적 광고 / 홍보 글" -> ReportType.COMMERCIAL_ADVERTISING.toString()
+ "선정적 / 불쾌함이 느껴지는 부적절한 글" -> ReportType.INAPPROPRIATE_CONTENT.toString()
+ "비방 / 욕설 / 혐오 표현이 사용된 글" -> ReportType.ABUSE.toString()
+ "종교 / 포교 관련 글" -> ReportType.RELIGIOUS_PROSELYTIZING.toString()
+ "게시판 성격에 부적절" -> ReportType.INAPPROPRIATE_FOR_FORUM.toString()
+ "유출 / 사칭 / 사기" -> ReportType.LEAK_IMPERSONATION_FRAUD.toString()
+ else -> ""
+ }
+ }
+ enum class ReportType{
+ FISHING_DUPLICATE_SPAM,
+ COMMERCIAL_ADVERTISING,
+ INAPPROPRIATE_CONTENT,
+ ABUSE,
+ RELIGIOUS_PROSELYTIZING,
+ INAPPROPRIATE_FOR_FORUM,
+ LEAK_IMPERSONATION_FRAUD
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/home/HomeFragment.kt b/app/src/main/java/com/umc/ttoklip/presentation/home/HomeFragment.kt
index 7a85fd20..f436b8b2 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/home/HomeFragment.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/home/HomeFragment.kt
@@ -16,9 +16,9 @@ import com.umc.ttoklip.presentation.MainActivity
import com.umc.ttoklip.presentation.alarm.AlarmActivity
import com.umc.ttoklip.presentation.base.BaseFragment
import com.umc.ttoklip.presentation.home.adapter.HomeTipRVA
-import com.umc.ttoklip.presentation.hometown.CommunicationActivity
-import com.umc.ttoklip.presentation.hometown.ReadTogetherActivity
-import com.umc.ttoklip.presentation.hometown.TogetherActivity
+import com.umc.ttoklip.presentation.hometown.communication.CommunicationActivity
+import com.umc.ttoklip.presentation.hometown.together.read.ReadTogetherActivity
+import com.umc.ttoklip.presentation.hometown.together.TogetherActivity
import com.umc.ttoklip.presentation.honeytip.adapter.OnItemClickListener
import com.umc.ttoklip.presentation.honeytip.read.ReadHoneyTipActivity
import com.umc.ttoklip.presentation.mypage.adapter.OnTogetherItemClickListener
@@ -26,7 +26,10 @@ import com.umc.ttoklip.presentation.mypage.adapter.TransactionAdapter
import com.umc.ttoklip.presentation.news.adapter.NewsRVA
import com.umc.ttoklip.presentation.news.detail.ArticleActivity
import com.umc.ttoklip.presentation.search2.SearchActivity2
+import com.umc.ttoklip.util.TtoklipFirebaseMessagingService
import dagger.hilt.android.AndroidEntryPoint
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@AndroidEntryPoint
@@ -93,8 +96,12 @@ class HomeFragment : BaseFragment(R.layout.fragment_home),
binding.vm = viewModel
binding.tipRV.adapter = tipRVA
viewModel.getMain()
- TtoklipApplication.prefs.setString("nickname","이강인")
- Log.d("엑세스","${TtoklipApplication.prefs.getString("jwt","")}")
+ viewModel.fetchGeocoding("분당구 불정로 6")
+ Log.d("엑세스", "${TtoklipApplication.prefs.getString("jwt", "")}")
+
+ CoroutineScope(Dispatchers.IO).launch {
+ viewModel.patchFCM(TtoklipFirebaseMessagingService().getFirebaseToken())
+ }
binding.chatImg.setOnClickListener {
val intent = Intent(requireContext(), CommunicationActivity::class.java)
@@ -104,9 +111,6 @@ class HomeFragment : BaseFragment(R.layout.fragment_home),
val intent = Intent(requireContext(), TogetherActivity::class.java)
startActivity(intent)
}
- //테스트
- binding.weatherImg.setImageResource(Weather.CLOUD.resId)
- binding.weatherTitle.text = Weather.CLOUD.label
binding.newsRV.adapter = newsRVA
binding.groupBuyRV.adapter = townRVA
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/home/HomeViewModel.kt b/app/src/main/java/com/umc/ttoklip/presentation/home/HomeViewModel.kt
index e40d502c..a8d9528e 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/home/HomeViewModel.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/home/HomeViewModel.kt
@@ -5,10 +5,10 @@ import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
interface HomeViewModel {
- val haveWork : StateFlow
- val doneWork : StateFlow
- val activityBus : SharedFlow
- val mainData : StateFlow
+ val haveWork: StateFlow
+ val doneWork: StateFlow
+ val activityBus: SharedFlow
+ val mainData: StateFlow
fun clickDelayWork()
fun clickDoneWork()
@@ -18,8 +18,11 @@ interface HomeViewModel {
fun clickAlarm()
fun clickSearch()
fun getMain()
+ fun patchFCM(token: String)
- enum class ActivityEventBus{
+ fun fetchGeocoding(query: String)
+
+ enum class ActivityEventBus {
SEARCH,
NEWS_DETAIL,
TIP_DETAIL,
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/home/HomeViewModelImpl.kt b/app/src/main/java/com/umc/ttoklip/presentation/home/HomeViewModelImpl.kt
index d822ea6e..a55b84d6 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/home/HomeViewModelImpl.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/home/HomeViewModelImpl.kt
@@ -5,8 +5,12 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
+import com.umc.ttoklip.TtoklipApplication
+import com.umc.ttoklip.data.model.fcm.FCMTokenRequest
import com.umc.ttoklip.data.model.home.HomeResponse
+import com.umc.ttoklip.data.repository.fcm.FCMRepository
import com.umc.ttoklip.data.repository.home.HomeRepository
+import com.umc.ttoklip.data.repository.naver.NaverRepository
import com.umc.ttoklip.module.NetworkResult
import com.umc.ttoklip.module.onException
import com.umc.ttoklip.module.onFail
@@ -23,7 +27,9 @@ import javax.inject.Inject
@HiltViewModel
class HomeViewModelImpl @Inject constructor(
- private val homeRepository: HomeRepository
+ private val homeRepository: HomeRepository,
+ private val fcmRepository: FCMRepository,
+ private val naverRepository: NaverRepository
) : ViewModel(), HomeViewModel {
private val _haveWork: MutableStateFlow = MutableStateFlow(true)
@@ -90,15 +96,42 @@ class HomeViewModelImpl @Inject constructor(
homeRepository.getHomeMain()
.onSuccess {
_mainData.emit(it)
+ TtoklipApplication.prefs.setString("nickname", it.currentMemberNickname)
}.onFail {
- }.onException {
- throw it
- }
+ }.onException {
+ throw it
+ }
} catch (e: Exception) {
e.printStackTrace()
Log.d("예외", "$e")
}
}
}
+
+ override fun patchFCM(token: String) {
+ viewModelScope.launch {
+ try {
+ fcmRepository.patchFCMToken(FCMTokenRequest(token))
+ .onSuccess {
+
+ }.onFail {
+
+ }.onException {
+ throw it
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ Log.d("예외", "$e")
+ }
+ }
+ }
+
+ override fun fetchGeocoding(query: String) {
+ viewModelScope.launch {
+ naverRepository.fetchGeocoding(query).onSuccess {
+ Log.d("naver", it.toString())
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/MyHometownFragment.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/MyHometownFragment.kt
index 579e6017..8bf6f963 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/MyHometownFragment.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/MyHometownFragment.kt
@@ -15,8 +15,13 @@ import com.umc.ttoklip.databinding.FragmentMyHometownBinding
import com.umc.ttoklip.presentation.alarm.AlarmActivity
import com.umc.ttoklip.presentation.base.BaseFragment
import com.umc.ttoklip.presentation.hometown.adapter.OnTogetherClickListener
-import com.umc.ttoklip.presentation.hometown.adapter.Together
import com.umc.ttoklip.presentation.hometown.adapter.TogetherAdapter
+import com.umc.ttoklip.presentation.hometown.communication.CommunicationActivity
+import com.umc.ttoklip.presentation.hometown.communication.read.ReadCommunicationActivity
+import com.umc.ttoklip.presentation.hometown.communication.write.WriteCommunicationActivity
+import com.umc.ttoklip.presentation.hometown.together.read.ReadTogetherActivity
+import com.umc.ttoklip.presentation.hometown.together.TogetherActivity
+import com.umc.ttoklip.presentation.hometown.together.write.WriteTogetherActivity
import com.umc.ttoklip.presentation.mypage.MyHometownAddressActivity
import com.umc.ttoklip.presentation.search.SearchActivity
import dagger.hilt.android.AndroidEntryPoint
@@ -68,7 +73,6 @@ class MyHometownFragment : BaseFragment(R.layout.frag
val intent = Intent(requireContext(), TogetherActivity::class.java)
startActivity(intent)
}
- viewModel.getM()
binding.seeDetailCommunicationBtn.setOnClickListener {
val intent = Intent(requireContext(), CommunicationActivity::class.java)
@@ -135,4 +139,9 @@ class MyHometownFragment : BaseFragment(R.layout.frag
startActivity(intent)
}
}
+
+ override fun onResume() {
+ super.onResume()
+ viewModel.getM()
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/ReadCommunicationViewModel.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/ReadCommunicationViewModel.kt
deleted file mode 100644
index c1c577db..00000000
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/ReadCommunicationViewModel.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.umc.ttoklip.presentation.hometown
-
-import com.umc.ttoklip.data.model.town.CreateCommentRequest
-import com.umc.ttoklip.data.model.town.ReportRequest
-import com.umc.ttoklip.data.model.town.ViewCommunicationResponse
-import kotlinx.coroutines.flow.StateFlow
-
-interface ReadCommunicationViewModel {
- val postId: StateFlow
- val postContent: StateFlow
- val like: StateFlow
- val scrap: StateFlow
-
- fun savePostId(postId: Long)
- fun readCommunication(postId: Long)
- fun changeScrap()
- fun changeLike()
- fun reportPost(reportRequest: ReportRequest)
- fun reportComment(commentId: Long, reportRequest: ReportRequest)
- fun deleteComment(commentId: Long)
- fun createComment(body: CreateCommentRequest)
-
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/ReadTogetherActivity.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/ReadTogetherActivity.kt
deleted file mode 100644
index 9cefa8f2..00000000
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/ReadTogetherActivity.kt
+++ /dev/null
@@ -1,216 +0,0 @@
-package com.umc.ttoklip.presentation.hometown
-
-import android.content.Context
-import android.content.Intent
-import android.graphics.Rect
-import android.text.SpannableString
-import android.text.style.ForegroundColorSpan
-import android.util.Log
-import android.view.MotionEvent
-import android.view.inputmethod.InputMethodManager
-import android.widget.EditText
-import androidx.activity.viewModels
-import androidx.core.view.isVisible
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.lifecycleScope
-import androidx.lifecycle.repeatOnLifecycle
-import com.umc.ttoklip.R
-import com.umc.ttoklip.data.model.honeytip.ImageUrl
-import com.umc.ttoklip.data.model.town.CreateCommentRequest
-import com.umc.ttoklip.databinding.ActivityReadTogetherBinding
-import com.umc.ttoklip.presentation.base.BaseActivity
-import com.umc.ttoklip.presentation.hometown.adapter.TownCommentAdapter
-import com.umc.ttoklip.presentation.honeytip.ImageViewActivity
-import com.umc.ttoklip.presentation.honeytip.adapter.OnReadImageClickListener
-import com.umc.ttoklip.presentation.honeytip.adapter.ReadImageRVA
-import com.umc.ttoklip.presentation.honeytip.dialog.DeleteDialogFragment
-import com.umc.ttoklip.presentation.honeytip.dialog.ReportDialogFragment
-import dagger.hilt.android.AndroidEntryPoint
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.delay
-import kotlinx.coroutines.launch
-
-@AndroidEntryPoint
-class ReadTogetherActivity :
- BaseActivity(R.layout.activity_read_together),
- OnReadImageClickListener {
- private val viewModel: ReadTogetherViewModel by viewModels()
- private val imageAdapter: ReadImageRVA by lazy {
- ReadImageRVA(this, this@ReadTogetherActivity)
- }
- private val commentRVA by lazy {
- TownCommentAdapter({}, { commentId, reportRequest ->
- if (reportRequest != null) {
- viewModel.reportComment(commentId, reportRequest)
- } else {
- viewModel.deleteComment(commentId)
- }
- })
- }
- private var postId = 0L
-
- override fun initView() {
- binding.imageRv.adapter = imageAdapter
- binding.commentRv.adapter = commentRVA
- binding.vm = viewModel
- postId = intent.getLongExtra("postId", 0)
- viewModel.savePostId(postId)
- binding.reportBtn.bringToFront()
-
-
- binding.deleteBtn.setOnClickListener {
- val deleteDialog = DeleteDialogFragment()
- deleteDialog.setDialogClickListener(object : DeleteDialogFragment.DialogClickListener {
- override fun onClick() {
-
- }
- })
- deleteDialog.show(supportFragmentManager, deleteDialog.tag)
- }
- binding.backBtn.setOnClickListener {
- finish()
- }
-
- binding.dotBtn.setOnClickListener {
- binding.reportBtn.isVisible = binding.reportBtn.isVisible.not()
- }
-
- binding.reportBtn.setOnClickListener {
- val reportDialog = ReportDialogFragment()
- reportDialog.setDialogClickListener(object : ReportDialogFragment.DialogClickListener {
- override fun onClick(type: String, content: String) {
-
- }
-
- })
- reportDialog.show(supportFragmentManager, reportDialog.tag)
- }
-
-
- binding.cardView.setOnClickListener {
- CoroutineScope(Dispatchers.IO).launch {
- if (binding.commentEt.text.toString().isNotBlank()) {
- viewModel.createComment(
- CreateCommentRequest(
- binding.commentEt.text.toString(),
- 0L
- )
- )
- delay(500)
- viewModel.readTogether(postId)
- }
- }
- }
-
- }
-
- override fun initObserver() {
- with(lifecycleScope) {
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.joinState.collect {
- if (it.not()) {
- binding.joinBtn.background =
- getDrawable(R.drawable.rectangle_corner_10_strok_1_gray40)
-// binding.joinBtn.text = getString(R.string.cancel_join)
- } else {
- binding.joinBtn.background =
- getDrawable(R.drawable.yellow_btn_background)
-// binding.joinBtn.text = getString(R.string.join_together)
- }
- }
- }
- }
-
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.postId.collect {
- viewModel.readTogether(it)
- }
- }
- }
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.postContent.collect { response ->
- with(binding) {
- writerTv.text = response.writer
- titleT.text = response.title
- contentT.text = response.content
- totalPriceTv.text = response.totalPrice.toString()
- maxMemberTv.text = response.partyMax.toString()
- tradingPlaceTv.text = response.location
- openChatLinkTv.text = response.chatUrl
-
-
-
- imageAdapter.submitList(response.imageUrls.map { url ->
- ImageUrl(
- imageUrl = url.imageUrl
- )
- })
- commentRVA.submitList(response.commentResponses)
- val spannableAmount =
- SpannableString(
- getString(
- R.string.join_stat_format,
- response.partyCnt,
- response.partyMax
- )
- )
- spannableAmount.setSpan(
- ForegroundColorSpan(getColor(R.color.blue)),
- AMOUNT_STRING_START,
- response.partyCnt.toString().length + AMOUNT_STRING_LENGTH,
- SPANNABLE_FLAG_ZERO
- )
- binding.currentJoinStatTv.text = spannableAmount
- }
- }
- }
- }
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
-
- }
- }
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
-
- }
- }
- }
- }
-
- override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
- if (event?.action == MotionEvent.ACTION_DOWN) {
- val v = currentFocus
- if (v is EditText) {
- val outRect = Rect()
- v.getGlobalVisibleRect(outRect)
- if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) {
- v.clearFocus()
- val imm: InputMethodManager =
- getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
- imm.hideSoftInputFromWindow(v.getWindowToken(), 0)
- }
- }
- }
- return super.dispatchTouchEvent(event)
- }
-
- companion object {
- private const val AMOUNT_STRING_START = 0
- private const val SPANNABLE_FLAG_ZERO = 0
- private const val AMOUNT_STRING_LENGTH = 1
- }
-
- override fun onClick(imageUrl: String) {
- val images = imageAdapter.currentList.filterIsInstance().map { it.imageUrl }
- .toTypedArray()
- Log.d("images", images.toString())
- val intent = Intent(this, ImageViewActivity::class.java)
- intent.putExtra("images", images)
- startActivity(intent)
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/TradeLocationActivity.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/TradeLocationActivity.kt
index 25ca17cd..9103616c 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/TradeLocationActivity.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/TradeLocationActivity.kt
@@ -10,6 +10,7 @@ import com.umc.ttoklip.presentation.base.BaseActivity
import com.umc.ttoklip.presentation.hometown.adapter.OnRecentPlaceClickListener
import com.umc.ttoklip.presentation.hometown.adapter.RecentPlace
import com.umc.ttoklip.presentation.hometown.adapter.RecentlyUsedPlaceAdapter
+import com.umc.ttoklip.presentation.hometown.together.write.WriteTogetherActivity
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/adapter/TownCommentAdapter.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/adapter/TownCommentAdapter.kt
index 19891137..cdd64c3e 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/adapter/TownCommentAdapter.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/adapter/TownCommentAdapter.kt
@@ -9,7 +9,7 @@ import com.umc.ttoklip.data.model.town.CommentResponse
import com.umc.ttoklip.data.model.town.ReportRequest
import com.umc.ttoklip.databinding.ItemTownCommentBinding
import com.umc.ttoklip.databinding.ItemTownCommentReplyBinding
-import com.umc.ttoklip.presentation.honeytip.dialog.ReportDialogFragment
+import com.umc.ttoklip.presentation.dialog.ReportDialogFragment
class TownCommentAdapter(
val replyComment: (Long) -> Unit,
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/CommunicationActivity.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/CommunicationActivity.kt
similarity index 75%
rename from app/src/main/java/com/umc/ttoklip/presentation/hometown/CommunicationActivity.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/CommunicationActivity.kt
index 9963796f..44462e9c 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/CommunicationActivity.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/CommunicationActivity.kt
@@ -1,10 +1,11 @@
-package com.umc.ttoklip.presentation.hometown
+package com.umc.ttoklip.presentation.hometown.communication
import android.content.Intent
import androidx.activity.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
+import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import com.umc.ttoklip.R
import com.umc.ttoklip.data.model.town.Communities
@@ -13,6 +14,8 @@ import com.umc.ttoklip.presentation.alarm.AlarmActivity
import com.umc.ttoklip.presentation.base.BaseActivity
import com.umc.ttoklip.presentation.hometown.adapter.CommunicationAdapter
import com.umc.ttoklip.presentation.hometown.adapter.OnItemClickListener
+import com.umc.ttoklip.presentation.hometown.communication.read.ReadCommunicationActivity
+import com.umc.ttoklip.presentation.hometown.communication.write.WriteCommunicationActivity
import com.umc.ttoklip.presentation.mypage.SortSpinnerAdapter
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
@@ -21,7 +24,7 @@ import kotlinx.coroutines.launch
class CommunicationActivity :
BaseActivity(R.layout.activity_communication),
OnItemClickListener {
- private val adapter by lazy {
+ private val rva by lazy {
CommunicationAdapter(this)
}
private val viewModel: CommunicationViewModel by viewModels()
@@ -46,12 +49,25 @@ class CommunicationActivity :
- binding.communicationRv.layoutManager = LinearLayoutManager(this)
- binding.communicationRv.adapter = adapter
+ binding.communicationRv.apply {
+ adapter = adapter
+ layoutManager = LinearLayoutManager(this@CommunicationActivity)
+ adapter = rva
+ addItemDecoration(
+ DividerItemDecoration(
+ this@CommunicationActivity,
+ LinearLayoutManager.VERTICAL
+ )
+ )
+ }
binding.backBtn.setOnClickListener {
finish()
}
+ }
+
+ override fun onResume() {
+ super.onResume()
viewModel.getCommunities()
}
@@ -61,7 +77,7 @@ class CommunicationActivity :
launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.communities.collect {
- adapter.submitList(it)
+ rva.submitList(it)
}
}
}
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/CommunicationViewModel.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/CommunicationViewModel.kt
similarity index 77%
rename from app/src/main/java/com/umc/ttoklip/presentation/hometown/CommunicationViewModel.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/CommunicationViewModel.kt
index 25e7be7e..91349588 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/CommunicationViewModel.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/CommunicationViewModel.kt
@@ -1,4 +1,4 @@
-package com.umc.ttoklip.presentation.hometown
+package com.umc.ttoklip.presentation.hometown.communication
import com.umc.ttoklip.data.model.town.Communities
import kotlinx.coroutines.flow.StateFlow
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/CommunicationViewModelImpl.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/CommunicationViewModelImpl.kt
similarity index 84%
rename from app/src/main/java/com/umc/ttoklip/presentation/hometown/CommunicationViewModelImpl.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/CommunicationViewModelImpl.kt
index d7c8de2f..305ac453 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/CommunicationViewModelImpl.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/CommunicationViewModelImpl.kt
@@ -1,39 +1,37 @@
-package com.umc.ttoklip.presentation.hometown
-
-import android.util.Log
-import androidx.lifecycle.ViewModel
-import androidx.lifecycle.viewModelScope
-import com.umc.ttoklip.data.model.town.Communities
-import com.umc.ttoklip.data.repository.town.MainCommsRepository
-import com.umc.ttoklip.module.onError
-import com.umc.ttoklip.module.onException
-import com.umc.ttoklip.module.onFail
-import com.umc.ttoklip.module.onSuccess
-import dagger.hilt.android.lifecycle.HiltViewModel
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.flow.StateFlow
-import kotlinx.coroutines.launch
-import javax.inject.Inject
-
-@HiltViewModel
-class CommunicationViewModelImpl @Inject constructor(private val repository: MainCommsRepository) :
- ViewModel(), CommunicationViewModel {
- private val _communities = MutableStateFlow>(emptyList())
- override val communities: StateFlow>
- get() = _communities
-
- val isEnd = MutableStateFlow(false)
-
- val age = MutableStateFlow(1)
-
- override fun getCommunities() {
- viewModelScope.launch {
- repository.getComms().onSuccess {
- _communities.value = it.communities
- }.onError {
-
- }
- }
- }
+package com.umc.ttoklip.presentation.hometown.communication
+
+import android.util.Log
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import com.umc.ttoklip.data.model.town.Communities
+import com.umc.ttoklip.data.repository.town.MainCommsRepository
+import com.umc.ttoklip.module.onError
+import com.umc.ttoklip.module.onSuccess
+import dagger.hilt.android.lifecycle.HiltViewModel
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.launch
+import javax.inject.Inject
+
+@HiltViewModel
+class CommunicationViewModelImpl @Inject constructor(private val repository: MainCommsRepository) :
+ ViewModel(), CommunicationViewModel {
+ private val _communities = MutableStateFlow>(emptyList())
+ override val communities: StateFlow>
+ get() = _communities
+
+ val isEnd = MutableStateFlow(false)
+
+ val age = MutableStateFlow(1)
+
+ override fun getCommunities() {
+ viewModelScope.launch {
+ repository.getComms().onSuccess {
+ _communities.value = it.communities
+ Log.d("getComms", it.toString())
+ }.onError {
+
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/ReadCommunicationActivity.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/read/ReadCommunicationActivity.kt
similarity index 59%
rename from app/src/main/java/com/umc/ttoklip/presentation/hometown/ReadCommunicationActivity.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/read/ReadCommunicationActivity.kt
index 416a2353..c78c7634 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/ReadCommunicationActivity.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/read/ReadCommunicationActivity.kt
@@ -1,237 +1,276 @@
-package com.umc.ttoklip.presentation.hometown
-
-import android.content.Context
-import android.content.Intent
-import android.graphics.Rect
-import android.util.Log
-import android.view.MotionEvent
-import android.view.inputmethod.InputMethodManager
-import android.widget.EditText
-import androidx.activity.viewModels
-import androidx.core.view.isVisible
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.lifecycleScope
-import androidx.lifecycle.repeatOnLifecycle
-import com.umc.ttoklip.R
-import com.umc.ttoklip.data.model.honeytip.ImageUrl
-import com.umc.ttoklip.data.model.town.CreateCommentRequest
-import com.umc.ttoklip.data.model.town.ReportRequest
-import com.umc.ttoklip.databinding.ActivityReadCommunicationBinding
-import com.umc.ttoklip.presentation.base.BaseActivity
-import com.umc.ttoklip.presentation.hometown.adapter.TownCommentAdapter
-import com.umc.ttoklip.presentation.honeytip.ImageViewActivity
-import com.umc.ttoklip.presentation.honeytip.adapter.OnReadImageClickListener
-import com.umc.ttoklip.presentation.honeytip.adapter.ReadImageRVA
-import com.umc.ttoklip.presentation.honeytip.dialog.DeleteDialogFragment
-import com.umc.ttoklip.presentation.honeytip.dialog.ReportDialogFragment
-import dagger.hilt.android.AndroidEntryPoint
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.delay
-import kotlinx.coroutines.launch
-
-@AndroidEntryPoint
-class ReadCommunicationActivity :
- BaseActivity(R.layout.activity_read_communication),
- OnReadImageClickListener {
- private val commentRVA by lazy {
- TownCommentAdapter({}, { commentId, reportRequest ->
- if (reportRequest != null) {
- viewModel.reportComment(commentId, reportRequest)
- } else {
- viewModel.deleteComment(commentId)
- }
- })
- }
- private val imageAdapter: ReadImageRVA by lazy {
- ReadImageRVA(this, this@ReadCommunicationActivity)
- }
- private val viewModel: ReadCommunicationViewModel by viewModels()
- private var postId = 0L
-
- override fun initView() {
- binding.imageRv.adapter = imageAdapter
- binding.commentRv.adapter = commentRVA
- binding.reportBtn.bringToFront()
- postId = intent.getLongExtra("postId", 0)
- viewModel.savePostId(postId)
-
- binding.backBtn.setOnClickListener {
- finish()
- }
-
- binding.dotBtn.setOnClickListener {
- binding.reportBtn.isVisible = true
- }
-
- binding.reportBtn.setOnClickListener {
- val reportDialog = ReportDialogFragment()
- reportDialog.setDialogClickListener(object : ReportDialogFragment.DialogClickListener {
- override fun onClick(type: String, content: String) {
- viewModel.reportPost(ReportRequest(content = content, reportType = type))
- }
-
- })
- reportDialog.show(supportFragmentManager, reportDialog.tag)
- }
-
- binding.deleteBtn.setOnClickListener {
- val deleteDialog = DeleteDialogFragment()
- deleteDialog.setDialogClickListener(object : DeleteDialogFragment.DialogClickListener {
- override fun onClick() {
-
- }
- })
- deleteDialog.show(supportFragmentManager, deleteDialog.tag)
- }
-
- binding.cardView.setOnClickListener {
- if (binding.commentEt.text.toString().isNotBlank()) {
- CoroutineScope(Dispatchers.IO).launch {
- viewModel.createComment(
- CreateCommentRequest(
- binding.commentEt.text.toString(),
- 0L
- )
- )
- delay(500)
- viewModel.readCommunication(postId)
- }
- }
- }
-
- binding.scrapBtn.setOnClickListener {
- CoroutineScope(Dispatchers.IO).launch {
- viewModel.changeScrap()
- delay(500)
- viewModel.readCommunication(postId)
- }
- }
- binding.likeBtn.setOnClickListener {
- CoroutineScope(Dispatchers.IO).launch {
- viewModel.changeLike()
- delay(500)
- viewModel.readCommunication(postId)
- }
- }
-
- binding.editBtn.setOnClickListener {
-
- }
- }
-
- override fun initObserver() {
- with(lifecycleScope) {
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.postId.collect {
- if (it != 0L) {
- viewModel.readCommunication(it)
- }
- }
- }
- }
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.postContent.collect { response ->
- with(binding) {
- writerTv.text = response.writer
- titleTv.text = response.title
- contentT.text = response.content
-
-
- Log.d("image", response.imageUrls.toString())
- imageAdapter.submitList(response.imageUrls.map { url ->
- ImageUrl(url.imageUrl)
- })
- if (response.writer == " 1") {
- communityMenu.bringToFront()
- }
- likeT.text = response.likeCount.toString()
- bookmarkT.text = response.scrapCount.toString()
- commitT.text = response.commentCount.toString()
- if (response.likedByCurrentUser) {
- likeImg.setImageDrawable(getDrawable(R.drawable.ic_heart_on_20))
- } else {
- likeImg.setImageDrawable(getDrawable(R.drawable.ic_heart_off_20))
- }
- if (response.scrapedByCurrentUser) {
- bookmarkImg.setImageDrawable(getDrawable(R.drawable.ic_bookmark_on_20))
- } else {
- bookmarkImg.setImageDrawable(getDrawable(R.drawable.ic_bookmark_off_20))
- }
-// Log.d("comment", response.commentResponse.toString())
- commentRVA.submitList(response.commentResponses)
- }
- }
- }
- }
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.like.collect {
- if (it) {
- binding.likeImg.setImageDrawable(getDrawable(R.drawable.ic_heart_on_20))
- } else {
- binding.likeImg.setImageDrawable(getDrawable(R.drawable.ic_heart_off_20))
- }
- }
- }
- }
-
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.scrap.collect {
- if (it) {
- binding.bookmarkImg.setImageDrawable(getDrawable(R.drawable.ic_bookmark_on_20))
- } else {
- binding.bookmarkImg.setImageDrawable(getDrawable(R.drawable.ic_bookmark_off_20))
- }
- }
- }
- }
-
-
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.scrap.collect {
-
- }
- }
- }
- }
- }
-
- override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
- if (event?.action == MotionEvent.ACTION_DOWN) {
- val v = currentFocus
- if (v is EditText) {
- val outRect = Rect()
- v.getGlobalVisibleRect(outRect)
- if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) {
- v.clearFocus()
- val imm: InputMethodManager =
- getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
- imm.hideSoftInputFromWindow(v.getWindowToken(), 0)
- }
- }
- }
- return super.dispatchTouchEvent(event)
- }
-
- override fun onClick(imageUrl: String) {
- val images = imageAdapter.currentList.filterIsInstance().map { it.imageUrl }
- .toTypedArray()
- Log.d("images", images.toString())
- val intent = Intent(this, ImageViewActivity::class.java)
- intent.putExtra("images", images)
- startActivity(intent)
- }
-
- companion object {
- const val COMMUNICATION = "postId"
- fun newIntent(context: Context, id: Long) =
- Intent(context, ReadCommunicationActivity::class.java).apply {
- putExtra(COMMUNICATION, id)
- }
- }
+package com.umc.ttoklip.presentation.hometown.communication.read
+
+import android.content.Context
+import android.content.Intent
+import android.graphics.Rect
+import android.util.Log
+import android.view.MotionEvent
+import android.view.View
+import android.view.inputmethod.InputMethodManager
+import android.widget.EditText
+import android.widget.Toast
+import androidx.activity.viewModels
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.lifecycleScope
+import androidx.lifecycle.repeatOnLifecycle
+import com.umc.ttoklip.R
+import com.umc.ttoklip.TtoklipApplication
+import com.umc.ttoklip.data.model.honeytip.ImageUrl
+import com.umc.ttoklip.data.model.news.comment.NewsCommentResponse
+import com.umc.ttoklip.data.model.town.ReportRequest
+import com.umc.ttoklip.databinding.ActivityReadCommunicationBinding
+import com.umc.ttoklip.presentation.base.BaseActivity
+import com.umc.ttoklip.presentation.honeytip.ImageViewActivity
+import com.umc.ttoklip.presentation.honeytip.adapter.OnReadImageClickListener
+import com.umc.ttoklip.presentation.honeytip.adapter.ReadImageRVA
+import com.umc.ttoklip.presentation.dialog.DeleteDialogFragment
+import com.umc.ttoklip.presentation.dialog.ReportDialogFragment
+import com.umc.ttoklip.presentation.news.adapter.CommentRVA
+import com.umc.ttoklip.presentation.otheruser.OtherUserActivity
+import dagger.hilt.android.AndroidEntryPoint
+import kotlinx.coroutines.launch
+
+@AndroidEntryPoint
+class ReadCommunicationActivity :
+ BaseActivity(R.layout.activity_read_communication),
+ OnReadImageClickListener {
+ private val commentRVA by lazy {
+ CommentRVA({ id ->
+ viewModel.replyCommentParentId.value = id
+ }, { id, myComment ->
+ if (myComment) {
+ val deleteDialog = DeleteDialogFragment()
+ deleteDialog.setDialogClickListener(object :
+ DeleteDialogFragment.DialogClickListener {
+ override fun onClick() {
+ viewModel.deleteComment(id.toLong())
+ }
+ })
+ deleteDialog.show(supportFragmentManager, deleteDialog.tag)
+ } else {
+
+ val reportDialog = ReportDialogFragment()
+ reportDialog.setDialogClickListener(object :
+ ReportDialogFragment.DialogClickListener {
+ override fun onClick(type: String, content: String) {
+ viewModel.reportComment(
+ id.toLong(),
+ com.umc.ttoklip.data.model.honeytip.request.ReportRequest(
+ content = content,
+ reportType = type
+ )
+ )
+ }
+ })
+ reportDialog.show(supportFragmentManager, reportDialog.tag)
+ }
+ }, { nick ->
+ startActivity(OtherUserActivity.newIntent(this, nick))
+ })
+ }
+ private val imageAdapter: ReadImageRVA by lazy {
+ ReadImageRVA(this, this@ReadCommunicationActivity)
+ }
+ private val viewModel: ReadCommunicationViewModel by viewModels()
+ private var postId = 0L
+ private var isShowMenu = false
+
+ override fun initView() {
+ binding.vm = viewModel
+ binding.imageRv.apply {
+ adapter = imageAdapter
+ itemAnimator = null
+ }
+ binding.replyT.setOnClickListener {
+ viewModel.replyCommentParentId.value = 0
+ }
+ binding.commentRv.adapter = commentRVA
+ binding.reportBtn.bringToFront()
+ postId = intent.getLongExtra("postId", 0)
+ viewModel.savePostId(postId)
+
+ binding.backBtn.setOnClickListener {
+ finish()
+ }
+
+ binding.reportBtn.setOnClickListener {
+ val reportDialog = ReportDialogFragment()
+ reportDialog.setDialogClickListener(object : ReportDialogFragment.DialogClickListener {
+ override fun onClick(type: String, content: String) {
+ viewModel.reportPost(ReportRequest(content = content, reportType = type))
+ }
+
+ })
+ reportDialog.show(supportFragmentManager, reportDialog.tag)
+ }
+
+ binding.deleteBtn.setOnClickListener {
+ val deleteDialog = DeleteDialogFragment()
+ deleteDialog.setDialogClickListener(object : DeleteDialogFragment.DialogClickListener {
+ override fun onClick() {
+ viewModel.deleteCommunication()
+ finish()
+ }
+ })
+ deleteDialog.show(supportFragmentManager, deleteDialog.tag)
+ }
+
+ binding.SendCardView.setOnClickListener {
+ if (binding.commentEt.text.toString().isNotBlank()) {
+ viewModel.createComment()
+ }
+ binding.commentEt.setText("")
+ viewModel.replyCommentParentId.value = 0
+ }
+
+
+ binding.editBtn.setOnClickListener {
+
+ }
+ }
+
+ private fun showReportBtn() {
+ binding.dotBtn.setOnClickListener {
+ if (!isShowMenu) {
+ binding.reportBtn.bringToFront()
+ binding.reportBtn.visibility = View.VISIBLE
+ isShowMenu = true
+ } else {
+ binding.reportBtn.visibility = View.GONE
+ isShowMenu = false
+ }
+ }
+ }
+
+ private fun showWriterMenu() {
+ binding.dotBtn.setOnClickListener {
+ if (!isShowMenu) {
+ binding.communityMenu.bringToFront()
+ binding.communityMenu.visibility = View.VISIBLE
+ isShowMenu = true
+ } else {
+ binding.communityMenu.visibility = View.GONE
+ isShowMenu = false
+ }
+ }
+ }
+
+ override fun initObserver() {
+ with(lifecycleScope) {
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.postId.collect {
+ if (it != 0L) {
+ viewModel.readCommunication(it)
+ }
+ }
+ }
+ }
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.postContent.collect { response ->
+ with(binding) {
+ writerTv.text = response.writer
+ titleTv.text = response.title
+ contentT.text = response.content
+
+
+ Log.d("image", response.imageUrls.toString())
+ imageAdapter.submitList(response.imageUrls.map { url ->
+ ImageUrl(url.imageUrl)
+ })
+ if (response.writer == " 1") {
+ communityMenu.bringToFront()
+ }
+ likeT.text = response.likeCount.toString()
+ bookmarkT.text = response.scrapCount.toString()
+ commitT.text = response.commentCount.toString()
+
+ if (response.writer == TtoklipApplication.prefs.getString(
+ "nickname",
+ ""
+ )
+ ) {
+ showWriterMenu()
+ } else {
+ showReportBtn()
+ }
+ }
+ }
+ }
+ }
+
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.comments.collect {
+ val list = it.map { it ->
+ NewsCommentResponse(
+ it.commentContent,
+ it.commentId.toInt(),
+ it.parentId.toInt(),
+ it.writer,
+ it.writtenTime
+ )
+ }
+ commentRVA.submitList(list)
+ }
+ }
+ }
+
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.replyCommentParentId.collect { id ->
+ if (id == 0) {
+ binding.replyT.text = ""
+ } else {
+ binding.replyT.text = "@${id}"
+ }
+ }
+ }
+ }
+
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.toast.collect {
+ Toast.makeText(this@ReadCommunicationActivity, it, Toast.LENGTH_SHORT)
+ .show()
+ }
+ }
+ }
+ }
+ }
+
+ override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
+ if (event?.action == MotionEvent.ACTION_DOWN) {
+ val v = currentFocus
+ if (v is EditText) {
+ val outRect = Rect()
+ v.getGlobalVisibleRect(outRect)
+ if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) {
+ v.clearFocus()
+ val imm: InputMethodManager =
+ getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+ imm.hideSoftInputFromWindow(v.getWindowToken(), 0)
+ }
+ }
+ }
+ return super.dispatchTouchEvent(event)
+ }
+
+ override fun onClick(imageUrl: String) {
+ val images = imageAdapter.currentList.filterIsInstance().map { it.imageUrl }
+ .toTypedArray()
+ Log.d("images", images.toString())
+ val intent = Intent(this, ImageViewActivity::class.java)
+ intent.putExtra("images", images)
+ startActivity(intent)
+ }
+
+ companion object {
+ const val COMMUNICATION = "postId"
+ fun newIntent(context: Context, id: Long) =
+ Intent(context, ReadCommunicationActivity::class.java).apply {
+ putExtra(COMMUNICATION, id)
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/read/ReadCommunicationViewModel.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/read/ReadCommunicationViewModel.kt
new file mode 100644
index 00000000..9831b3ff
--- /dev/null
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/read/ReadCommunicationViewModel.kt
@@ -0,0 +1,36 @@
+package com.umc.ttoklip.presentation.hometown.communication.read
+
+import com.umc.ttoklip.data.model.town.ReportRequest
+import com.umc.ttoklip.data.model.town.ViewCommunicationResponse
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.SharedFlow
+import kotlinx.coroutines.flow.StateFlow
+
+interface ReadCommunicationViewModel {
+ val postId: StateFlow
+ val postContent: StateFlow
+ val like: StateFlow
+ val scrap: StateFlow
+ val replyCommentParentId : MutableStateFlow
+ val commentContent: MutableStateFlow
+ val comments: StateFlow>
+ val toast: SharedFlow
+ val toastEvent: SharedFlow
+
+ sealed class ToastEvent(){
+ object SuccessReportEvent: ToastEvent()
+ object FailReportEvent: ToastEvent()
+ }
+
+ fun eventToast(event: ToastEvent)
+ fun savePostId(postId: Long)
+ fun readCommunication(postId: Long)
+
+ fun deleteCommunication()
+ fun changeScrap()
+ fun changeLike()
+ fun reportPost(reportRequest: ReportRequest)
+ fun reportComment(commentId: Long, reportRequest: com.umc.ttoklip.data.model.honeytip.request.ReportRequest)
+ fun deleteComment(commentId: Long)
+ fun createComment()
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/ReadCommunicationViewModelImpl.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/read/ReadCommunicationViewModelImpl.kt
similarity index 55%
rename from app/src/main/java/com/umc/ttoklip/presentation/hometown/ReadCommunicationViewModelImpl.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/read/ReadCommunicationViewModelImpl.kt
index a0005481..287235ca 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/ReadCommunicationViewModelImpl.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/read/ReadCommunicationViewModelImpl.kt
@@ -1,4 +1,4 @@
-package com.umc.ttoklip.presentation.hometown
+package com.umc.ttoklip.presentation.hometown.communication.read
import android.util.Log
import androidx.lifecycle.ViewModel
@@ -9,9 +9,12 @@ import com.umc.ttoklip.data.model.town.ReportRequest
import com.umc.ttoklip.data.model.town.ViewCommunicationResponse
import com.umc.ttoklip.data.repository.town.ReadCommsRepository
import com.umc.ttoklip.module.onError
+import com.umc.ttoklip.module.onFail
import com.umc.ttoklip.module.onSuccess
import dagger.hilt.android.lifecycle.HiltViewModel
+import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject
@@ -54,6 +57,27 @@ class ReadCommunicationViewModelImpl @Inject constructor(
override val scrap: StateFlow
get() = _scrap
+ override val replyCommentParentId = MutableStateFlow(0)
+ override val commentContent = MutableStateFlow("")
+
+ private val _comments = MutableStateFlow(listOf())
+ override val comments: StateFlow>
+ get() = _comments
+
+ private val _toast = MutableSharedFlow()
+ override val toast: SharedFlow
+ get() = _toast
+
+ private val _toastEvent = MutableSharedFlow()
+ override val toastEvent: SharedFlow
+ get() = _toastEvent
+
+ override fun eventToast(event: ReadCommunicationViewModel.ToastEvent) {
+ viewModelScope.launch {
+ _toastEvent.emit(event)
+ }
+ }
+
override fun savePostId(postId: Long) {
_postId.value = postId
}
@@ -64,22 +88,38 @@ class ReadCommunicationViewModelImpl @Inject constructor(
_postContent.value = it
_like.value = it.likedByCurrentUser
_scrap.value = it.scrapedByCurrentUser
+ _comments.value = it.commentResponses
}.onError {
}
}
}
+ override fun deleteCommunication() {
+ viewModelScope.launch {
+ repository.deleteComms(_postId.value).onSuccess {
+ _toast.emit("게시글 삭제가 완료되었습니다.")
+ }
+ }
+ }
+
override fun changeScrap() {
Log.d("change", "스크랩")
_scrap.value = _scrap.value.not()
+ Log.d("scrap", scrap.value.toString())
viewModelScope.launch {
if (_scrap.value) {
repository.addCommsScrap(postId.value).onSuccess {
+ _postContent.emit(_postContent.value.copy().also {
+ it.scrapCount += 1
+ })
}
} else {
repository.cancelCommsScrap(postId.value).onSuccess {
Log.d("change", "스크랩")
+ _postContent.emit(_postContent.value.copy().also {
+ it.scrapCount -= 1
+ })
}
}
}
@@ -91,10 +131,15 @@ class ReadCommunicationViewModelImpl @Inject constructor(
viewModelScope.launch {
if (_like.value) {
repository.addCommsLike(postId.value).onSuccess {
+ _postContent.emit(_postContent.value.copy().also {
+ it.likeCount += 1
+ })
}
} else {
repository.cancelCommsLike(postId.value).onSuccess {
- Log.d("change", "좋아요")
+ _postContent.emit(_postContent.value.copy().also {
+ it.likeCount -= 1
+ })
}
}
}
@@ -103,27 +148,46 @@ class ReadCommunicationViewModelImpl @Inject constructor(
override fun reportPost(reportRequest: ReportRequest) {
viewModelScope.launch {
if (postId.value != 0L) {
- repository.reportComms(postId.value, reportRequest)
+ repository.reportComms(postId.value, reportRequest).onSuccess {
+ Log.d("report", it.toString())
+ _toast.emit("게시글 신고가 완료되었습니다.")
+ }.onFail {
+ _toast.emit("게시글 신고 타입을 설정해주세요.")
+ }
}
}
}
- override fun reportComment(commentId: Long, reportRequest: ReportRequest) {
+ override fun reportComment(
+ commentId: Long,
+ reportRequest: com.umc.ttoklip.data.model.honeytip.request.ReportRequest
+ ) {
viewModelScope.launch {
- repository.reportCommsComment(commentId, reportRequest)
+ repository.reportCommsComment(commentId, reportRequest).onSuccess {
+ _toast.emit("댓글 신고가 완료되었습니다.")
+ }.onFail {
+ _toast.emit("댓글 신고 타입을 설정해주세요.")
+ }
}
}
override fun deleteComment(commentId: Long) {
viewModelScope.launch {
- repository.deleteCommsComment(commentId)
+ repository.deleteCommsComment(commentId).onSuccess {
+ readCommunication(postId.value)
+ }
}
}
- override fun createComment(body: CreateCommentRequest) {
+ override fun createComment() {
viewModelScope.launch {
if (postId.value != 0L) {
- repository.createCommsComment(postId.value, body)
+ repository.createCommsComment(
+ postId.value,
+ CreateCommentRequest(commentContent.value, replyCommentParentId.value.toLong())
+ ).onSuccess {
+ readCommunication(postId.value)
+ }
}
}
}
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationActivity.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/write/WriteCommunicationActivity.kt
similarity index 89%
rename from app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationActivity.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/write/WriteCommunicationActivity.kt
index 25c84e13..76004768 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationActivity.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/write/WriteCommunicationActivity.kt
@@ -1,143 +1,136 @@
-package com.umc.ttoklip.presentation.hometown
-
-import android.content.Context
-import android.graphics.Rect
-import android.net.Uri
-import android.util.Log
-import android.view.MotionEvent
-import android.view.View
-import android.view.inputmethod.InputMethodManager
-import android.widget.EditText
-import androidx.activity.result.PickVisualMediaRequest
-import androidx.activity.result.contract.ActivityResultContracts
-import androidx.activity.viewModels
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.lifecycleScope
-import androidx.lifecycle.repeatOnLifecycle
-import com.umc.ttoklip.R
-import com.umc.ttoklip.databinding.ActivityWriteCommunicationBinding
-import com.umc.ttoklip.presentation.base.BaseActivity
-import com.umc.ttoklip.presentation.honeytip.adapter.Image
-import com.umc.ttoklip.presentation.honeytip.adapter.ImageRVA
-import com.umc.ttoklip.presentation.honeytip.dialog.ImageDialogFragment
-import dagger.hilt.android.AndroidEntryPoint
-import kotlinx.coroutines.launch
-
-@AndroidEntryPoint
-class WriteCommunicationActivity :
- BaseActivity(R.layout.activity_write_communication) {
- private val imageAdapter by lazy {
- ImageRVA(null)
- }
- private val viewModel: WriteCommunicationViewModel by viewModels()
- private val pickMultipleMedia = registerForActivityResult(
- ActivityResultContracts.PickMultipleVisualMedia(
- 100
- )
- ) { uris ->
- if (uris.isNotEmpty()) {
- updateImages(uris)
- } else {
- Log.d("PhotoPicker", "No media selected")
- }
- }
-
- override fun initView() {
- binding.vm = viewModel as WriteCommunicationViewModelImpl
- initImageRVA()
- addImage()
-
- binding.backBtn.setOnClickListener {
- finish()
- }
- }
-
- override fun initObserver() {
- with(lifecycleScope) {
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.doneButtonActivated.collect {
- binding.writeDoneBtn.isEnabled = it
- }
- }
- }
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.title.collect {
- viewModel.checkDone()
- }
- }
- }
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.content.collect {
- viewModel.checkDone()
- }
- }
- }
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.content.collect {
- viewModel.checkDone()
- }
- }
- }
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.images.collect {
- Log.d("uri image", it.toString())
- imageAdapter.submitList(it.toList())
- }
- }
- }
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.closePage.collect {
- Log.d("close page", it.toString())
- if (it) finish()
- }
- }
- }
- }
- }
-
- private fun initImageRVA() {
- binding.imageRv.adapter = imageAdapter
- }
-
- private fun addImage() {
- binding.addImageBtn.setOnClickListener {
- val imageDialog = ImageDialogFragment()
- imageDialog.setDialogClickListener(object : ImageDialogFragment.DialogClickListener {
- override fun onClick() {
- binding.imageRv.visibility = View.VISIBLE
- pickMultipleMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
- }
- })
- imageDialog.show(supportFragmentManager, imageDialog.tag)
- }
- }
-
- private fun updateImages(uriList: List) {
- Log.d("uri", uriList.toString())
- val images = uriList.map { Image(it) }
- viewModel.addImages(images)
- }
-
- override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
- if (event?.action == MotionEvent.ACTION_DOWN) {
- val v = currentFocus
- if (v is EditText) {
- val outRect = Rect()
- v.getGlobalVisibleRect(outRect)
- if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) {
- v.clearFocus()
- val imm: InputMethodManager =
- getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
- imm.hideSoftInputFromWindow(v.getWindowToken(), 0)
- }
- }
- }
- return super.dispatchTouchEvent(event)
- }
+package com.umc.ttoklip.presentation.hometown.communication.write
+
+import android.content.Context
+import android.graphics.Rect
+import android.net.Uri
+import android.util.Log
+import android.view.MotionEvent
+import android.view.View
+import android.view.inputmethod.InputMethodManager
+import android.widget.EditText
+import androidx.activity.result.PickVisualMediaRequest
+import androidx.activity.result.contract.ActivityResultContracts
+import androidx.activity.viewModels
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.lifecycleScope
+import androidx.lifecycle.repeatOnLifecycle
+import com.umc.ttoklip.R
+import com.umc.ttoklip.databinding.ActivityWriteCommunicationBinding
+import com.umc.ttoklip.presentation.base.BaseActivity
+import com.umc.ttoklip.presentation.honeytip.adapter.Image
+import com.umc.ttoklip.presentation.honeytip.adapter.ImageRVA
+import com.umc.ttoklip.presentation.dialog.ImageDialogFragment
+import dagger.hilt.android.AndroidEntryPoint
+import kotlinx.coroutines.launch
+
+@AndroidEntryPoint
+class WriteCommunicationActivity :
+ BaseActivity(R.layout.activity_write_communication) {
+ private val imageAdapter by lazy {
+ ImageRVA(this, null)
+ }
+ private val viewModel: WriteCommunicationViewModel by viewModels()
+ private val pickMultipleMedia = registerForActivityResult(
+ ActivityResultContracts.PickMultipleVisualMedia(
+ 100
+ )
+ ) { uris ->
+ if (uris.isNotEmpty()) {
+ updateImages(uris)
+ } else {
+ Log.d("PhotoPicker", "No media selected")
+ }
+ }
+
+ override fun initView() {
+ binding.vm = viewModel as WriteCommunicationViewModelImpl
+ initImageRVA()
+ addImage()
+
+ binding.backBtn.setOnClickListener {
+ finish()
+ }
+ }
+
+ override fun initObserver() {
+ with(lifecycleScope) {
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.doneButtonActivated.collect {
+ binding.writeDoneBtn.isEnabled = it
+ }
+ }
+ }
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.title.collect {
+ viewModel.checkDone()
+ }
+ }
+ }
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.content.collect {
+ viewModel.checkDone()
+ }
+ }
+ }
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.images.collect {
+ Log.d("uri image", it.toString())
+ imageAdapter.submitList(it.toList())
+ }
+ }
+ }
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.closePage.collect {
+ Log.d("close page", it.toString())
+ if (it) finish()
+ }
+ }
+ }
+ }
+ }
+
+ private fun initImageRVA() {
+ binding.imageRv.adapter = imageAdapter
+ }
+
+ private fun addImage() {
+ binding.addImageBtn.setOnClickListener {
+ val imageDialog = ImageDialogFragment()
+ imageDialog.setDialogClickListener(object : ImageDialogFragment.DialogClickListener {
+ override fun onClick() {
+ binding.imageRv.visibility = View.VISIBLE
+ pickMultipleMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
+ }
+ })
+ imageDialog.show(supportFragmentManager, imageDialog.tag)
+ }
+ }
+
+ private fun updateImages(uriList: List) {
+ Log.d("uri", uriList.toString())
+ val images = uriList.map { Image(it, "") }
+ viewModel.addImages(images)
+ }
+
+ override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
+ if (event?.action == MotionEvent.ACTION_DOWN) {
+ val v = currentFocus
+ if (v is EditText) {
+ val outRect = Rect()
+ v.getGlobalVisibleRect(outRect)
+ if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) {
+ v.clearFocus()
+ val imm: InputMethodManager =
+ getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+ imm.hideSoftInputFromWindow(v.getWindowToken(), 0)
+ }
+ }
+ }
+ return super.dispatchTouchEvent(event)
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationViewModel.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/write/WriteCommunicationViewModel.kt
similarity index 86%
rename from app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationViewModel.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/write/WriteCommunicationViewModel.kt
index ca2389e7..6d128850 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationViewModel.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/write/WriteCommunicationViewModel.kt
@@ -1,4 +1,4 @@
-package com.umc.ttoklip.presentation.hometown
+package com.umc.ttoklip.presentation.hometown.communication.write
import com.umc.ttoklip.presentation.honeytip.adapter.Image
import kotlinx.coroutines.flow.StateFlow
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationViewModelImpl.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/write/WriteCommunicationViewModelImpl.kt
similarity index 97%
rename from app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationViewModelImpl.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/write/WriteCommunicationViewModelImpl.kt
index 33b2af65..dfb3f967 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/WriteCommunicationViewModelImpl.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/communication/write/WriteCommunicationViewModelImpl.kt
@@ -1,4 +1,4 @@
-package com.umc.ttoklip.presentation.hometown
+package com.umc.ttoklip.presentation.hometown.communication.write
import android.content.Context
import android.util.Log
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/TogetherActivity.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/together/TogetherActivity.kt
similarity index 96%
rename from app/src/main/java/com/umc/ttoklip/presentation/hometown/TogetherActivity.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/hometown/together/TogetherActivity.kt
index 6cf90c40..9f31d893 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/TogetherActivity.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/together/TogetherActivity.kt
@@ -1,166 +1,168 @@
-package com.umc.ttoklip.presentation.hometown
-
-import android.content.Intent
-import android.util.Log
-import androidx.activity.viewModels
-import androidx.core.view.isGone
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.lifecycleScope
-import androidx.lifecycle.repeatOnLifecycle
-import androidx.recyclerview.widget.LinearLayoutManager
-import com.umc.ttoklip.R
-import com.umc.ttoklip.data.model.town.Togethers
-import com.umc.ttoklip.databinding.ActivityTogetherBinding
-import com.umc.ttoklip.presentation.alarm.AlarmActivity
-import com.umc.ttoklip.presentation.base.BaseActivity
-import com.umc.ttoklip.presentation.hometown.dialog.TogetherBottomSheetDialogFragment
-import com.umc.ttoklip.presentation.mypage.adapter.OnTogetherItemClickListener
-import com.umc.ttoklip.presentation.mypage.adapter.TransactionAdapter
-import dagger.hilt.android.AndroidEntryPoint
-import kotlinx.coroutines.launch
-
-@AndroidEntryPoint
-class TogetherActivity : BaseActivity(R.layout.activity_together),
- OnTogetherItemClickListener {
- private val viewModel: TogetherViewModel by viewModels()
- private val adapter by lazy {
- TransactionAdapter(this, this)
- }
-
- override fun initView() {
- binding.vm = viewModel
- binding.writeFab.setOnClickListener {
- val intent = Intent(this, WriteTogetherActivity::class.java)
- startActivity(intent)
- }
- binding.backBtn.setOnClickListener {
- finish()
- }
- viewModel.get()
-
- binding.noticeBtn.setOnClickListener {
- startActivity(AlarmActivity.newIntent(this))
- }
-
- binding.togetherRv.adapter = adapter
- binding.togetherRv.layoutManager = LinearLayoutManager(this)
- }
-
- override fun onStart() {
- super.onStart()
- Log.d("start", "start")
- }
- override fun onResume() {
- super.onResume()
- Log.d("resume", "resume")
- viewModel.get()
- }
-
- override fun initObserver() {
- with(lifecycleScope) {
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.showDialog.collect {
- if (it) {
- val sheet = TogetherBottomSheetDialogFragment { filter ->
- viewModel.getFilters(filter[0], filter[1])
- }
- sheet.show(supportFragmentManager, sheet.tag)
- }
- }
- }
- }
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.mainData.collect {
- adapter.submitList(it.carts)
- }
- }
- }
-
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.filterRequiredAmount.collect {
- binding.requiredAmount.isGone = false
- when (it) {
- 1L -> {
- binding.requiredAmount.text = "10,000"
- }
-
- 2L -> {
- binding.requiredAmount.text = "20,000"
- }
-
- 3L -> {
- binding.requiredAmount.text = "30,000"
- }
-
- 4L -> {
- binding.requiredAmount.text = "40,000"
- }
-
- 5L -> {
- binding.requiredAmount.text = "50,000 이상"
- }
-
- else -> {
- binding.requiredAmount.isGone = true
- }
- }
- }
- }
- }
-
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.filterMaxMember.collect {
- binding.maxMemberSizeTv.isGone = false
- when (it) {
- 1L -> {
- binding.maxMemberSizeTv.text = "2~4"
- }
-
- 2L -> {
- binding.maxMemberSizeTv.text = "5~7"
- }
-
- 3L -> {
- binding.maxMemberSizeTv.text = "8~10"
- }
-
- 4L -> {
- binding.maxMemberSizeTv.text = "11~13"
- }
-
- 5L -> {
- binding.maxMemberSizeTv.text = "14~17"
- }
-
- 6L -> {
- binding.maxMemberSizeTv.text = "18~20"
- }
-
- else -> {
- binding.maxMemberSizeTv.isGone = true
- }
- }
- }
- }
- }
- launch {
- repeatOnLifecycle(Lifecycle.State.STARTED) {
- viewModel.togethers.collect {
- adapter.submitList(it)
- }
- }
- }
- }
- }
-
- override fun onClick(together: Togethers) {
- val intent = Intent(this, ReadTogetherActivity::class.java)
- intent.putExtra("postId", together.id)
- startActivity(intent)
- }
-
+package com.umc.ttoklip.presentation.hometown.together
+
+import android.content.Intent
+import android.util.Log
+import androidx.activity.viewModels
+import androidx.core.view.isGone
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.lifecycleScope
+import androidx.lifecycle.repeatOnLifecycle
+import androidx.recyclerview.widget.LinearLayoutManager
+import com.umc.ttoklip.R
+import com.umc.ttoklip.data.model.town.Togethers
+import com.umc.ttoklip.databinding.ActivityTogetherBinding
+import com.umc.ttoklip.presentation.alarm.AlarmActivity
+import com.umc.ttoklip.presentation.base.BaseActivity
+import com.umc.ttoklip.presentation.hometown.dialog.TogetherBottomSheetDialogFragment
+import com.umc.ttoklip.presentation.hometown.together.read.ReadTogetherActivity
+import com.umc.ttoklip.presentation.hometown.together.write.WriteTogetherActivity
+import com.umc.ttoklip.presentation.mypage.adapter.OnTogetherItemClickListener
+import com.umc.ttoklip.presentation.mypage.adapter.TransactionAdapter
+import dagger.hilt.android.AndroidEntryPoint
+import kotlinx.coroutines.launch
+
+@AndroidEntryPoint
+class TogetherActivity : BaseActivity(R.layout.activity_together),
+ OnTogetherItemClickListener {
+ private val viewModel: TogetherViewModel by viewModels()
+ private val adapter by lazy {
+ TransactionAdapter(this, this)
+ }
+
+ override fun initView() {
+ binding.vm = viewModel
+ binding.writeFab.setOnClickListener {
+ val intent = Intent(this, WriteTogetherActivity::class.java)
+ startActivity(intent)
+ }
+ binding.backBtn.setOnClickListener {
+ finish()
+ }
+ viewModel.get()
+
+ binding.noticeBtn.setOnClickListener {
+ startActivity(AlarmActivity.newIntent(this))
+ }
+
+ binding.togetherRv.adapter = adapter
+ binding.togetherRv.layoutManager = LinearLayoutManager(this)
+ }
+
+ override fun onStart() {
+ super.onStart()
+ Log.d("start", "start")
+ }
+ override fun onResume() {
+ super.onResume()
+ Log.d("resume", "resume")
+ viewModel.get()
+ }
+
+ override fun initObserver() {
+ with(lifecycleScope) {
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.showDialog.collect {
+ if (it) {
+ val sheet = TogetherBottomSheetDialogFragment { filter ->
+ viewModel.getFilters(filter[0], filter[1])
+ }
+ sheet.show(supportFragmentManager, sheet.tag)
+ }
+ }
+ }
+ }
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.mainData.collect {
+ adapter.submitList(it.carts)
+ }
+ }
+ }
+
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.filterRequiredAmount.collect {
+ binding.requiredAmount.isGone = false
+ when (it) {
+ 1L -> {
+ binding.requiredAmount.text = "10,000"
+ }
+
+ 2L -> {
+ binding.requiredAmount.text = "20,000"
+ }
+
+ 3L -> {
+ binding.requiredAmount.text = "30,000"
+ }
+
+ 4L -> {
+ binding.requiredAmount.text = "40,000"
+ }
+
+ 5L -> {
+ binding.requiredAmount.text = "50,000 이상"
+ }
+
+ else -> {
+ binding.requiredAmount.isGone = true
+ }
+ }
+ }
+ }
+ }
+
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.filterMaxMember.collect {
+ binding.maxMemberSizeTv.isGone = false
+ when (it) {
+ 1L -> {
+ binding.maxMemberSizeTv.text = "2~4"
+ }
+
+ 2L -> {
+ binding.maxMemberSizeTv.text = "5~7"
+ }
+
+ 3L -> {
+ binding.maxMemberSizeTv.text = "8~10"
+ }
+
+ 4L -> {
+ binding.maxMemberSizeTv.text = "11~13"
+ }
+
+ 5L -> {
+ binding.maxMemberSizeTv.text = "14~17"
+ }
+
+ 6L -> {
+ binding.maxMemberSizeTv.text = "18~20"
+ }
+
+ else -> {
+ binding.maxMemberSizeTv.isGone = true
+ }
+ }
+ }
+ }
+ }
+ launch {
+ repeatOnLifecycle(Lifecycle.State.STARTED) {
+ viewModel.togethers.collect {
+ adapter.submitList(it)
+ }
+ }
+ }
+ }
+ }
+
+ override fun onClick(together: Togethers) {
+ val intent = Intent(this, ReadTogetherActivity::class.java)
+ intent.putExtra("postId", together.id)
+ startActivity(intent)
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/umc/ttoklip/presentation/hometown/TogetherViewModel.kt b/app/src/main/java/com/umc/ttoklip/presentation/hometown/together/TogetherViewModel.kt
similarity index 83%
rename from app/src/main/java/com/umc/ttoklip/presentation/hometown/TogetherViewModel.kt
rename to app/src/main/java/com/umc/ttoklip/presentation/hometown/together/TogetherViewModel.kt
index 4ed79a28..f14e2049 100644
--- a/app/src/main/java/com/umc/ttoklip/presentation/hometown/TogetherViewModel.kt
+++ b/app/src/main/java/com/umc/ttoklip/presentation/hometown/together/TogetherViewModel.kt
@@ -1,4 +1,4 @@
-package com.umc.ttoklip.presentation.hometown
+package com.umc.ttoklip.presentation.hometown.together
import com.umc.ttoklip.data.model.town.Togethers
import com.umc.ttoklip.data.model.town.TogethersResponse
@@ -11,7 +11,7 @@ interface TogetherViewModel {
val showDialog: SharedFlow
val page: StateFlow
val togethers: StateFlow