Anr snippets#986
Conversation
* Create ViewThreadingViolationSnippet.kt * Add snippet for switching to Dispatchers.Main in coroutines * Add snippet for View.registerCalledFromWrongThreadListener (API 37)
* Create ViewThreadingViolationSnippet.kt * Add snippet for switching to Dispatchers.Main in coroutines * Add snippet for View.registerCalledFromWrongThreadListener (API 37) # Conflicts: # misc/src/main/java/com/example/snippets/anr/ViewThreadingViolationSnippet.kt
|
Here is the summary of changes. You are about to add 2 region tags.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new Kotlin file, ViewThreadingViolationSnippet.kt, containing code snippets for handling view threading violations, such as switching context using coroutines and registering a CalledFromWrongThreadListener. The feedback suggests using Kotlin's native @Suppress annotation instead of the Java @SuppressWarnings annotation, and correcting the @RequiresApi annotation to target API level 35 instead of 37.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…tionSnippet.kt Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.example.snippets.anr |
There was a problem hiding this comment.
Hi Chansuk! Thanks for adding new snippets!
One comment: We're actually discouraging folks from adding to the misc module (because it's getting quite big as a catch-all for everything), and directing people to add to other more-specific modules instead.
What do you think about moving this to the existing "view" module in the snippets repo? you can add a new "anr" folder under there if you'd like.
https://github.com/android/snippets/tree/main/views/src/main/java
Other than that, the change looks good!
There was a problem hiding this comment.
SGTM. Will move to view module and send a new PR : )
Add anr package under misc to add snippets related ANR issues.