• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Prez android annotations
 

Prez android annotations

on

  • 1,791 views

 

Statistics

Views

Total Views
1,791
Views on SlideShare
1,633
Embed Views
158

Actions

Likes
0
Downloads
9
Comments
0

1 Embed 158

http://www.paug.fr 158

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Prez android annotations Prez android annotations Presentation Transcript

    • AndroidAnnotations Simple and powerful Android code! sponsorisé par eBusiness Information, groupe Excilysjeudi 8 mars 12
    • SPEAKERS • Pierre-Yves RICAU (@Piwai) • Alexandre THOMAS (@AleksThomas)jeudi 8 mars 12
    • CE SOIR • Dev Android, les trucs pas sexy • AndroidAnnotations à la rescousse! • Live codingjeudi 8 mars 12
    • ANDROIDjeudi 8 mars 12
    • jeudi 8 mars 12
    • APPLICATIONS SÉRIEUSESjeudi 8 mars 12
    • Activity = God Objectjeudi 8 mars 12
    • Activity = God Objectjeudi 8 mars 12
    • POURQUOI ?jeudi 8 mars 12
    • 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
    • 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
    • ET SI VOTRE CODE RESSEMBLAIT À ÇA ?jeudi 8 mars 12
    • 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
    • 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
    • SIMPLER THREADING @EActivity(R.layout.main) public class EditActivity extends Activity { @Background void doSomeBackgroundWork() { } @UiThread void updateUI() { } }jeudi 8 mars 12
    • 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
    • INJECTION DE DÉPENDANCES @EBean public class SomeBean { @Bean SomeOtherBean dependency1; }jeudi 8 mars 12
    • 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
    • TAKE THAT, ANDROID GOD!jeudi 8 mars 12
    • 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
    • SOUS-CLASSE GÉNÉRÉE public final class EditActivity_ extends EditActivity { // Ugly Android code goes here }jeudi 8 mars 12
    • PIÈGES CLASSIQUES <activity android:name=".EditActivity_" /> startActivity(new Intent(this, EditActivity_.class)); EditActivity_.intent(this).start();jeudi 8 mars 12
    • AVANTAGES • Compile time = no runtime overhead • Code debuggable & readable • No vendor lock-in!jeudi 8 mars 12
    • OPEN SOURCEjeudi 8 mars 12
    • PRODUCTIVITÉ VuzZz Quality of life, Geolocalized. Développée en 48hjeudi 8 mars 12
    • CODE PROPRE Live coding! Nettoyage de printempsjeudi 8 mars 12
    • QUESTIONS? • http://androidannotations.org • @AndAnnotationsjeudi 8 mars 12