Created
June 14, 2018 11:52
-
-
Save Marchuck/7be9593c5e9d89279b0d68a37a6834e7 to your computer and use it in GitHub Desktop.
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
class SwapiAdapter(diffCallback: DiffUtil.ItemCallback<Person?>) | |
: PagedListAdapter<Person, SwapiPersonViewHolder>(diffCallback) { | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SwapiPersonViewHolder { | |
val inflater = LayoutInflater.from(parent.context) | |
val binding = DataBindingUtil.inflate<ItemSwapiPersonBinding>( | |
inflater, R.layout.item_swapi_person, parent, false) | |
return SwapiPersonViewHolder(binding) | |
} | |
override fun onBindViewHolder(holder: SwapiPersonViewHolder, position: Int) { | |
val item = getItem(position) | |
holder.bind(item) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment