|
1 | 1 |
|
2 | 2 |
|
3 | | - |
4 | 3 | "_The ratio of time spent reading [code] versus writing is well over 10 to 1 [therefore] making it easy to read makes it easier to write._" - **Robert C. Martin** |
5 | 4 |
|
6 | | -#Is your Android code easy to write, read, and maintain? |
7 | | - |
8 | | -```java |
9 | | -@EActivity(R.layout.translate) // Sets content view to R.layout.translate |
10 | | -public class TranslateActivity extends Activity { |
11 | | - |
12 | | - @ViewById // Injects R.id.textInput |
13 | | - EditText textInput; |
14 | | - |
15 | | - @ViewById(R.id.myTextView) // Injects R.id.myTextView |
16 | | - TextView result; |
17 | 5 |
|
18 | | - @AnimationRes // Injects android.R.anim.fade_in |
19 | | - Animation fadeIn; |
20 | 6 |
|
21 | | - @Click // When R.id.doTranslate button is clicked |
22 | | - void doTranslate() { |
23 | | - translateInBackground(textInput.getText().toString()); |
24 | | - } |
| 7 | +## Test [](https://github.com/excilys/androidannotations/wiki/Home) test |
25 | 8 |
|
26 | | - @Background // Executed in a background thread |
27 | | - void translateInBackground(String textToTranslate) { |
28 | | - String translatedText = callGoogleTranslate(textToTranslate); |
29 | | - showResult(translatedText); |
30 | | - } |
31 | | - |
32 | | - @UiThread // Executed in the ui thread |
33 | | - void showResult(String translatedText) { |
34 | | - result.setText(translatedText); |
35 | | - result.startAnimation(fadeIn); |
36 | | - } |
37 | | - |
38 | | - // [...] |
39 | | -} |
40 | | -``` |
41 | | - |
42 | | -AndroidAnnotations provide those good things for **less than 50kb**, without any [perf impact](https://github.com/excilys/androidannotations/wiki/FAQ#wiki-perf-impact)! |
43 | 9 |
|
44 | 10 | [](https://github.com/excilys/androidannotations/wiki/GettingStarted) | [**Get Started**](https://github.com/excilys/androidannotations/wiki/GettingStarted), then [**read the cookbook**](https://github.com/excilys/androidannotations/wiki/Cookbook) | |
45 | 11 | -----------|---------------| |
46 | 12 |
|
47 | 13 |
|
48 | 14 |
|
49 | | -*** |
50 | | -The project logo is based on the [Android logo](http://upload.wikimedia.org/wikipedia/commons/d/d7/Android_robot.svg), created and [shared by Google](http://code.google.com/policies.html) and used according to terms described in the [Creative Commons 3.0 Attribution License](http://creativecommons.org/licenses/by/3.0/). |
51 | | - |
52 | | -Android is a trademark of Google Inc. Use of this trademark is subject to [Google Permissions](http://www.google.com/permissions/index.html). |
0 commit comments