evolución android - droidconmad 2014
TRANSCRIPT
![Page 1: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/1.jpg)
Evolución Android Del framework a la supervivencia del
más fuerte
![Page 2: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/2.jpg)
1. Origen 2. Extinción 3. Evolución
Agenda
![Page 3: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/3.jpg)
1. Origen
![Page 4: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/4.jpg)
Rubén Serrano Núñez (@Akelael) Lead Android Developer @RedboothHQ
![Page 5: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/5.jpg)
![Page 6: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/6.jpg)
Redbooth Beta Redbooth
![Page 7: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/7.jpg)
WTF!
![Page 8: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/8.jpg)
Creacionista
![Page 9: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/9.jpg)
![Page 10: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/10.jpg)
Evolucionista
![Page 11: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/11.jpg)
![Page 12: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/12.jpg)
¿Creacionistas vs
Evolucionistas?
![Page 13: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/13.jpg)
“It’s the maintenance!”
![Page 14: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/14.jpg)
2. Extinción
![Page 15: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/15.jpg)
All-in-one Application
![Page 16: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/16.jpg)
public class Application extends android.app.Application { private static Gson gson; private Map<Long, Integer> mRoles; private Session mSession; private File mCacheDir; private NotificationManager mNotificationManager; private int mNumberNotifications; ! public static Session getSession() { return instance.mSession; }
public static String getGCMToken() { AccountManager am = AccountManager.get(Application.getContext()); return am.getUserData(Application.getSession().getUser(), AccountAuthenticator.GCM_TOKEN); } public static File getCacheDirectory() { return instance.mCacheDir; }
![Page 17: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/17.jpg)
Lo puse todo en Application y …
¡Quita eso de ahí, guarro!
![Page 18: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/18.jpg)
Ahora si, ahora no
![Page 19: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/19.jpg)
Ahora si, ahora no: Relative Layout
![Page 20: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/20.jpg)
Ahora si, ahora no:
Enums vs Static Final Fields
![Page 21: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/21.jpg)
Ahora si, ahora no: ViewHolder
![Page 22: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/22.jpg)
private static class ViewHolder { public TextView textView; public ImageView imageView; } !@Overridepublic View getView(int position, View convertView, ViewGroup parent) { View view = convertView; ViewHolder viewHolder; if (view == null) { view = inflater.inflate(R.layout.item, parent, false); viewHolder = new ViewHolder(); viewHolder.textView = (TextView) view.findViewById(R.id.text); viewHolder.imageView = (ImageView) view.findViewById(R.id.image); view.setTag(viewHolder); } viewHolder = (ViewHolder) view.getTag(); viewHolder.textView.setText("Random string"); viewHolder.imageView.setBackgroundColor(R.color.black); return view; }
ViewHolder
![Page 23: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/23.jpg)
@Overridepublic View getView(int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { view = inflater.inflate(R.layout.item, parent, false); } ((TextView) view.findViewById(R.id.text)).setText(“Random string"); ((ImageView) view.findViewById(R.id.image)).setBackgroundColor(R.color.black); return view; }
No Holder
![Page 24: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/24.jpg)
Ahora…
ActionBarCompat
Nested Fragments
Navigation drawer
Native Pull-to-Refresh
![Page 25: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/25.jpg)
Si lo recomienda
![Page 26: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/26.jpg)
Juguemos…
• Descargar datos de un servidor
• Parser JSON
• Guardar datos en la BBDD
• Recuperar datos de la BBDD
• Mostrar datos en la pantalla
![Page 27: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/27.jpg)
• Descargar datos de un servidor
• Parser JSON
• Guardar datos en la BBDD
• Recuperar datos de la BBDD
• Mostrar datos en la pantalla
Juguemos…
![Page 28: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/28.jpg)
God Activity
![Page 29: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/29.jpg)
startManagingCursor(Cursor c)
![Page 30: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/30.jpg)
God Fragment
![Page 31: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/31.jpg)
“Una Activity para gobernarlos a todos; una Activity para encontrarlos; una Activity para atraerlos a todos y atarlos a las tinieblas”
- El Señor de los Fragments
![Page 32: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/32.jpg)
SauronActivity
![Page 33: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/33.jpg)
Clean code
vs
Lengua Oscura de Mordor
![Page 34: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/34.jpg)
AsyncTask
![Page 35: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/35.jpg)
AsyncTask + startManagingCursor
![Page 36: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/36.jpg)
Loaders!
![Page 37: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/37.jpg)
LoaderCallbacks<Cursor> callback = new LoaderCallbacks<Cursor>() { @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(context, uri, null, null, null, null); } @Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { adapter.swapCursor(data); } @Override public void onLoaderReset(Loader<Cursor> loader) { }};
LoaderCallbacks
![Page 38: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/38.jpg)
ContentProvider
![Page 39: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/39.jpg)
SyncAdapter
![Page 40: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/40.jpg)
¿Cuándo?
![Page 41: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/41.jpg)
3. Evolución
![Page 42: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/42.jpg)
![Page 43: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/43.jpg)
SOLID
![Page 44: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/44.jpg)
Model View Presenter
![Page 45: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/45.jpg)
Unit testing
![Page 46: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/46.jpg)
Test Driven Development
![Page 47: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/47.jpg)
Ports & Adapters (Hexagonal
Architecture)
![Page 48: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/48.jpg)
![Page 49: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/49.jpg)
It is not the strongest of the species that survives, nor the most intelligent, but rather the one most adaptable to change.
Charles Darwin
![Page 50: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/50.jpg)
It is not the strongest of the species that survives, nor the most intelligent, but rather the one most adaptable to change.
Charles Darwin
![Page 51: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/51.jpg)
Espíritu crítico
![Page 52: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/52.jpg)
Código mantenible
(y legible)
![Page 53: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/53.jpg)
Remember!
![Page 54: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/54.jpg)
¡Muchas gracias!
![Page 55: Evolución Android - DroidconMad 2014](https://reader034.vdocuments.pub/reader034/viewer/2022051507/53f51baa8d7f7297528ba398/html5/thumbnails/55.jpg)
Q & ARubén Serrano Núñez
@Akelael
plus.google.com/+RubénSerrano