Text
Android Annotations co to ?
Android Annotations
Features
Dependency injection: inject views, extras, system services, resources, ...
Simplified threading model: annotate your methods so that they execute on the UI thread or on a background thread.
Event binding: annotate methods to handle events on views, no more ugly anonymous listener classes!
REST client: create a client interface, AndroidAnnotations generates the implementation.
No magic: As AndroidAnnotations generate subclasses at compile time, you can check the code to see how it works.
AndroidAnnotations provide those good things and even more for less than 150kb, without any runtime perf impact!
Is your Android code easy to write, read, and maintain?
Look at that:
@EActivity(R.layout.translate) // Sets content view to R.layout.translate public class TranslateActivity extends Activity { @ViewById // Injects R.id.textInput EditText textInput; @ViewById(R.id.myTextView) // Injects R.id.myTextView TextView result; @AnimationRes // Injects android.R.anim.fade_in Animation fadeIn; @Click // When R.id.doTranslate button is clicked void doTranslate() { translateInBackground(textInput.getText().toString()); } @Background // Executed in a background thread void translateInBackground(String textToTranslate) { String translatedText = callGoogleTranslate(textToTranslate); showResult(translatedText); } @UiThread // Executed in the ui thread void showResult(String translatedText) { result.setText(translatedText); result.startAnimation(fadeIn); } // [...] }
0 notes
Text
Siema świat
Tak ?
int i = 1; String textToShow = "Hello World"; Log.d(TAG, "start: = [ " + textToShow + " ], "+ "post = [ " + i + " ]");
Czy tak ?
int i = 1; String textToShow = "Hello World"; CLog.d(TAG, "start: ", textToShow, "post", i);
public class CLog { public static <T, S> void d(String TAG, String info, T t, String info2, S s) { String s1 = null; String s2 = null; if (t != null) s1 = t.toString(); if (s != null) s2 = s.toString(); Log.d(TAG, info + " = [" + s1 + "], " + info2 + " = [" + s2 + "]"); } }
1 note
·
View note