|
1 | 1 | <meta charset="utf-8">
|
2 |
| -(#) Use the support library AlertDialog instead of android.app.AlertDialog. |
| 2 | +(#) Use the support library AlertDialog instead of android.app.AlertDialog |
3 | 3 |
|
4 |
| -!!! WARNING: Use the support library AlertDialog instead of android.app.AlertDialog. |
| 4 | +!!! WARNING: Use the support library AlertDialog instead of android.app.AlertDialog |
5 | 5 | This is a warning.
|
6 | 6 |
|
7 | 7 | Id
|
8 | 8 | : `AlertDialogUsage`
|
9 | 9 | Summary
|
10 |
| -: Use the support library AlertDialog instead of android.app.AlertDialog. |
| 10 | +: Use the support library AlertDialog instead of android.app.AlertDialog |
11 | 11 | Severity
|
12 | 12 | : Warning
|
13 | 13 | Category
|
|
29 | 29 | : Kotlin and Java files
|
30 | 30 | Editing
|
31 | 31 | : This check runs on the fly in the IDE editor
|
| 32 | +Implementation |
| 33 | +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/main/kotlin/com/vanniktech/lintrules/android/AlertDialogUsageDetector.kt) |
| 34 | +Tests |
| 35 | +: [Source Code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/AlertDialogUsageDetectorTest.kt) |
32 | 36 |
|
33 | 37 | Support library AlertDialog is much more powerful and plays better
|
34 | 38 | together with the new theming / styling than the AlertDialog built into
|
35 | 39 | the framework.
|
36 | 40 |
|
| 41 | +(##) Example |
| 42 | + |
| 43 | +Here is an example of lint warnings produced by this check: |
| 44 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text |
| 45 | +src/Test.java:4:Warning: Should not be using android.app.AlertDialog |
| 46 | +[AlertDialogUsage] |
| 47 | + public Test(AlertDialog dialog) { } |
| 48 | + ------------------ |
| 49 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 50 | + |
| 51 | +Here is the source file referenced above: |
| 52 | + |
| 53 | +`src/Test.java`: |
| 54 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java linenumbers |
| 55 | +import android.app.AlertDialog; |
| 56 | + |
| 57 | +class Test { |
| 58 | + public Test(AlertDialog dialog) { } |
| 59 | +} |
| 60 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 61 | + |
| 62 | +You can also visit the |
| 63 | +[source code](https://github.com/vanniktech/lint-rules/tree/master/lint-rules-android-lint/src/test/kotlin/com/vanniktech/lintrules/android/AlertDialogUsageDetectorTest.kt) |
| 64 | +for the unit tests for this check to see additional scenarios. |
| 65 | + |
| 66 | +The above example was automatically extracted from the first unit test |
| 67 | +found for this lint check, `AlertDialogUsageDetector.constructorParameterInJava`. |
| 68 | +To report a problem with this extracted sample, visit |
| 69 | +https://github.com/vanniktech/lint-rules/issues. |
| 70 | + |
37 | 71 | (##) Including
|
38 | 72 |
|
39 | 73 | !!!
|
|
0 commit comments