Skip to content

Commit

Permalink
[develop]: 후기에 사진 보이도록 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
soopeach committed Mar 13, 2024
1 parent 4c1888d commit 64b50bc
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.gdsc.presentation.view.mypage.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
Expand All @@ -26,6 +27,14 @@ class RestaurantReviewAdapter(

tvNickname.text = item.userName
tvContent.text = item.reviewContent

if (item.reviewImages.isEmpty()) {
rvReviewImages.visibility = View.GONE
} else {
rvReviewImages.adapter = ReviewImageAdapter().apply {
submitList(item.reviewImages)
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.gdsc.presentation.view.mypage.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import org.gdsc.presentation.databinding.ItemReviewImageBinding

class ReviewImageAdapter() :
ListAdapter<String, ReviewImageAdapter.ReviewImageViewHolder>(
diffUtil
) {
inner class ReviewImageViewHolder(private val binding: ItemReviewImageBinding) :
RecyclerView.ViewHolder(binding.root) {

fun bind(url: String) {

Glide.with(binding.root)
.load(url)
.into(binding.image)
}
}

companion object {
val diffUtil = object : DiffUtil.ItemCallback<String>() {
override fun areItemsTheSame(oldItem: String, newItem: String): Boolean {
return oldItem == newItem
}

override fun areContentsTheSame(oldItem: String, newItem: String): Boolean {
return oldItem == newItem
}
}
}

override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): ReviewImageViewHolder {
val inflater = LayoutInflater.from(parent.context)
return ReviewImageViewHolder(
ItemReviewImageBinding.inflate(
inflater,
parent,
false
)
)
}

override fun onBindViewHolder(holder: ReviewImageViewHolder, position: Int) {
holder.apply {
bind(getItem(position))
}
}
}
19 changes: 19 additions & 0 deletions presentation/src/main/res/layout/item_review_image.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingEnd="2dp"
xmlns:app="http://schemas.android.com/apk/res-auto">

<org.gdsc.presentation.view.custom.FlexibleCornerImageView
android:id="@+id/image"
android:layout_width="48dp"
android:layout_height="48dp"
app:all_corner_radius="4dp"
android:scaleType="centerCrop"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
66 changes: 37 additions & 29 deletions presentation/src/main/res/layout/item_review_restaurant.xml
Original file line number Diff line number Diff line change
@@ -1,69 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/bg_rounded_border_12_grey200"
android:padding="16dp"
android:layout_marginTop="16dp">
android:padding="16dp">

<ImageView
android:id="@+id/iv_profile"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/mock_profile"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="@drawable/mock_profile"/>
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tv_nickname"
style="@style/text_medium_medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@id/iv_profile"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="6dp"
style="@style/text_medium_medium"
android:textColor="@color/grey900"
tools:text="권나무방구뿡뿡"/>
app:layout_constraintStart_toEndOf="@id/iv_profile"
app:layout_constraintTop_toTopOf="parent"
tools:text="권나무방구뿡뿡" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_review_images"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_nickname"
tools:layout_height="48dp" />

<TextView
android:id="@+id/tv_content"
style="@style/text_medium_medium"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_profile"
android:layout_marginTop="6dp"
style="@style/text_medium_medium"
android:textColor="@color/grey900"
tools:text="와 정말 맛있더군요 여기 안가면 바보입니다 하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하"/>
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rv_review_images"
tools:text="와 정말 맛있더군요 여기 안가면 바보입니다 하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하하" />


<TextView
style="@style/text_small_medium"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/iv_thumb_up"
app:layout_constraintTop_toBottomOf="@id/tv_content"
app:layout_constraintBottom_toBottomOf="parent"
android:text="리뷰가 도움이 됐어요"
android:layout_marginEnd="4dp"
android:layout_marginTop="8dp"
style="@style/text_small_medium"
android:layout_marginEnd="4dp"
android:text="리뷰가 도움이 됐어요"
android:textColor="@color/grey500"
/>
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_thumb_up"
app:layout_constraintTop_toBottomOf="@id/tv_content" />

<ImageView
android:id="@+id/iv_thumb_up"
android:src="@drawable/ic_thumb_up"
android:layout_width="16dp"
android:layout_height="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_content"
android:layout_marginTop="8dp"
/>


android:src="@drawable/ic_thumb_up"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_content" />


</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 64b50bc

Please sign in to comment.