SlideShare a Scribd company logo
Adapter and
cache technique
Trí Phạm – MultiUni - 2012
Adapter and cache technique

   • Adapter in Android
   • Cache technique in Android
ADAPTER IN ANDROID
Adapter in Android

   • Adapter design pattern
Adapter in Android

   • Adapter design pattern (con’t)
Adapter in Android

   • Adapter design pattern (con’t)
Adapter in Android

   • Adapter design pattern (con’t)
Adapter in Android

     •   An Adapter object acts as a bridge between an View and the
         underlying data for that view.
     •   One side of the adapter is a data structure like a Java object
         storing data. the other side of the adapter, there is view that
         the data structure was transformed into.
     •   The Adapter is also responsible for making a View for each
         item in the data set.
Adapter in Android
Adapter in Android

   • Android ListView
Adapter in Android

   • Android ListView (con’t)
     – Naive and dumb way
     – The correct way: List13.java
     – The fast way: List14.java
Adapter in Android

   • Considering Adapter for the List View
     – Each List item in the List View would be calling its
       “getView()” method.
     – This method would return a view for the List.
     – But creating a new View for each list item would be
       complicated, and the UI would be slow down.
     – Instead of creating new View for each item, Recycler
       save these view and passes it to the Adapter.
     – Adapter uses these view sent by the recycler, when it
       has to produce any new views.
Adapter in Android

   • View Holders
     – View Holders hold some data that related to an item to
       the view.
     – View Holders minimizes the amount of work, while
       writing the same piece of code again and again.
     – These are used while creating the views, where we have
       to use more than one time.

        (TextView)findViewById(R.Id.text);
        (ImageView)findViewById(R.Id.Icon);
Adapter in Android

   • View Holders (con’t)
     – By using the View Holders, the views are saved into a
       class variable and can be called when needed.
         holder.text = (TextView)findViewById(R.id.text);
         holder.icon = (ImageView)findViewById(R.id.icon);
         convertView.setTag(holder);
     – A tag can hold any kind of object, that can be set on the
       view.
Adapter in Android

   • Android ListView
CACHE TECHNIQUE IN
ANDROID
Cache technique in Android


     • Basic cache view technique (for
       views that have scrolling
       behavior)
     • Cache data technique
Adapter in Android

   • Basic cache view technique (for
     views that have scrolling behavior)
     – Demo EfficientListView
Adapter in Android

   • Cache data technique
     – Why using cache:
       • Some operations are high CPU load and
         time consuming. E.g.: load images from
         network…
       -> Never do something time consuming twice
       • Mobile applications, especially Android
         applications needs optimization for smooth
         UI.
Adapter in Android

   • Cache data technique
     – Demo ImageDownloader with soft
       (memory) cache
Q&A

More Related Content

PPT
Android UI
PDF
Android UI System
PPT
Android Ui
PDF
Listview and Adapter
PPTX
Material Design Android
PDF
Android Screen Containers & Layouts
PDF
Android Materials Design
PPTX
Imagetag
Android UI
Android UI System
Android Ui
Listview and Adapter
Material Design Android
Android Screen Containers & Layouts
Android Materials Design
Imagetag

What's hot (6)

PDF
Android Material Design APIs/Tips
PPTX
3. react - native: component
PDF
Material design basics
PPTX
HTML Images
PDF
MVP Community Camp 2014 - How to use enhanced features of Windows 8.1 Store ...
PDF
Domain model
Android Material Design APIs/Tips
3. react - native: component
Material design basics
HTML Images
MVP Community Camp 2014 - How to use enhanced features of Windows 8.1 Store ...
Domain model
Ad

Viewers also liked (6)

PDF
Android ui adapter
PDF
Android sync adapter
PPT
Lecture Slides for List Views [Android ]
PPTX
Android Training (AdapterView & Adapter)
PDF
Android development - ListView & Adapter
Android ui adapter
Android sync adapter
Lecture Slides for List Views [Android ]
Android Training (AdapterView & Adapter)
Android development - ListView & Adapter
Ad

Similar to Adapter and cache technique (20)

PDF
Lab2-android
PPTX
Introduction to Listview in Android
PPTX
MDAD 5 - Android - Lists, adapters and recycling
PPTX
MDAD 4 - Lists, adapters and recycling
PDF
Android UI Tips, Tricks and Techniques
PDF
Android UI Development: Tips, Tricks, and Techniques
PPTX
Day 5 android app code advancement
PDF
The Tale of a Smooth RecyclerView
PPTX
Android course Lesson2
PDF
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
PDF
Dinosaurs and Androids: The Listview Evolution
PPTX
Andromance - Android Performance
PDF
Workshop 04 android-development
PDF
The Good, the Bad and the Ugly things to do with android
PDF
Day 8: Dealing with Lists and ListViews
PPT
Hello Android
PPTX
Adapter and adapter views that are used in android
PPT
Android ListView and Custom ListView
ODP
Android App Development - 11 Lists, grids, adapters, dialogs and toasts
ODP
Android query
Lab2-android
Introduction to Listview in Android
MDAD 5 - Android - Lists, adapters and recycling
MDAD 4 - Lists, adapters and recycling
Android UI Tips, Tricks and Techniques
Android UI Development: Tips, Tricks, and Techniques
Day 5 android app code advancement
The Tale of a Smooth RecyclerView
Android course Lesson2
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
Dinosaurs and Androids: The Listview Evolution
Andromance - Android Performance
Workshop 04 android-development
The Good, the Bad and the Ugly things to do with android
Day 8: Dealing with Lists and ListViews
Hello Android
Adapter and adapter views that are used in android
Android ListView and Custom ListView
Android App Development - 11 Lists, grids, adapters, dialogs and toasts
Android query

More from Hoang Vy Nguyen (7)

PDF
Android platfom discete_topics
PDF
Android platform broadcast_receiver_intent
PDF
Android content provider
PDF
Android platform widgets
PDF
Android platform widgets
PDF
Android platform activity
PDF
Android platform overview
Android platfom discete_topics
Android platform broadcast_receiver_intent
Android content provider
Android platform widgets
Android platform widgets
Android platform activity
Android platform overview

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
A Presentation on Artificial Intelligence
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Modernizing your data center with Dell and AMD
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Empathic Computing: Creating Shared Understanding
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Big Data Technologies - Introduction.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Machine learning based COVID-19 study performance prediction
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Approach and Philosophy of On baking technology
Dropbox Q2 2025 Financial Results & Investor Presentation
A Presentation on Artificial Intelligence
Digital-Transformation-Roadmap-for-Companies.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Review of recent advances in non-invasive hemoglobin estimation
Modernizing your data center with Dell and AMD
Unlocking AI with Model Context Protocol (MCP)
Empathic Computing: Creating Shared Understanding
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Big Data Technologies - Introduction.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Network Security Unit 5.pdf for BCA BBA.
Machine learning based COVID-19 study performance prediction
Building Integrated photovoltaic BIPV_UPV.pdf
Spectral efficient network and resource selection model in 5G networks
The AUB Centre for AI in Media Proposal.docx
20250228 LYD VKU AI Blended-Learning.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

Adapter and cache technique

  • 1. Adapter and cache technique Trí Phạm – MultiUni - 2012
  • 2. Adapter and cache technique • Adapter in Android • Cache technique in Android
  • 4. Adapter in Android • Adapter design pattern
  • 5. Adapter in Android • Adapter design pattern (con’t)
  • 6. Adapter in Android • Adapter design pattern (con’t)
  • 7. Adapter in Android • Adapter design pattern (con’t)
  • 8. Adapter in Android • An Adapter object acts as a bridge between an View and the underlying data for that view. • One side of the adapter is a data structure like a Java object storing data. the other side of the adapter, there is view that the data structure was transformed into. • The Adapter is also responsible for making a View for each item in the data set.
  • 10. Adapter in Android • Android ListView
  • 11. Adapter in Android • Android ListView (con’t) – Naive and dumb way – The correct way: List13.java – The fast way: List14.java
  • 12. Adapter in Android • Considering Adapter for the List View – Each List item in the List View would be calling its “getView()” method. – This method would return a view for the List. – But creating a new View for each list item would be complicated, and the UI would be slow down. – Instead of creating new View for each item, Recycler save these view and passes it to the Adapter. – Adapter uses these view sent by the recycler, when it has to produce any new views.
  • 13. Adapter in Android • View Holders – View Holders hold some data that related to an item to the view. – View Holders minimizes the amount of work, while writing the same piece of code again and again. – These are used while creating the views, where we have to use more than one time. (TextView)findViewById(R.Id.text); (ImageView)findViewById(R.Id.Icon);
  • 14. Adapter in Android • View Holders (con’t) – By using the View Holders, the views are saved into a class variable and can be called when needed. holder.text = (TextView)findViewById(R.id.text); holder.icon = (ImageView)findViewById(R.id.icon); convertView.setTag(holder); – A tag can hold any kind of object, that can be set on the view.
  • 15. Adapter in Android • Android ListView
  • 17. Cache technique in Android • Basic cache view technique (for views that have scrolling behavior) • Cache data technique
  • 18. Adapter in Android • Basic cache view technique (for views that have scrolling behavior) – Demo EfficientListView
  • 19. Adapter in Android • Cache data technique – Why using cache: • Some operations are high CPU load and time consuming. E.g.: load images from network… -> Never do something time consuming twice • Mobile applications, especially Android applications needs optimization for smooth UI.
  • 20. Adapter in Android • Cache data technique – Demo ImageDownloader with soft (memory) cache
  • 21. Q&A