Your SlideShare is downloading. ×
  • Like
Prez android annotations
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Prez android annotations

  • 1,418 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,418
On SlideShare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
10
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. AndroidAnnotations Simple and powerful Android code! sponsorisé par eBusiness Information, groupe Excilysjeudi 8 mars 12
  • 2. SPEAKERS • Pierre-Yves RICAU (@Piwai) • Alexandre THOMAS (@AleksThomas)jeudi 8 mars 12
  • 3. CE SOIR • Dev Android, les trucs pas sexy • AndroidAnnotations à la rescousse! • Live codingjeudi 8 mars 12
  • 4. ANDROIDjeudi 8 mars 12
  • 5. jeudi 8 mars 12
  • 6. APPLICATIONS SÉRIEUSESjeudi 8 mars 12
  • 7. Activity = God Objectjeudi 8 mars 12
  • 8. Activity = God Objectjeudi 8 mars 12
  • 9. POURQUOI ?jeudi 8 mars 12
  • 10. ASYNCTASK void doSomeCrazyStuff(Param param) { new AsyncTask<Param, Progress, Void>() { @Override protected Void doInBackground(Param... params) { Param myParam = params[0]; publishProgress(new Progress()); mySuperDownloader.downloadStuff(myParam); return null; } protected void onProgressUpdate(Progress... values) { Progress myProgress = values[0]; updateProgress(myProgress); }; protected void onPostExecute(Void result) { // ... }; }.execute(param); }jeudi 8 mars 12
  • 11. TextView myTextView = (TextView) findViewById(R.id.someId); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); findViewById(R.id.textView).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { handler.postDelayed(new Runnable() { @Override public void run() { // ... } }, 500); } });jeudi 8 mars 12
  • 12. ET SI VOTRE CODE RESSEMBLAIT À ÇA ?jeudi 8 mars 12
  • 13. SIMPLER VIEW HANDLING @EActivity(R.layout.main) public class EditActivity extends Activity { @ViewById(R.id.titleTextView) TextView title; @ViewById EditText editText; @AfterViews void initTitle() { title.setText("42"); } }jeudi 8 mars 12
  • 14. SIMPLER EVENT HANDLING @EActivity(R.layout.main) public class EditActivity extends Activity { @Click(R.id.downloadButton) void startDownloading() { } @Click void myButtonClicked() { } }jeudi 8 mars 12
  • 15. SIMPLER THREADING @EActivity(R.layout.main) public class EditActivity extends Activity { @Background void doSomeBackgroundWork() { } @UiThread void updateUI() { } }jeudi 8 mars 12
  • 16. REST CLIENT @Rest("http://www.stuff.com") public interface StuffClient { @Get("/stuff/{userId}?search={search}") Stuff getStuff(String search, String userId); @Post("/stuff/{userId}") void updateStuff(Stuff stuff, String userId); }jeudi 8 mars 12
  • 17. INJECTION DE DÉPENDANCES @EBean public class SomeBean { @Bean SomeOtherBean dependency1; }jeudi 8 mars 12
  • 18. TOUT ENSEMBLE! @EActivity(R.layout.main) public class EditActivity extends Activity { @ViewById EditText searchInput; @RestService RestClient restClient; @Bean Datastore datastore; @Click void downloadButtonClicked() { doSomeBackgroundWork(searchInput.getText().toString()); } @Background void doSomeBackgroundWork(String search) { Stuff stuff = restClient.getStuff(search); datastore.saveStuff(stuff); updateUI(stuff); } @UiThread void updateUI(Stuff stuff) { // Show stuff } }jeudi 8 mars 12
  • 19. TAKE THAT, ANDROID GOD!jeudi 8 mars 12
  • 20. COMMENT ? • Java 6 Annotation Processor • Génération de code à la compilation • Exécuter automatiquement par javac AndroidAnnotations Simple and powerful Android code!jeudi 8 mars 12
  • 21. SOUS-CLASSE GÉNÉRÉE public final class EditActivity_ extends EditActivity { // Ugly Android code goes here }jeudi 8 mars 12
  • 22. PIÈGES CLASSIQUES <activity android:name=".EditActivity_" /> startActivity(new Intent(this, EditActivity_.class)); EditActivity_.intent(this).start();jeudi 8 mars 12
  • 23. AVANTAGES • Compile time = no runtime overhead • Code debuggable & readable • No vendor lock-in!jeudi 8 mars 12
  • 24. OPEN SOURCEjeudi 8 mars 12
  • 25. PRODUCTIVITÉ VuzZz Quality of life, Geolocalized. Développée en 48hjeudi 8 mars 12
  • 26. CODE PROPRE Live coding! Nettoyage de printempsjeudi 8 mars 12
  • 27. QUESTIONS? • http://androidannotations.org • @AndAnnotationsjeudi 8 mars 12