android jam - loaders - udacity lesson 4c
TRANSCRIPT
![Page 1: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/1.jpg)
Android ManchesterWeek 6 - Loaders
![Page 2: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/2.jpg)
Overview
● Sponsors message - Novoda● Retro
○ Lesson 4c Loaders● Looking Forward
○ Lesson 5 Rich and Responsive layouts● Stickers + Booklets● Questionnaire● Next Tue 7-8pm SpacePortX
![Page 3: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/3.jpg)
Energizer
Stand up and introduce yourself to somebody around you, you don’t know
![Page 4: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/4.jpg)
Prime Directive
‘Regardless of where we are up to, we understand and truly believe that everyone did the best job he or she could, given his or her skills and abilities, the personal time available, and the situation at hand.’
![Page 5: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/5.jpg)
Difficulty Check● Who completed the class?
● How long did it take?
● Hands up 1-10 difficulty of the weeks lesson
● Any specific areas of the lesson that require particular focus?
![Page 6: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/6.jpg)
Retro lesson 4c Loaders
What we learnt last week● Problems ● Solution with loader● Key methods● How loaders fit into the bigger picture
![Page 7: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/7.jpg)
Problems 1
![Page 8: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/8.jpg)
Problem 2
● Loading data in UI/Main thread can take time and make UI less responsive○ Load data in AsyncTask why don’t we?
■ On orientation change we’ll re-create AsyncTask and consume even more resources
● Loaders registered to LoaderManager via static ID and live beyond lifecycle of Fragment or Activity○ Monitor source changes and deliver new data.
![Page 9: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/9.jpg)
(Cursor)Loader 1● Available from HoneyComb (3.0+)
○ Available in compatibility library● Load data in AsyncTask on the background thread
○ provides updates to UI thread.● CursorLoader = AsynTaskLoader for content
providers○ Returns cursor to UI ○ Monitors changes to data and notifies UI○ On rotation when activity reconnects to loader
its passed the last Cursor
![Page 10: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/10.jpg)
(Cursor)Loader 2
● Key components○ Loader_ID○ Interface to implement
■ LoaderManager.LoaderCallbacks<Cursor>
○ InitLoader■ getLoaderManager().initLoader(ID, null, this);
○ Callbacks■ public Loader<Cursor> onCreateLoader(int loaderID, Bundle bundle) //Build Uri and create new CursorLoader
■ public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) //update adapter with new cursor
■ public void onLoaderReset(Loader<Cursor> loader) // release resources
![Page 11: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/11.jpg)
Without loaders
![Page 12: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/12.jpg)
With Loaders
![Page 13: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/13.jpg)
What went well
![Page 14: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/14.jpg)
What went well
● Responsive○ Hard work off UI/Main thread
Data retrieval not tied to Activity lifecycleSaves resources/memory
● Makes observing data easier○ Less coding
● Updates update the UI without us doing anything!
![Page 15: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/15.jpg)
What didn’t go so well
![Page 16: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/16.jpg)
What didn’t go so well
● More coding○ Time consuming
● Loaders are crayzay! initLoader() vs restartLoader() ?!?
![Page 18: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/18.jpg)
Next Week - Android Jam
Rich Layouts (location: Store room)
![Page 19: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/19.jpg)
Next Lesson - Rich Layouts
Learning Objectives:- Screen densities- Fragments- Orientation change - preserving data- 2 pane layout- ActionBar- Custom Views
![Page 20: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/20.jpg)
See you next week..
- Time: Tuesday 7pm - Place: SpacePort- Things needed: You + Questions +
Feedback- Can contact us if issues:
@blundell_apps / @android_mcr
![Page 21: Android Jam - Loaders - Udacity Lesson 4c](https://reader030.vdocuments.site/reader030/viewer/2022032421/55a699e81a28ab80668b4600/html5/thumbnails/21.jpg)
Go forth and discuss