Upload
chanhyeong-lee
View
56
Download
0
Embed Size (px)
Citation preview
Lesson����������� ������������������ 4b.����������� ������������������ Content����������� ������������������ Providers����������� ������������������ and����������� ������������������ Loaders
도우미����������� ������������������ 이찬형
Content����������� ������������������ Providers
•bind����������� ������������������ view����������� ������������������ to����������� ������������������ data����������� ������������������ model����������� ������������������
•URI����������� ������������������
•CONTENT://COM.EXAMPLE.ANDROID.SUNSHINE.APP/WEATHER/85456����������� ������������������
•CONTENT://COM.EXAMPLE.ANDROID.SUNSHINE.APP/WEATHER/85456/20140624
Why����������� ������������������ Content����������� ������������������ Providers����������� ������������������ Matter
Adding����������� ������������������ Content����������� ������������������ Provider����������� ������������������ to����������� ������������������ our����������� ������������������ Contract
Create����������� ������������������ WeatherProvider
•extends����������� ������������������ COntentProvider����������� ������������������
•AndroidManifest.xml����������� ������������������
•OnCreate
Coding����������� ������������������ the����������� ������������������ Content����������� ������������������ Provider����������� ������������������ :����������� ������������������ getType()
•UriMatcher����������� ������������������
•testGetType()����������� ������������������
•ContentResolver
Coding����������� ������������������ the����������� ������������������ Content����������� ������������������ Provider����������� ������������������ :����������� ������������������ query()
•implement����������� ������������������ every����������� ������������������ cases����������� ������������������
•setNotificationUri()
Add����������� ������������������ a����������� ������������������ join����������� ������������������ query
Add����������� ������������������ a����������� ������������������ join����������� ������������������ query
•SQLiteQueryBuilder����������� ������������������
•inner����������� ������������������ join����������� ������������������
•_ID����������� ������������������
•http://egloos.zum.com/sweeper/v/3002133
Inserting,����������� ������������������ Updating����������� ������������������ and����������� ������������������ Deleting
•match����������� ������������������ the����������� ������������������ base����������� ������������������ URI����������� ������������������
•getContext().getContentResolver().notifyChange(uri,����������� ������������������ null);
Efficient����������� ������������������ Updates����������� ������������������ :����������� ������������������ Inserts•bulkInsert����������� ������������������
•What����������� ������������������ is����������� ������������������ transcation����������� ������������������ ?����������� ������������������
•http://ko.wikipedia.org/wiki/%ED%8A%B8%EB%9E%9C%EC%9E%AD%EC%85%98����������� ������������������
•beginTranscation����������� ������������������
•endTranscation
Step����������� ������������������ 3.����������� ������������������ Connect����������� ������������������ to����������� ������������������ Sunshine•Step����������� ������������������ 1.����������� ������������������ Create����������� ������������������ the����������� ������������������ underlying����������� ������������������ data����������� ������������������ source����������� ������������������
•Step����������� ������������������ 2.����������� ������������������ the����������� ������������������ ContentProvider����������� ������������������ class����������� ������������������
•FethchWeatherTask����������� ������������������ use����������� ������������������ the����������� ������������������ ContentProvider����������� ������������������
•Loader����������� ������������������
•CursorAdapter
Refactoring����������� ������������������ FetchWeatherTask
•Extract����������� ������������������ class����������� ������������������ -����������� ������������������ FetchWeatherTask����������� ������������������
•Utility
Inserts����������� ������������������ with����������� ������������������ ContentProvider
•getWeatherDataFromJson����������� ������������������ in����������� ������������������ FetchWeatherTask����������� ������������������
•sql����������� ������������������ date����������� ������������������ vs����������� ������������������ util����������� ������������������ date����������� ������������������
•http://javarevisited.blogspot.kr/2012/04/difference-between-javautildate-and.html
Loaders����������� ������������������ are����������� ������������������ Awesome
•async����������� ������������������ task����������� ������������������ to����������� ������������������ load����������� ������������������ data����������� ������������������ on����������� ������������������ the����������� ������������������ background����������� ������������������ thread
Using����������� ������������������ Loaders����������� ������������������ in����������� ������������������ our����������� ������������������ App•onActivityCreated����������� ������������������
•onCreateLoader����������� ������������������
•onLoadFinished����������� ������������������
•onLoaderReset����������� ������������������
•mForecastAdapter.swapCursor(null);
SimpleCursorAdapter•Change����������� ������������������ the����������� ������������������ type����������� ������������������ of����������� ������������������ the����������� ������������������ mForecastAdapter����������� ������������������ to����������� ������������������ SimpleCursorAdapter����������� ������������������
•https://github.com/udacity/Sunshine/compare/4.34-split-forecast-textviews...4.35-simple-cursor-adapter
Implement����������� ������������������ Details
•https://github.com/udacity/Sunshine/compare/4.37-user-settings-change...4.38-implement-details-cursor-loader
Step����������� ������������������ 3.����������� ������������������ Final����������� ������������������ Summary
Storing����������� ������������������ Images����������� ������������������ or����������� ������������������ Binary����������� ������������������ Data