Contenu connexe Similaire à Evolución Android - DroidconMad 2014 (20) Evolución Android - DroidconMad 201416. 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;
}
17. Lo puse todo en
Application y …
¡Quita eso de
ahí, guarro!
22. private static class ViewHolder {
public TextView textView;
public ImageView imageView;
}
!
@Override
public 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
23. @Override
public 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
26. Juguemos…
• Descargar datos de un servidor
• Parser JSON
• Guardar datos en la BBDD
• Recuperar datos de la BBDD
• Mostrar datos en la pantalla
27. • Descargar datos de un servidor
• Parser JSON
• Guardar datos en la BBDD
• Recuperar datos de la BBDD
• Mostrar datos en la pantalla
Juguemos…
31. “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
37. 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
49. It is not the strongest of the species that
survives, nor the most intelligent, but
rather the one most adaptable to change.
Charles Darwin
50. It is not the strongest of the species that
survives, nor the most intelligent, but
rather the one most adaptable to change.
Charles Darwin
55. Q & A
Rubén Serrano Núñez
@Akelael
plus.google.com/+RubénSerrano