filmov
tv
Performance optimisations for android applications - Part 2 Creating AsyncTask

Показать описание
Part 2 - Addresses the issue with the bitmaps being loaded from the filesystem in the UI thread by creating a background thread using the android AsyncTask class.
Link below to that tutorial series
For those of you who have not done the android image gallery tutorial but are familiar enough with android you can clone the code from github here
In this part of the android tutorial performance series we first explain how to remove a third party library which is picasso and then detail how to create an AsyncTask and load the bitmaps in the AsyncTask's doInBackground method.
A WeakReference is also created for the ImageView to avoid potential garbage collector issues.
In this tutorial we will cover:
- Removing third party libraries with gradle
- Creating an AsyncTask object
- Create a WeakReference to reference to ImageView
- Implement to doInBackground method to return the bitmap
- Implement the onPostExecute to apply the bitmap to the ImageView on the UI thread
- Create and call the BitmapWorkerTask from inside the RecyclerView Adapter's onBindViewHolder method
- Run the application and check for performance changes
- Debug app and step through the code changes
The previous tutorials were aimed at beginners to android but over time have been getting more complex as the original camera_intent app has developed.
This tutorial series is more aimed towards the intermediate developers but for those who have been following the previous tutorial series, feel free to watch this android performance series.
Android studio (1.2.1) is the editor of choice (IDE) for this tutorial series.
API's covered
- AyncTask
- doInBackground
- onPostExecute
- onBindViewHolder
This tutorial series is the start of what I expect to be many so I encourage comments and feedback to improve the quality and viewing experience.
Link below to that tutorial series
For those of you who have not done the android image gallery tutorial but are familiar enough with android you can clone the code from github here
In this part of the android tutorial performance series we first explain how to remove a third party library which is picasso and then detail how to create an AsyncTask and load the bitmaps in the AsyncTask's doInBackground method.
A WeakReference is also created for the ImageView to avoid potential garbage collector issues.
In this tutorial we will cover:
- Removing third party libraries with gradle
- Creating an AsyncTask object
- Create a WeakReference to reference to ImageView
- Implement to doInBackground method to return the bitmap
- Implement the onPostExecute to apply the bitmap to the ImageView on the UI thread
- Create and call the BitmapWorkerTask from inside the RecyclerView Adapter's onBindViewHolder method
- Run the application and check for performance changes
- Debug app and step through the code changes
The previous tutorials were aimed at beginners to android but over time have been getting more complex as the original camera_intent app has developed.
This tutorial series is more aimed towards the intermediate developers but for those who have been following the previous tutorial series, feel free to watch this android performance series.
Android studio (1.2.1) is the editor of choice (IDE) for this tutorial series.
API's covered
- AyncTask
- doInBackground
- onPostExecute
- onBindViewHolder
This tutorial series is the start of what I expect to be many so I encourage comments and feedback to improve the quality and viewing experience.
Комментарии