SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados (6)

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

Destaque (6)

Android ui adapter
Android ui adapterAndroid ui adapter
Android ui adapter
 
Android sync adapter
Android sync adapterAndroid sync adapter
Android sync adapter
 
Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]
 
Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)
 
Android development - ListView & Adapter
Android development - ListView & AdapterAndroid development - ListView & Adapter
Android development - ListView & Adapter
 
Android adapters
Android adaptersAndroid adapters
Android adapters
 

Semelhante a Adapter and cache technique

Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
aswapnal
 

Semelhante a Adapter and cache technique (20)

Android Development
Android DevelopmentAndroid Development
Android Development
 
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROIDMaterial Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
 
Android application development for TresmaxAsia
Android application development for TresmaxAsiaAndroid application development for TresmaxAsia
Android application development for TresmaxAsia
 
Androidify workshop
Androidify workshopAndroidify workshop
Androidify workshop
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
Developing for Android-Types of Android Application
Developing for Android-Types of Android ApplicationDeveloping for Android-Types of Android Application
Developing for Android-Types of Android Application
 
Android Effective UI: Tips, Tricks and Patterns
Android Effective UI: Tips, Tricks and PatternsAndroid Effective UI: Tips, Tricks and Patterns
Android Effective UI: Tips, Tricks and Patterns
 
Marrying together the worlds of ADF and HTML5 & AngularJS - Oracle OpenWorld ...
Marrying together the worlds of ADF and HTML5 & AngularJS - Oracle OpenWorld ...Marrying together the worlds of ADF and HTML5 & AngularJS - Oracle OpenWorld ...
Marrying together the worlds of ADF and HTML5 & AngularJS - Oracle OpenWorld ...
 
Shortify for Android
Shortify for AndroidShortify for Android
Shortify for Android
 
Using Automatic Refactoring to Improve Energy Efficiency of Android Apps
Using Automatic Refactoring to Improve Energy Efficiency of Android AppsUsing Automatic Refactoring to Improve Energy Efficiency of Android Apps
Using Automatic Refactoring to Improve Energy Efficiency of Android Apps
 
Android layouts course-in-mumbai
Android layouts course-in-mumbaiAndroid layouts course-in-mumbai
Android layouts course-in-mumbai
 
Android layouts course-in-mumbai
Android layouts course-in-mumbaiAndroid layouts course-in-mumbai
Android layouts course-in-mumbai
 
Building your first android app using xamarin (Gill Cleeren)
Building your first android app using xamarin (Gill Cleeren)Building your first android app using xamarin (Gill Cleeren)
Building your first android app using xamarin (Gill Cleeren)
 
Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...
Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...
Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...
 
Marrying HTML5 and Angular to ADF - Oracle OpenWorld 2014 Preview
Marrying HTML5 and Angular to ADF - Oracle OpenWorld 2014 PreviewMarrying HTML5 and Angular to ADF - Oracle OpenWorld 2014 Preview
Marrying HTML5 and Angular to ADF - Oracle OpenWorld 2014 Preview
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
 
Android Jetpack - Google IO Extended Singapore 2018
Android Jetpack - Google IO Extended Singapore 2018Android Jetpack - Google IO Extended Singapore 2018
Android Jetpack - Google IO Extended Singapore 2018
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User Interface
 
行動App開發管理實務 unit1
行動App開發管理實務 unit1行動App開發管理實務 unit1
行動App開發管理實務 unit1
 
Micro frontend
Micro frontendMicro frontend
Micro frontend
 

Mais de Hoang Vy Nguyen (7)

Android platfom discete_topics
Android platfom discete_topicsAndroid platfom discete_topics
Android platfom discete_topics
 
Android platform broadcast_receiver_intent
Android platform broadcast_receiver_intentAndroid platform broadcast_receiver_intent
Android platform broadcast_receiver_intent
 
Android content provider
Android content providerAndroid content provider
Android content provider
 
Android platform widgets
Android platform widgetsAndroid platform widgets
Android platform widgets
 
Android platform widgets
Android platform widgetsAndroid platform widgets
Android platform widgets
 
Android platform activity
Android platform activityAndroid platform activity
Android platform activity
 
Android platform overview
Android platform overviewAndroid platform overview
Android platform overview
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

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