-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feat/#33 emotion activity 구현
- Loading branch information
Showing
8 changed files
with
179 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/owori/android/presenter/main/home/adapter/EmotionAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.owori.android.presenter.main.home.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.owori.android.databinding.ItemEmotionBinding | ||
import com.owori.android.presenter.model.EmotionItem | ||
|
||
class EmotionAdapter(private val clickEvent: (emotionItem: EmotionItem) -> Unit = {}) : ListAdapter<EmotionItem, EmotionAdapter.ViewHolder>(EmotionItemDiffUtil()) { | ||
|
||
inner class ViewHolder(private val binding: ItemEmotionBinding) : RecyclerView.ViewHolder(binding.root) { | ||
fun bind(emotionItem: EmotionItem) { | ||
with(binding) { | ||
data = emotionItem | ||
emotionItemLayout.setOnClickListener { clickEvent(emotionItem) } | ||
} | ||
} | ||
} | ||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int | ||
): ViewHolder { | ||
val binding = ItemEmotionBinding.inflate(LayoutInflater.from(parent.context),parent,false) | ||
return ViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
holder.bind(getItem(position)) | ||
} | ||
} | ||
|
||
class EmotionItemDiffUtil : DiffUtil.ItemCallback<EmotionItem>(){ | ||
override fun areItemsTheSame(oldItem: EmotionItem, newItem: EmotionItem): Boolean { | ||
return oldItem.id == newItem.id | ||
} | ||
|
||
override fun areContentsTheSame(oldItem: EmotionItem, newItem: EmotionItem): Boolean { | ||
return oldItem.hashCode() == newItem.hashCode() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<vector android:autoMirrored="true" android:height="40dp" | ||
android:viewportHeight="40" android:viewportWidth="40" | ||
android:width="40dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#FA7B53" android:pathData="M16.668,26.951L32.477,11.143C33.127,10.492 34.183,10.492 34.834,11.143C35.485,11.794 35.485,12.849 34.834,13.5L17.846,30.487C17.195,31.138 16.14,31.138 15.489,30.487L5.573,20.571C4.922,19.92 4.922,18.865 5.573,18.214C6.224,17.563 7.279,17.563 7.93,18.214L16.668,26.951Z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters