Skip to content

Instantly share code, notes, and snippets.

@novotnyr
Created April 18, 2021 23:33
Show Gist options
  • Save novotnyr/1cd160a7e67403277daac34dc28ec7f7 to your computer and use it in GitHub Desktop.
Save novotnyr/1cd160a7e67403277daac34dc28ec7f7 to your computer and use it in GitHub Desktop.
UINF/VMA Android - Appka Fotoriava
implementation 'androidx.activity:activity-ktx:1.2.2'
implementation 'androidx.fragment:fragment-ktx:1.3.2'
implementation 'com.otaliastudios:cameraview:2.7.0'
implementation 'com.squareup.picasso:picasso:2.71828'
-----
class GalleryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val icon: ImageView = itemView.findViewById(R.id.galleryImageView)
fun bind(item: GalleryItem) {
TODO("Dopracovat nacitanie obrazka")
}
}
object GalleryItemDiff : DiffUtil.ItemCallback<GalleryItem>() {
override fun areItemsTheSame(oldItem: GalleryItem, newItem: GalleryItem): Boolean {
return oldItem == newItem
}
override fun areContentsTheSame(oldItem: GalleryItem, newItem: GalleryItem): Boolean {
return oldItem == newItem
}
}
class GalleryAdapter : ListAdapter<GalleryItem, GalleryViewHolder>(GalleryItemDiff){
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GalleryViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.gallery_item, parent, false)
return GalleryViewHolder(view)
}
override fun onBindViewHolder(holder: GalleryViewHolder, position: Int) {
holder.bind(getItem(position))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment