From cd6d565b75f59824515c185add03d4d97487b72d Mon Sep 17 00:00:00 2001 From: moon0900 Date: Mon, 16 Dec 2024 23:08:08 +0900 Subject: [PATCH] fix: food history view --- .../beyoureyes/ui/myInfo/FoodHistoryAdapter.kt | 17 +---------------- .../dna/beyoureyes/ui/myInfo/FoodHistoryView.kt | 8 +++++--- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/dna/beyoureyes/ui/myInfo/FoodHistoryAdapter.kt b/app/src/main/java/com/dna/beyoureyes/ui/myInfo/FoodHistoryAdapter.kt index 9ca8209..6c3fb24 100644 --- a/app/src/main/java/com/dna/beyoureyes/ui/myInfo/FoodHistoryAdapter.kt +++ b/app/src/main/java/com/dna/beyoureyes/ui/myInfo/FoodHistoryAdapter.kt @@ -9,17 +9,13 @@ class FoodHistoryAdapter( private val onItemClickListener: (FoodHistory) -> Unit) : RecyclerView.Adapter() { - init { - sortItems() - } - // 뷰 홀더 생성 inner class FoodHistoryViewHolder(val historyView: FoodHistoryView) : RecyclerView.ViewHolder(historyView) { fun bind(history: FoodHistory) { historyView.setData(history.timestamp, history.kcal, history.imgUri) - historyView.setOnClickListener{ onItemClickListener(history) } + historyView.cardView.setOnClickListener{ onItemClickListener(history) } } } @@ -36,15 +32,4 @@ class FoodHistoryAdapter( override fun getItemCount() = items.size - // 데이터 업데이트 시 정렬 - fun updateItems(newItems: List) { - sortItems(newItems) - notifyDataSetChanged() - } - - // 데이터 정렬 - private fun sortItems(newItems: List = items) { - - } - } \ No newline at end of file diff --git a/app/src/main/java/com/dna/beyoureyes/ui/myInfo/FoodHistoryView.kt b/app/src/main/java/com/dna/beyoureyes/ui/myInfo/FoodHistoryView.kt index 64bcf10..3d0f4d2 100644 --- a/app/src/main/java/com/dna/beyoureyes/ui/myInfo/FoodHistoryView.kt +++ b/app/src/main/java/com/dna/beyoureyes/ui/myInfo/FoodHistoryView.kt @@ -6,6 +6,7 @@ import android.net.Uri import android.util.AttributeSet import android.util.Log import android.view.LayoutInflater +import android.widget.FrameLayout import android.widget.ImageView import android.widget.TextView import androidx.cardview.widget.CardView @@ -21,19 +22,20 @@ import java.text.SimpleDateFormat import java.util.Locale class FoodHistoryView(context: Context, attrs: AttributeSet?) : - CardView(context, attrs) { + FrameLayout(context, attrs) { // 뷰 컴포넌트들을 클래스 속성으로 정의 private val historyImg : ImageView private val historyLabel : TextView private val kcalTextView : TextView + val cardView: CardView init { // Bar View의 XML 레이아웃을 인플레이트 LayoutInflater.from(context).inflate(R.layout.food_history_item, this, true) // 레이아웃 파라미터 설정 layoutParams = ConstraintLayout.LayoutParams( - ConstraintLayout.LayoutParams.MATCH_PARENT, + ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT ) @@ -41,7 +43,7 @@ class FoodHistoryView(context: Context, attrs: AttributeSet?) : historyImg = findViewById(R.id.imageView) historyLabel = findViewById(R.id.label) kcalTextView = findViewById(R.id.kcal) - + cardView = findViewById(R.id.cardView) // attrs 입력값 속성 처리 attrs?.let{