Skip to content

Commit

Permalink
위시 리스트 recycler view ing 위치 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
codeSweet0828 committed Jan 23, 2024
1 parent 6268739 commit 349884d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
22 changes: 18 additions & 4 deletions app/src/main/java/com/wish/bunny/wish/CustomAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.wish.bunny.R
import com.wish.bunny.wish.domain.WishItem
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit

class CustomAdapter(private val context: Context, private val wishItemList: List<WishItem>) :
RecyclerView.Adapter<CustomAdapter.ViewHolder>() {
Expand All @@ -28,17 +31,28 @@ class CustomAdapter(private val context: Context, private val wishItemList: List
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val content = itemView.findViewById<TextView>(R.id.rv_content)
private val dDay = itemView.findViewById<TextView>(R.id.rv_dDay)
private val tag1 = itemView.findViewById<TextView>(R.id.rv_tag1)

fun bind(wishItem: WishItem) {
content.text = wishItem.content
dDay.text = calculateDDay(wishItem.deadlineDt)
tag1.text = wishItem.tagContents
//content.text = wishItem.wishNo
// dDay 설정 등 필요한 데이터 설정
// 예시: dDay.text = "D-${calculateDDay(wishItem.deadlineDt)}"
}

// 예시: private fun calculateDDay(deadlineDt: String): Int {
// 예시: // D-Day를 계산하는 로직을 작성하세요.
// 예시: return 0
// 예시: }
private fun calculateDDay(deadlineDt: String): String {
val dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val targetDate = LocalDate.parse(deadlineDt, dateFormatter)

//현재날짜
val currentDate = LocalDate.now()

//남은 일수 계산
val daysRemaining = ChronoUnit.DAYS.between(currentDate, targetDate)

return "D-${daysRemaining.toString()}"
}
}
}
14 changes: 11 additions & 3 deletions app/src/main/res/layout/activity_wish_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
android:text="토리 님의 버킷리스트"
android:textSize="30dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -34,9 +33,18 @@
android:padding="10dp"
android:radius="8dp"
/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/wishList_recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/wishList_recyclerView"/>
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button"
app:layout_constraintVertical_bias="1.0"
/>


</androidx.constraintlayout.widget.ConstraintLayout>
8 changes: 4 additions & 4 deletions app/src/main/res/layout/item_wish.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@
android:id="@+id/rv_tag1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#운동"
android:text="tags1"
android:layout_marginLeft="10dp"
android:textSize="20dp"
android:textColor="@color/activePink"
/>
<TextView
<!-- <TextView
android:id="@+id/rv_tag2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#다이어트"
android:text=""
android:layout_marginLeft="5dp"
android:textSize="18dp"
android:textColor="@color/activePink"
/>
/>-->
</LinearLayout>
</LinearLayout>

Expand Down

0 comments on commit 349884d

Please sign in to comment.