Skip to content
Back to skills

Android Xml Views

ASecurity

Use `ListAdapter`, which wraps `AsyncListDiffer`, and describe how items are identified and when their contents changed. Submit each new snapshot with `submitList()`: ```kotlin data class Post( val id: Long, val title: String, ) class PostAdapter( private val onClick: (Post) -> Unit, ) : ListAdapter<Post, PostAdapter.ViewHolder>(DIFF_CALLBACK) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val binding = ItemPostBinding.inflate( LayoutInflater.from(parent.con...

  • 584 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 5, 2026
developmentkotlin

Works with

  • cli

Security analysis

A100/100

Pro scans all 18 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill android-xml-views --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Android Xml Views?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Android Xml Views
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-android-xml-views-57b46013/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-android-xml-views-57b46013)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Replace `notifyDataSetChanged()` with `ListAdapter`

Use `ListAdapter`, which wraps `AsyncListDiffer`, and describe how items are identified and when their contents changed. Submit each new snapshot with `submitList()`:

```kotlin
data class Post(
    val id: Long,
    val title: String,
)

class PostAdapter(
    private val onClick: (Post) -> Unit,
) : ListAdapter<Post, PostAdapter.ViewHolder>(DIFF_CALLBACK) {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val binding = ItemPostBinding.inflate(
            LayoutInflater.from(parent.context),
            parent,
            false,
        )
        return ViewHolder(binding)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.bind(getItem(position))
    }

    inner class ViewHolder(
        private val binding: ItemPostBinding,
    ) : RecyclerView.ViewHolder(binding.root) {

        fun bind(post: Post) {
            binding.title.text = post.title
            binding.root.setOnClickListener { onClick(post) }
        }
    }

    companion object {
        private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<Post>() {
            override fun areItemsTheSame(oldItem: Post, newItem: Post): Boolean =
                oldItem.id == newItem.id

            override fun areContentsTheSame(oldItem: Post, newItem: Post): Boolean =
                oldItem == newItem
        }
    }
}
```

Update the adapter with a new, preferably immutable list:

```kotlin
adapter.submitList(postsFromRepository)
```

`areItemsTheSame` answers whether two rows represent the same entity; `areContentsTheSame` answers whether that entity's rendered content is unchanged. `ListAdapter` computes the difference asynchronously and dispatches only the required insert, remove, move, and change operations, so there is no need for—and you should not call—`notifyDataSetChanged()`. Avoid mutating a list after submitting it; create a new snapshot when items change.

Files in this skill

  • eval-1.baseline.md1.7 KB
  • eval-1.with-skill.md1.4 KB
  • eval-2.baseline.md2 KB
  • eval-2.with-skill.md2 KB
  • eval-3.baseline.md2.3 KB
  • eval-3.with-skill.md2.3 KB
  • trigger-1.md124 B
  • trigger-10.md137 B
  • trigger-11.md129 B
  • trigger-2.md120 B
  • trigger-3.md122 B
  • trigger-4.md129 B
  • trigger-5.md107 B
  • trigger-6.md115 B
  • trigger-7.md149 B
  • trigger-8.md152 B
  • trigger-9.md134 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.