Skip to content

Commit

Permalink
Merge pull request #260 from TeamDon-tBe/feature/#259-image-post
Browse files Browse the repository at this point in the history
[Feature/#259] 이미지 조회
  • Loading branch information
chanubc authored May 16, 2024
2 parents 7357b06 + 8fb49ea commit 0b21fde
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ interface HomeApiService {
const val V2 = "v2"
}

@GET("$API/$V1/$CONTENTS")
@GET("$API/$V2/$CONTENTS")
suspend fun getFeedList(
@Query(value = CURSOR) contentId: Long = -1,
): BaseResponse<List<ResponseFeedDto>>

@GET("/$API/$V2/$CONTENT/{$CONTENT_ID}/$DETAIL")
@GET("/$API/$V2/$CONTENT/{$CONTENT_ID}")
suspend fun getFeedDetail(
@Path(value = CONTENT_ID) contentId: Int,
): BaseResponse<ResponseFeedDto>

@GET("$API/$V1/$CONTENT/{$CONTENT_ID}/$COMMENTS")
@GET("$API/$V2/$CONTENT/{$CONTENT_ID}/$COMMENTS")
suspend fun getCommentList(
@Path(value = CONTENT_ID) contentId: Int,
@Query(value = CURSOR) commentId: Long = -1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import com.teamdontbe.data.dto.BaseResponse
import com.teamdontbe.data.dto.response.ResponseFeedDto
import com.teamdontbe.data.dto.response.ResponseMyPageCommentDto
import com.teamdontbe.data.dto.response.ResponseMyPageUserProfileDto
import com.teamdontbe.data_remote.api.HomeApiService.Companion.COMMENTS
import com.teamdontbe.data_remote.api.HomeApiService.Companion.CONTENTS
import com.teamdontbe.data_remote.api.HomeApiService.Companion.CURSOR
import com.teamdontbe.data_remote.api.HomeApiService.Companion.V2
import com.teamdontbe.data_remote.api.LoginApiService.Companion.API
import com.teamdontbe.data_remote.api.LoginApiService.Companion.V1
import retrofit2.http.GET
Expand All @@ -19,25 +22,23 @@ interface MyPageApiService {
const val MEMBER = "member"
const val MEMBER_DATA = "member-data"
const val MEMBER_ID = "memberId"
const val MEMBER_CONTENTS = "member-contents"
const val MEMBER_COMMENTS = "member-comments"
}

@GET("/$API/$V1/$VIEW_MEMBER/{$VIEW_MEMBER_ID}")
suspend fun getMyPageUserProfile(
@Path(VIEW_MEMBER_ID) viewMemberID: Int,
): BaseResponse<ResponseMyPageUserProfileDto>

@GET("/$API/$V1/$MEMBER/{$MEMBER_ID}/$MEMBER_CONTENTS")
@GET("/$API/$V2/$MEMBER/{$MEMBER_ID}/$CONTENTS")
suspend fun getMyPageFeedList(
@Path(MEMBER_ID) viewMemberID: Int,
@Query(CURSOR) cursor: Long = -1
@Query(CURSOR) cursor: Long = -1,
): BaseResponse<List<ResponseFeedDto>>

@GET("/$API/$V1/$MEMBER/{$MEMBER_ID}/$MEMBER_COMMENTS")
@GET("/$API/$V2/$MEMBER/{$MEMBER_ID}/$COMMENTS")
suspend fun getMyPageCommentList(
@Path(MEMBER_ID) viewMemberID: Int,
@Query(CURSOR) cursor: Long = -1
@Query(CURSOR) cursor: Long = -1,
): BaseResponse<List<ResponseMyPageCommentDto>>

@GET("/$API/$V1/$MEMBER_DATA")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data class ResponseCommentDto(
@SerialName("time") val time: String,
@SerialName("commentId") val commentId: Int,
@SerialName("isDeleted") val isDeleted: Boolean? = null,
@SerialName("commentImageUrl") val commentImageUrl: String? = null,
) {
fun toCommentEntity() =
CommentEntity(
Expand All @@ -30,6 +31,7 @@ data class ResponseCommentDto(
commentText,
time,
commentId,
isDeleted
isDeleted,
commentImageUrl = commentImageUrl,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ data class ResponseFeedDto(
@SerialName("likedNumber") val likedNumber: Int,
@SerialName("commentNumber") val commentNumber: Int,
@SerialName("isDeleted") val isDeleted: Boolean? = null,
@SerialName("contentImageUrl") val contentImageUrl: String? = null,
) {
fun toFeedEntity() =
FeedEntity(
Expand All @@ -33,5 +34,6 @@ data class ResponseFeedDto(
time,
contentId,
isDeleted,
contentImageUrl,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ data class ResponseMyPageCommentDto(
val commentId: Int,
@SerialName("contentId")
val contentId: Int,
@SerialName("commentImageUrl")
val commentImageUrl: String? = null,
) {
fun toMyPageCommentEntity() = CommentEntity(
memberId,
Expand All @@ -42,5 +44,6 @@ data class ResponseMyPageCommentDto(
commentId,
isDeleted = null,
contentId,
commentImageUrl = commentImageUrl,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ data class CommentEntity(
val commentId: Int,
val isDeleted: Boolean? = null,
val contentId: Int? = null,
val commentImageUrl: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ data class FeedEntity(
val time: String,
val contentId: Int? = null,
val isDeleted: Boolean? = null,
val contentImageUrl: String? = null,
)
9 changes: 6 additions & 3 deletions feature/src/main/java/com/teamdontbe/feature/home/Feed.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ data class Feed(
val contentText: String,
val time: String,
val contentId: Int? = null,
val isDeleted: Boolean? = null
val isDeleted: Boolean? = null,
val contentImageUrl: String? = null,
) : Parcelable {
constructor(feedEntity: FeedEntity) : this(
feedEntity.memberId,
Expand All @@ -31,7 +32,8 @@ data class Feed(
feedEntity.contentText,
feedEntity.time,
feedEntity.contentId,
feedEntity.isDeleted
feedEntity.isDeleted,
feedEntity.contentImageUrl,
)

fun toFeedEntity() =
Expand All @@ -47,6 +49,7 @@ data class Feed(
contentText,
time,
contentId,
isDeleted
isDeleted,
contentImageUrl,
)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.teamdontbe.feature.util

import android.content.Context
import android.widget.ImageView
import android.widget.TextView
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.databinding.BindingAdapter
import coil.load
import coil.transform.RoundedCornersTransformation
Expand Down Expand Up @@ -40,7 +41,7 @@ fun TextView.setTransparencyAndTimeText(data: Any?) {
text = context.getString(
R.string.tv_transparency,
data.memberGhost,
CalculateTime(context).getCalculateTime(data.time)
CalculateTime(context).getCalculateTime(data.time),
)
}
}
Expand All @@ -50,10 +51,19 @@ fun TextView.setTransparencyAndTimeText(data: Any?) {
text = context.getString(
R.string.tv_transparency,
data.memberGhost,
CalculateTime(context).getCalculateTime(data.time)
CalculateTime(context).getCalculateTime(data.time),
)
}
}
}
}

@BindingAdapter("setEmptyImageUrl")
fun ImageView.setEmptyImageUrl(img: String?) {
if (img.isNullOrEmpty()) {
this.isGone = true
} else {
this.isVisible = true
load(img)
}
}
19 changes: 17 additions & 2 deletions feature/src/main/res/layout/item_home_comment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1"
app:layout_constraintStart_toStartOf="@id/guide_comment_start_10"
app:layout_constraintTop_toBottomOf="@id/tv_comment_content"
app:shapeAppearance="@style/ShapeAppearanceOverlay.App.CornerSize50Percent" />

<androidx.appcompat.widget.AppCompatImageButton
Expand All @@ -171,7 +170,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_comment_content" />
app:layout_constraintTop_toBottomOf="@id/iv_home_feed_img" />

<TextView
android:id="@+id/tv_comment_like_num"
Expand All @@ -188,6 +187,22 @@
app:layout_constraintStart_toEndOf="@id/btn_comment_heart"
app:layout_constraintTop_toTopOf="@id/btn_comment_heart"
tools:text="544" />

<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv_home_feed_img"
setEmptyImageUrl="@{comment.commentImageUrl}"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:scaleType="centerCrop"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="@id/btn_comment_heart"
app:layout_constraintDimensionRatio="270:330"
app:layout_constraintEnd_toEndOf="@id/tv_comment_content"
app:layout_constraintStart_toStartOf="@id/tv_comment_content"
app:layout_constraintTop_toBottomOf="@id/tv_comment_content"
app:shapeAppearance="@style/ShapeAppearanceOverlay.App.CornerRadius4"
tools:background="@color/primary" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
20 changes: 18 additions & 2 deletions feature/src/main/res/layout/item_home_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1"
app:layout_constraintStart_toStartOf="@id/guide_home_start_10"
app:layout_constraintTop_toBottomOf="@id/tv_home_feed_content"
app:layout_constraintTop_toBottomOf="@id/iv_home_feed_img"
app:shapeAppearance="@style/ShapeAppearanceOverlay.App.CornerSize50Percent" />

<androidx.appcompat.widget.AppCompatImageButton
Expand Down Expand Up @@ -163,7 +163,7 @@
app:layout_constraintDimensionRatio="1"
app:layout_constraintEnd_toStartOf="@id/btn_home_comment"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintTop_toBottomOf="@id/tv_home_feed_content" />
app:layout_constraintTop_toBottomOf="@id/iv_home_feed_img" />

<TextView
android:id="@+id/tv_home_heart_num"
Expand All @@ -180,5 +180,21 @@
app:layout_constraintStart_toEndOf="@id/btn_home_heart"
app:layout_constraintTop_toTopOf="@id/btn_home_heart"
tools:text="541" />

<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv_home_feed_img"
setEmptyImageUrl="@{feed.contentImageUrl}"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:scaleType="centerCrop"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="@id/btn_home_heart"
app:layout_constraintDimensionRatio="270:330"
app:layout_constraintEnd_toEndOf="@id/tv_home_feed_content"
app:layout_constraintStart_toStartOf="@id/tv_home_feed_content"
app:layout_constraintTop_toBottomOf="@id/tv_home_feed_content"
app:shapeAppearance="@style/ShapeAppearanceOverlay.App.CornerRadius4"
tools:background="@color/primary" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
22 changes: 19 additions & 3 deletions feature/src/main/res/layout/item_my_page_comment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
imageUrl="@{feed.memberProfileUrl}"
android:layout_width="42dp"
android:layout_height="0dp"
android:background="@color/gray_9"
android:scaleType="centerCrop"
app:layout_constraintDimensionRatio="1"
app:layout_constraintStart_toStartOf="@id/guide_comment_start_10"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/ShapeAppearanceOverlay.App.CornerSize50Percent" />
app:shapeAppearance="@style/ShapeAppearanceOverlay.App.CornerSize50Percent"
tools:background="@color/gray_9" />

<TextView
android:id="@+id/tv_comment_user_name"
Expand Down Expand Up @@ -113,7 +113,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1"
app:layout_constraintStart_toStartOf="@id/guide_comment_start_10"
app:layout_constraintTop_toBottomOf="@id/tv_comment_content"
app:layout_constraintTop_toBottomOf="@id/iv_home_feed_img"
app:shapeAppearance="@style/ShapeAppearanceOverlay.App.CornerSize50Percent" />

<androidx.appcompat.widget.AppCompatImageButton
Expand Down Expand Up @@ -151,5 +151,21 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/btn_comment_heart"
tools:text="54" />

<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv_home_feed_img"
setEmptyImageUrl="@{feed.commentImageUrl}"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:scaleType="centerCrop"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="@id/iv_comment_ghost_fill_green"
app:layout_constraintDimensionRatio="270:330"
app:layout_constraintEnd_toEndOf="@id/tv_comment_content"
app:layout_constraintStart_toStartOf="@id/tv_comment_content"
app:layout_constraintTop_toBottomOf="@id/tv_comment_content"
app:shapeAppearance="@style/ShapeAppearanceOverlay.App.CornerRadius4"
tools:background="@color/primary" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
6 changes: 5 additions & 1 deletion feature/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
</style>

<style name="Theme.DontBe" parent="Base.Theme.DontBe" />

\
<style name="ShapeAppearanceOverlay.App.CornerSize50Percent" parent="">
<item name="cornerSize">50%</item>
</style>

<style name="ShapeAppearanceOverlay.App.CornerRadius4" parent="">
<item name="cornerSize">4dp</item>
</style>

<style name="Theme.DontBe.RemoveSplash" parent="Theme.DontBe">
<item name="android:windowIsTranslucent">true</item>
</style>
Expand Down

0 comments on commit 0b21fde

Please sign in to comment.