пятница, 24 июня 2011 г.
четверг, 23 июня 2011 г.
Android: Use the ViewHolder
This is going to be a quick hit blog post about the Android "ViewHolder" pattern. To really make use of the ViewHolder with Android you do need to know what theListView widget is (a helper for managing views of lists), and that ListViews and generally backed byAdapters (adapters provide data for lists and build views for said data, they can be made from lists of stuff in files, or from in memory arrays, or from databases, and so on).
We will look at the code, complete with ViewHolder, coming up. First a bit more background.
среда, 22 июня 2011 г.
Asynchronous Lazy Loading and Caching of ListView Images
I am using a custom CursorAdapter for a ListView to display some images and captions associated with those images. I am getting the images from the Internet.
The implementation produced significant lag in the UI when scrolling through items. This is because the getView() method of a ListView adapter can be called one or more times each time a ListView item comes into view – we are given no guarantees on when or how this method will be called. Therefore, downloading images within getView() was extremely inefficient, as each image was being downloaded by the UI thread as the ListView item came into view, and was usually downloaded repeatedly after that.
Today I’ll refactor my app to add asynchronous lazy loading and caching of images. Some of the code included has been based on the excellent demonstration provided by Github user thest1. Through this example, I’ll demonstrate asynchronous operations in Android, using local storage for caching data, ViewHolders, and a few other advanced techniques for optimizing app performance.
Since all(downloading images) of this is happening on the UI thread, massive UI lag resulted, which would create a poor user experience for a production app. The root problems are:
The implementation produced significant lag in the UI when scrolling through items. This is because the getView() method of a ListView adapter can be called one or more times each time a ListView item comes into view – we are given no guarantees on when or how this method will be called. Therefore, downloading images within getView() was extremely inefficient, as each image was being downloaded by the UI thread as the ListView item came into view, and was usually downloaded repeatedly after that.
Today I’ll refactor my app to add asynchronous lazy loading and caching of images. Some of the code included has been based on the excellent demonstration provided by Github user thest1. Through this example, I’ll demonstrate asynchronous operations in Android, using local storage for caching data, ViewHolders, and a few other advanced techniques for optimizing app performance.
Since all(downloading images) of this is happening on the UI thread, massive UI lag resulted, which would create a poor user experience for a production app. The root problems are:
- Images are being downloaded from the UI thread
- Images are being downloaded many, many more times than they need to be, since getView() is called as often as Android feels like calling it
So, what can we do?
пятница, 17 июня 2011 г.
way 2 rankers: Google Job Interview Questions | (PM, SE, Testing,...
way 2 rankers: Google Job Interview Questions | (PM, SE, Testing,...: "Google Interview Questions: Product Marketing Manager Why do you want to join Google? What do you know about Google's pro..."
среда, 15 июня 2011 г.
Using the Contact Picker. Getting phone and send sms
How to get email or phone from contacts and use it in your app?
This tutorial will start out simple, but then we’ll get in to some of the technical details of using Contacts with the ContactsContract class, which was introduced in API Level 5.
This tutorial will start out simple, but then we’ll get in to some of the technical details of using Contacts with the ContactsContract class, which was introduced in API Level 5.
Step 1: Launching the Contact Picker
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.CommonDataKinds.Phone;
private static final int CONTACT_PICKER_RESULT = 1001;
public void doLaunchContactPicker(View view) {
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,
Contacts.CONTENT_URI);
startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT);
}Once launched, the contacts picker in your application will look something like this:
пятница, 29 апреля 2011 г.
How to pictures don't show in the user gallery
If your app writes images to the SD card, please, add a .nomedia file in your directory so
they don't show up in Gallery
they don't show up in Gallery
воскресенье, 3 апреля 2011 г.
Simon Sinek: How great leaders inspire action | Video on TED.com
Simon Sinek: How great leaders inspire action | Video on TED.com
Замечательная лекция с не менее замечательными примерами, в которой показано, что нужно все начинать с вопроса Зачем?, а уже потом подходить к вопросам Как? и Что?
Замечательная лекция с не менее замечательными примерами, в которой показано, что нужно все начинать с вопроса Зачем?, а уже потом подходить к вопросам Как? и Что?
Подписаться на:
Сообщения (Atom)
