SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Loader
+Handaru Sakti
Intoduction
●   Asynchronously load data in an activity or
    fragment.
●   Automatically reconnect to the last their cursor
    when being recreated after a configuration
    change (like screen flips). Thus, they don't need
    to re-query their data.
●   Introduced in Honeycomb, exist on Android
    Support Package v-4.
Involved Classes and Interfaces
●   LoaderManager
●   LoaderManager.LoaderCallbacks
●   Loader
●   AsyncTaskLoader
●   CursorLoader
Common Approach...
●   LoaderManager to initialize a Loader. There is
    only one LoaderManager per activity or
    fragment, but a LoaderManager can have
    multiple loaders.
●   LoaderManager.LoaderCallbacks: a callback
    interface for a client to interact with the
    LoaderManager.
●   Loader: an abstract class that performs
    asynchronous loading of data. This is the base
    class for a loader.
...Common Approach
●   AsyncTaskLoader: abstract loader that provides
    an AsyncTask to do the work.
●   A CursorLoader used to load data which
    backed by a ContentProvider. Alternatively,
    implement a subclass of Loader or
    AsyncTaskLoader to load data from some other
    source.
●   A SimpleCursorAdapter used to display the
    loader’s data.
Implementation
●   Starting a Loader
    –   getLoaderManager().initLoader(0, null, this);
    –   Within Activity via onCreate() method.
    –   Within Fragment via onActivityCreated() method.
●   Restarting a Loader
    –   getLoaderManager().restartLoader(0, null, this);
Using the LoaderManager Callbacks
LoaderManager.LoaderCallbacks includes these
methods:
  –   onCreateLoader() — Instantiate and return a new
      Loader for the given ID.
  –   onLoadFinished() — Called when a previously
      created Loader has finished its load.
  –   onLoaderReset() — Called when a previously
      created Loader is being reset, thus making its data.
DEMO LoaderTest
References
●   http://developer.android.com/guide/components
    /loaders.html
●   http://developer.android.com/reference/android/
    content/Loader.html

Weitere ähnliche Inhalte

Was ist angesagt?

Into to Docker (Central PA Java User Group - 8/14/2017)
Into to Docker (Central PA Java User Group - 8/14/2017)Into to Docker (Central PA Java User Group - 8/14/2017)
Into to Docker (Central PA Java User Group - 8/14/2017)Mike Melusky
 
OpenNebula Conf 2014 | Cloud Automation for OpenNebula by Kishorekumar Neelam...
OpenNebula Conf 2014 | Cloud Automation for OpenNebula by Kishorekumar Neelam...OpenNebula Conf 2014 | Cloud Automation for OpenNebula by Kishorekumar Neelam...
OpenNebula Conf 2014 | Cloud Automation for OpenNebula by Kishorekumar Neelam...NETWAYS
 
Kolla Onboarding (Vancouver 2018)
Kolla Onboarding (Vancouver 2018)Kolla Onboarding (Vancouver 2018)
Kolla Onboarding (Vancouver 2018)Paul Bourke
 
Kubernetes deployment strategies - CNCF Webinar
Kubernetes deployment strategies - CNCF WebinarKubernetes deployment strategies - CNCF Webinar
Kubernetes deployment strategies - CNCF WebinarEtienne Tremel
 
Kolla Project Update (Vancouver 2018)
Kolla Project Update (Vancouver 2018)Kolla Project Update (Vancouver 2018)
Kolla Project Update (Vancouver 2018)Paul Bourke
 
Helm - Application deployment management for Kubernetes
Helm - Application deployment management for KubernetesHelm - Application deployment management for Kubernetes
Helm - Application deployment management for KubernetesAlexei Ledenev
 
ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019
ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019
ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019UA DevOps Conference
 

Was ist angesagt? (8)

Into to Docker (Central PA Java User Group - 8/14/2017)
Into to Docker (Central PA Java User Group - 8/14/2017)Into to Docker (Central PA Java User Group - 8/14/2017)
Into to Docker (Central PA Java User Group - 8/14/2017)
 
Docker quick start
Docker quick startDocker quick start
Docker quick start
 
OpenNebula Conf 2014 | Cloud Automation for OpenNebula by Kishorekumar Neelam...
OpenNebula Conf 2014 | Cloud Automation for OpenNebula by Kishorekumar Neelam...OpenNebula Conf 2014 | Cloud Automation for OpenNebula by Kishorekumar Neelam...
OpenNebula Conf 2014 | Cloud Automation for OpenNebula by Kishorekumar Neelam...
 
Kolla Onboarding (Vancouver 2018)
Kolla Onboarding (Vancouver 2018)Kolla Onboarding (Vancouver 2018)
Kolla Onboarding (Vancouver 2018)
 
Kubernetes deployment strategies - CNCF Webinar
Kubernetes deployment strategies - CNCF WebinarKubernetes deployment strategies - CNCF Webinar
Kubernetes deployment strategies - CNCF Webinar
 
Kolla Project Update (Vancouver 2018)
Kolla Project Update (Vancouver 2018)Kolla Project Update (Vancouver 2018)
Kolla Project Update (Vancouver 2018)
 
Helm - Application deployment management for Kubernetes
Helm - Application deployment management for KubernetesHelm - Application deployment management for Kubernetes
Helm - Application deployment management for Kubernetes
 
ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019
ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019
ОЛЕГ МАЦЬКІВ «Crash course on Operator Framework» Lviv DevOps Conference 2019
 

Andere mochten auch

Reduirisidoroandres compatible
Reduirisidoroandres compatibleReduirisidoroandres compatible
Reduirisidoroandres compatibleMar Caston Palacio
 
Storial - Be Storyteller
Storial - Be StorytellerStorial - Be Storyteller
Storial - Be StorytellerHandaru Sakti
 
Fisikawan dan Dunia Kerja
Fisikawan dan Dunia KerjaFisikawan dan Dunia Kerja
Fisikawan dan Dunia KerjaHandaru Sakti
 
Why Functional Programming Is Important in Big Data Era
Why Functional Programming Is Important in Big Data EraWhy Functional Programming Is Important in Big Data Era
Why Functional Programming Is Important in Big Data EraHandaru Sakti
 

Andere mochten auch (6)

Reduirisidoroandres compatible
Reduirisidoroandres compatibleReduirisidoroandres compatible
Reduirisidoroandres compatible
 
My Storial
My StorialMy Storial
My Storial
 
Storial - Be Storyteller
Storial - Be StorytellerStorial - Be Storyteller
Storial - Be Storyteller
 
Fisikawan dan Dunia Kerja
Fisikawan dan Dunia KerjaFisikawan dan Dunia Kerja
Fisikawan dan Dunia Kerja
 
Why Functional Programming Is Important in Big Data Era
Why Functional Programming Is Important in Big Data EraWhy Functional Programming Is Important in Big Data Era
Why Functional Programming Is Important in Big Data Era
 
SAH2H PPT
SAH2H PPTSAH2H PPT
SAH2H PPT
 

Ähnlich wie Loader

Lecture #4 c loaders and co.
Lecture #4 c   loaders and co.Lecture #4 c   loaders and co.
Lecture #4 c loaders and co.Vitali Pekelis
 
Loaders (and why we should use them)
Loaders (and why we should use them)Loaders (and why we should use them)
Loaders (and why we should use them)Michael Pustovit
 
Android Loaders : Reloaded
Android Loaders : ReloadedAndroid Loaders : Reloaded
Android Loaders : Reloadedcbeyls
 
Android App Development - 07 Threading
Android App Development - 07 ThreadingAndroid App Development - 07 Threading
Android App Development - 07 ThreadingDiego Grancini
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming ) Adarsh Patel
 
SH 1 - SES 6 - compass-tel-aviv-slides.pptx
SH 1 - SES 6 - compass-tel-aviv-slides.pptxSH 1 - SES 6 - compass-tel-aviv-slides.pptx
SH 1 - SES 6 - compass-tel-aviv-slides.pptxMongoDB
 
Nine Circles of Inferno or Explaining the PostgreSQL Vacuum
Nine Circles of Inferno or Explaining the PostgreSQL VacuumNine Circles of Inferno or Explaining the PostgreSQL Vacuum
Nine Circles of Inferno or Explaining the PostgreSQL VacuumAlexey Lesovsky
 
Your journey into the serverless world
Your journey into the serverless worldYour journey into the serverless world
Your journey into the serverless worldRed Hat Developers
 
Load testing in Zonky with Gatling
Load testing in Zonky with GatlingLoad testing in Zonky with Gatling
Load testing in Zonky with GatlingPetr Vlček
 
Deep dive into Android async operations
Deep dive into Android async operationsDeep dive into Android async operations
Deep dive into Android async operationsMateusz Grzechociński
 
What is code splitting in react
What is code splitting in reactWhat is code splitting in react
What is code splitting in reactBOSC Tech Labs
 
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTESOBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTESsuthi
 
How to deploy and run mule in docker
How to deploy and run mule in dockerHow to deploy and run mule in docker
How to deploy and run mule in dockerRavi Prakash Singh
 
12.+Managing+Containers.pdf
12.+Managing+Containers.pdf12.+Managing+Containers.pdf
12.+Managing+Containers.pdfVikrantSChohaan
 
Automation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAutomation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAlan Richardson
 

Ähnlich wie Loader (20)

Lecture #4 c loaders and co.
Lecture #4 c   loaders and co.Lecture #4 c   loaders and co.
Lecture #4 c loaders and co.
 
Loaders (and why we should use them)
Loaders (and why we should use them)Loaders (and why we should use them)
Loaders (and why we should use them)
 
Android Loaders : Reloaded
Android Loaders : ReloadedAndroid Loaders : Reloaded
Android Loaders : Reloaded
 
Redux
ReduxRedux
Redux
 
Android App Development - 07 Threading
Android App Development - 07 ThreadingAndroid App Development - 07 Threading
Android App Development - 07 Threading
 
Redux workshop
Redux workshopRedux workshop
Redux workshop
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming )
 
SH 1 - SES 6 - compass-tel-aviv-slides.pptx
SH 1 - SES 6 - compass-tel-aviv-slides.pptxSH 1 - SES 6 - compass-tel-aviv-slides.pptx
SH 1 - SES 6 - compass-tel-aviv-slides.pptx
 
Nine Circles of Inferno or Explaining the PostgreSQL Vacuum
Nine Circles of Inferno or Explaining the PostgreSQL VacuumNine Circles of Inferno or Explaining the PostgreSQL Vacuum
Nine Circles of Inferno or Explaining the PostgreSQL Vacuum
 
Advanced guide to Quartz plugin
Advanced guide to Quartz pluginAdvanced guide to Quartz plugin
Advanced guide to Quartz plugin
 
Your journey into the serverless world
Your journey into the serverless worldYour journey into the serverless world
Your journey into the serverless world
 
Load testing in Zonky with Gatling
Load testing in Zonky with GatlingLoad testing in Zonky with Gatling
Load testing in Zonky with Gatling
 
Loaders
LoadersLoaders
Loaders
 
Deep dive into Android async operations
Deep dive into Android async operationsDeep dive into Android async operations
Deep dive into Android async operations
 
What is code splitting in react
What is code splitting in reactWhat is code splitting in react
What is code splitting in react
 
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTESOBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
 
Fluxxor react library
Fluxxor react libraryFluxxor react library
Fluxxor react library
 
How to deploy and run mule in docker
How to deploy and run mule in dockerHow to deploy and run mule in docker
How to deploy and run mule in docker
 
12.+Managing+Containers.pdf
12.+Managing+Containers.pdf12.+Managing+Containers.pdf
12.+Managing+Containers.pdf
 
Automation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAutomation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and Beyond
 

Mehr von Handaru Sakti

Game Theory of Oligopolistic Pricing Strategies
Game Theory of  Oligopolistic Pricing StrategiesGame Theory of  Oligopolistic Pricing Strategies
Game Theory of Oligopolistic Pricing StrategiesHandaru Sakti
 
Innovation management
Innovation managementInnovation management
Innovation managementHandaru Sakti
 
Product Design Language System
Product Design Language SystemProduct Design Language System
Product Design Language SystemHandaru Sakti
 
IES Triangle Principle
IES Triangle PrincipleIES Triangle Principle
IES Triangle PrincipleHandaru Sakti
 
Business Model Canvas
Business Model CanvasBusiness Model Canvas
Business Model CanvasHandaru Sakti
 
Transition management of product as platform
Transition management of  product as platformTransition management of  product as platform
Transition management of product as platformHandaru Sakti
 
Mobile App Trends in 2016
Mobile App Trends in 2016Mobile App Trends in 2016
Mobile App Trends in 2016Handaru Sakti
 
Android career opportunities
Android career opportunitiesAndroid career opportunities
Android career opportunitiesHandaru Sakti
 

Mehr von Handaru Sakti (9)

Game Theory of Oligopolistic Pricing Strategies
Game Theory of  Oligopolistic Pricing StrategiesGame Theory of  Oligopolistic Pricing Strategies
Game Theory of Oligopolistic Pricing Strategies
 
Innovation management
Innovation managementInnovation management
Innovation management
 
Product Design Language System
Product Design Language SystemProduct Design Language System
Product Design Language System
 
Real-Time Big Data
Real-Time Big DataReal-Time Big Data
Real-Time Big Data
 
IES Triangle Principle
IES Triangle PrincipleIES Triangle Principle
IES Triangle Principle
 
Business Model Canvas
Business Model CanvasBusiness Model Canvas
Business Model Canvas
 
Transition management of product as platform
Transition management of  product as platformTransition management of  product as platform
Transition management of product as platform
 
Mobile App Trends in 2016
Mobile App Trends in 2016Mobile App Trends in 2016
Mobile App Trends in 2016
 
Android career opportunities
Android career opportunitiesAndroid career opportunities
Android career opportunities
 

Loader

  • 2. Intoduction ● Asynchronously load data in an activity or fragment. ● Automatically reconnect to the last their cursor when being recreated after a configuration change (like screen flips). Thus, they don't need to re-query their data. ● Introduced in Honeycomb, exist on Android Support Package v-4.
  • 3. Involved Classes and Interfaces ● LoaderManager ● LoaderManager.LoaderCallbacks ● Loader ● AsyncTaskLoader ● CursorLoader
  • 4. Common Approach... ● LoaderManager to initialize a Loader. There is only one LoaderManager per activity or fragment, but a LoaderManager can have multiple loaders. ● LoaderManager.LoaderCallbacks: a callback interface for a client to interact with the LoaderManager. ● Loader: an abstract class that performs asynchronous loading of data. This is the base class for a loader.
  • 5. ...Common Approach ● AsyncTaskLoader: abstract loader that provides an AsyncTask to do the work. ● A CursorLoader used to load data which backed by a ContentProvider. Alternatively, implement a subclass of Loader or AsyncTaskLoader to load data from some other source. ● A SimpleCursorAdapter used to display the loader’s data.
  • 6. Implementation ● Starting a Loader – getLoaderManager().initLoader(0, null, this); – Within Activity via onCreate() method. – Within Fragment via onActivityCreated() method. ● Restarting a Loader – getLoaderManager().restartLoader(0, null, this);
  • 7. Using the LoaderManager Callbacks LoaderManager.LoaderCallbacks includes these methods: – onCreateLoader() — Instantiate and return a new Loader for the given ID. – onLoadFinished() — Called when a previously created Loader has finished its load. – onLoaderReset() — Called when a previously created Loader is being reset, thus making its data.
  • 9. References ● http://developer.android.com/guide/components /loaders.html ● http://developer.android.com/reference/android/ content/Loader.html