Skip to content

Commit 7ba3d73

Browse files
Merge pull request #39 from adenilsonricardo/feature/repository-list-adapter
Feature/repository list adapter
2 parents 9fc03f0 + ca85038 commit 7ba3d73

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

solutions/devsprint-bruno-almeida-1/app/src/main/java/com/devpass/githubapp/presentation/RepositoryCellItem.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.devpass.githubapp.presentation
22

3+
import android.view.View
34
import androidx.recyclerview.widget.RecyclerView
45
import com.bumptech.glide.Glide
56
import com.devpass.githubapp.data.model.Repository
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.devpass.githubapp.presentation
2+
3+
import android.view.LayoutInflater
4+
import android.view.ViewGroup
5+
import androidx.recyclerview.widget.RecyclerView
6+
import com.devpass.githubapp.R
7+
import com.devpass.githubapp.data.model.Repository
8+
import com.devpass.githubapp.databinding.RepositoryCellItemBinding
9+
10+
class RepositoryListAdapter(
11+
private val repositoryList : List<Repository>
12+
) : RecyclerView.Adapter<RepositoryCellItem>() {
13+
14+
override fun onCreateViewHolder(
15+
parent: ViewGroup, viewType: Int): RepositoryCellItem {
16+
val view = LayoutInflater.from(parent.context)
17+
.inflate(R.layout.repository_cell_item, parent, false)
18+
return RepositoryCellItem(RepositoryCellItemBinding.bind(view))
19+
}
20+
21+
override fun getItemCount(): Int {
22+
return repositoryList.size
23+
}
24+
25+
override fun onBindViewHolder(
26+
holder: RepositoryCellItem, position: Int) {
27+
holder.bind(repositoryList[position])
28+
}
29+
30+
}

0 commit comments

Comments
 (0)