evolución android - droidconmad 2014
Post on 29-Jan-2018
859 Views
Preview:
TRANSCRIPT
Evolución Android Del framework a la supervivencia del
más fuerte
1. Origen 2. Extinción 3. Evolución
Agenda
1. Origen
Rubén Serrano Núñez (@Akelael) Lead Android Developer @RedboothHQ
Redbooth Beta Redbooth
WTF!
Creacionista
Evolucionista
¿Creacionistas vs
Evolucionistas?
“It’s the maintenance!”
2. Extinción
All-in-one Application
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; }
Lo puse todo en Application y …
¡Quita eso de ahí, guarro!
Ahora si, ahora no
Ahora si, ahora no: Relative Layout
Ahora si, ahora no:
Enums vs Static Final Fields
Ahora si, ahora no: ViewHolder
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
@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
Ahora…
ActionBarCompat
Nested Fragments
Navigation drawer
Native Pull-to-Refresh
Si lo recomienda
Juguemos…
• Descargar datos de un servidor
• Parser JSON
• Guardar datos en la BBDD
• Recuperar datos de la BBDD
• Mostrar datos en la pantalla
• Descargar datos de un servidor
• Parser JSON
• Guardar datos en la BBDD
• Recuperar datos de la BBDD
• Mostrar datos en la pantalla
Juguemos…
God Activity
startManagingCursor(Cursor c)
God Fragment
“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
SauronActivity
Clean code
vs
Lengua Oscura de Mordor
AsyncTask
AsyncTask + startManagingCursor
Loaders!
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
ContentProvider
SyncAdapter
¿Cuándo?
3. Evolución
SOLID
Model View Presenter
Unit testing
Test Driven Development
Ports & Adapters (Hexagonal
Architecture)
It is not the strongest of the species that survives, nor the most intelligent, but rather the one most adaptable to change.
Charles Darwin
It is not the strongest of the species that survives, nor the most intelligent, but rather the one most adaptable to change.
Charles Darwin
Espíritu crítico
Código mantenible
(y legible)
Remember!
¡Muchas gracias!
Q & ARubén Serrano Núñez
@Akelael
plus.google.com/+RubénSerrano
top related