Skip to content

Commit

Permalink
[REFACTOR/#3] 멀티 뷰 아이템 이름 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeha committed Apr 23, 2023
1 parent e51dd69 commit 13cf905
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ object DataSources {

fun loadHomeDataSet(): ArrayList<MultiViewItem> {
val multiViewItems = arrayListOf<MultiViewItem>().apply {
add(MultiViewItem.TextItem("하은의 레포지토리"))
add(MultiViewItem.Header("하은의 레포지토리"))

for (i in 1..HOME_ITEM_NUM) {
add(
MultiViewItem.ImageItem(
MultiViewItem.Repo(
R.drawable.ic_launcher_background,
"name $i",
"author $i"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.android.go.sopt.ui.main.gallery.adapter

import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,4 @@ class MultiViewAdapter(
override fun getItemViewType(position: Int): Int {
return itemList[position].getViewType().ordinal
}

fun scrollToTop() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ sealed class MultiViewHolder<E : MultiViewItem>(

class TextViewHolder(
private val binding: ItemTextBinding
) : MultiViewHolder<MultiViewItem.TextItem>(binding) {
override fun bind(item: MultiViewItem.TextItem) {
) : MultiViewHolder<MultiViewItem.Header>(binding) {
override fun bind(item: MultiViewItem.Header) {
binding.title = item.title
}
}

class ImageViewHolder(
private val binding: ItemImageBinding
) : MultiViewHolder<MultiViewItem.ImageItem>(binding) {
override fun bind(item: MultiViewItem.ImageItem) {
) : MultiViewHolder<MultiViewItem.Repo>(binding) {
override fun bind(item: MultiViewItem.Repo) {
with(binding){
ivImage.setImageResource(item.imageRes)
name = item.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import androidx.annotation.DrawableRes
sealed class MultiViewItem(
private val viewType: MultiViewType
) {
data class TextItem(val title: String) : MultiViewItem(MultiViewType.TEXT)
data class Header(val title: String) : MultiViewItem(MultiViewType.TEXT)

data class ImageItem(
data class Repo(
@DrawableRes val imageRes: Int,
val name: String,
val author: String
Expand Down

0 comments on commit 13cf905

Please sign in to comment.