SlideShare a Scribd company logo
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Effective Android UI
Pedro Vicente Gómez Sánchez
Android Expert
pedro@karumi.com
@pedro_g_s
github.com/pedrovgs
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Irene Herranz
Managing Director
Alberto Gragera
Technical Director
Jorge Barroso
Android Expert
Davide Mendolia
Full Stack Engineer
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
This talk is the continuation of Software Design Patterns on Android
http://www.slideshare.net/PedroVicenteGmezSnch/software-design-patterns-on-android
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Is the UI code less important?
Are we using Android SDK properly?
How can I improve the UI code?
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
● Introduction.
● Resources and qualifiers.
● Custom Views.
● Model View Presenter.
● Model View ViewModel.
● MVP vs MVVM.
● Some advices.
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
https://github.com/pedrovgs/EffectiveAndroidUI
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
● MVP and MVVM samples.
● How to work with Fragments.
● Communication between Fragments and Activities.
● How to use Dagger as Dependency Injector.
● How to use resources to support different screen
densities, device orientation and different Android
versions.
● How to use styles and themes.
● How to use Navigator or ActionCommand to
implement activities navigation.
● How to use custom qualifiers with resources.
● How to use different layouts: RelativeLayout,
LinearLayout, FrameLayout, etc.
● Usage of merge, include and view stub.
● How to implement a ListView using Renderers.
● Simple Interactors implementation described in
“Software Design Patterns on Android” talk.
● How to use Dagger with different scopes, Application
scope and Activity scope.
Introduction
https://github.com/pedrovgs/EffectiveAndroidUI
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Introduction: S4 - Android 4.4.2
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Introduction: DraggablePanel
https://github.com/pedrovgs/DraggablePanel
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Introduction: MDPI device
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Introduction: Nexus 7 and Nexus 10 - Android 4.4.4
Portrait Landscape
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
How can we change the UI depending
on the device?
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Android resources are one of the Android SDK powerful tools
to work with the UI layer. Some common resources are:
● Color: Colors available for your application. In colors.xml you can declare
your color palette.
● Drawable: Shapes and statics assets ready to be used in Image
components as src or background.
● Layout: XML files to describe the application UI and to be inflated by the
system.
● Menu: Android menus can be described in xml files and used directly
from our activities.
● Integer: Integer values ready to be used in xml files or java code.
● XML: XML configuration files that can be used to indicate different
configuration parameters. Not really common.
Resources and qualifiers
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
For complex projects where we have to support tons of different devices with different screen
densities and sizes and different Android API versions we need to use our resources and qualifiers
properly to get the max development performance.
Qualifiers are really important to work with different Android configurations. We can prepare
different resources for different Android configurations and these resources are going to be
provided automatically. Configuration based on qualifiers:
● Screen density: ldpi, mdpi, hdpi, xhdpi, etc.
● Language: es, en, fr, en-rUS, etc.
● Min width: sw600dp, sw720dip.
● Available width or height: w720dp, h1024dp.
● Screen orientation: landscape, portrait.
● Android API level: v7, v8, v9, etc.
Resources and qualifiers
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
How have we used resources and qualifiers in Effective Android UI project?
● Layouts:
○ layout-v10: Android 2.X is using one layout with just one fragment.
○ layout-v11: Android 3.X y 4.X (except tablets in landscape).
○ layout-sw600dp-land: Layout with two fragments in landscape.
● Values:
○ values-mdpi: Mdpi and ldpi devices are using one column for the GridView and different
ImageView height.
○ values-hdpi: Hdpi, xhdpi and xxhdpi devices with screen width lower than 820 dip are
using two columns for the GridView and another ImageView height.
○ values-w820: Devices with more than 820 dip width are going to use 3 columns for the
GridView configuration.
Resources and qualifiers
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Resources and qualifiers
http://developer.android.com/guide/topics/resources/providing-resources.html
How it’s working if we haven’
t declared every possible
configuration?
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Custom Views
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Main motivations to use custom views are:
● Create a non implemented Android SDK widget.
● Group presentation logic for different views. Really useful with
MVVM.
● Add semantic to UI layer components.
● Avoid code duplicity.
Custom Views
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
There are 5 approaches to implement your custom views:
● Extend an already written widget like TextView, ImageView.
● Extend View and override onDraw method using the Canvas API.
● Extend one Layout/ViewGroup and inflate your own layout file.
● Extend one Layout/ViewGroup and wait for views added by other
developers using this custom view.
● Inflate different layouts provided by the custom view client
Custom Views
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Custom Views
http://github.com/pedrovgs/Nox
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Are you ready to talk about MVP and
MVVM?
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Model View Presenter
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Model View Presenter is a software
design pattern that comes from MVC and is
used to build user interfaces. In this pattern,
the “presenter” has the responsibility to
implement all the presentation logic and data
transformation in order to send information to
the view. Works as an abstraction between the
UI layer and the business logic layer.
The “view” in MVP is going to be
abstracted using an interface implemented by
Android components.
Model View Presenter
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
The main problem that MVP solves is related
to testing, to avoid coupling and to avoid code
duplicity.
The usage of MVP improves the testability of
your code because we can test all our UI code
without executing framework code, just with unit
tests. To do this, all the presentation logic is moved
to the presenter.
The view implementation is going to be really
lightweight.
Model View Presenter
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
One of the key points related to
MVP is to leave your presenters free of
Android dependencies. By removing all
your Android code from your
presenters you’ll be able to test it
easily.
Model View Presenter
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Using MVP, Activity Fragments and
Custom Views are going to implement a
presenter “view” interface and are going to
be configured as presenter views.
Views are going to contain code to
implement your view details - described in
the View interface - and to connect user
actions with presenters.
Model View Presenter
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Even if we are using MVP, we need to connect our component lifecycle to our
presenter in order to notify whether the view is ready to work or not.
Some methods like “onSavedInstanceState” will update our presenter state if
needed.
Model View Presenter
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Model View Presenter
To implement user events - like a button clicked - our
view implementation will delegate to the presenter to take
some decisions.
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
If you want to extract navigation
implementation out of Activities or
Fragments you can use a “Navigator”.
Using one Navigator you can avoid
some cycles in the collaboration diagram
between view implementations and presenter
when a user action has to open another
activity or modify the navigation stack.
To do this, you need to be able to inject
Activity context using a dependency injector.
Model View Presenter
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Model View ViewModel
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Model View ViewModel is a software
design pattern derived from Presentation
Model (by Martin Fowler). It’s commonly used
to build user interfaces and used by Microsoft
to implement Windows applications.
The power of this pattern is in the usage
of a binding engine, but we can use it without
one.
The binding engine is going to avoid all
the boilerplate code we have to write to
connect our view model with the view to keep
it updated.
Model View ViewModel
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
ViewModel implementations will contain
all the logic state of the view. “Visibility”, “is
focused?”, “is clickable?”, “has been clicked?”
and keeps references to all the data related to
the view.
If you want to implement a reactive UI
you have to connect your ViewModels with
your events mechanism to be able to change
the view state changing the ViewModel
information.
Android UI components lifecycle will be
connected with the ViewModel as we were
already doing with MVP.
Model View ViewModel
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
In MVVM ViewModel implementation
will not contain a view instance, it is going to
use an events mechanism - data binding
engine - to communicate state changes to the
view implementation.
In this pattern, the “View” is not an
interface, is just an implementation using the
ViewModel. Activities, Fragments and Custom
Views will keep an instance of the View Model
and will register different listeners to know
when the View Model has changed.
Model View ViewModel
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
In the view implementation we are using - Activities, Fragments or Custom Views - we will
execute Action Commands offered by the ViewModel.
Model View ViewModel
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
If the user clicks a widget, the view
implementation will get an Action Command
from the View Model to execute it.
This implementation will be really
interesting when Action Commands are going
to represent UI actions that could be really
repetitive like open Activities or show Toasts.
Model View ViewModel
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
View Models represent big views like
Activities and return little ViewModels for
Custom Views or ListView rows. This
implementation is really easy to adopt if you
use Renderers.
Model View ViewModel
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
To implement MVVM is really convenient to connect our ViewModels
and view implementations using a binding engine. This is going to reduce
all the boilerplate needed to connect these elements manually and is
going to get a reactive view.
Model View ViewModel
RoboBinding AndroidBinding
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
¿ MVP vs MVVM ?
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
● MVVM data binding engines are really powerful, but not every library
supports obfuscation.
● MVP used to be easier to understand and implement.
● If you use little presenters your MVP implementation will look like
MVVM, be careful with the presenter size!
● MVP could be easier to test, depending on the binding engine you are
using.
● MVVM is going to be faster to implement, if you use binding, because
you have to write less code.
● Both patterns are going to improve code quality and testability.
MVP vs MVVM
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
The motivations of this patterns are the same. These
patterns try to solve the same problems.
Both patterns are going to abstract our model
implementation and view implementation. This is useful
to change any UI boundary layer implementation as you
wish.
MVP vs MVVM
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
To me, MVP is not better than MVVM and
vice versa.
Think about these patterns and use the one
you understand better.
MVP vs MVVM
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
● Avoid expensive tasks executed over the UI thread.
● Avoid code duplicity.
● Measure your UI performance using performance tools.
● Use themes, styles, dimensions and colors properly.
● Think in the UI layer like an isolated domain.
● Write testable code and test it.
● Return all the information needed to paint your UI.
● Implement your ListView and Adapters recycling your views.
● Write code for your buddies, not for the machine.
Some advices
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
Questions?
pedro@karumi.com
@pedro_g_s
github.com/pedrovgs
Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs

More Related Content

What's hot

Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
Knoldus Inc.
 
Vue.js
Vue.jsVue.js
인공지능(AI)과 사용자 경험(UX)
인공지능(AI)과 사용자 경험(UX)인공지능(AI)과 사용자 경험(UX)
인공지능(AI)과 사용자 경험(UX)
Billy Choi
 
Java null survival guide
Java null survival guideJava null survival guide
Java null survival guide
Sungchul Park
 
Fake It Outside-In TDD @XP2017
Fake It Outside-In TDD @XP2017Fake It Outside-In TDD @XP2017
Fake It Outside-In TDD @XP2017
David Völkel
 
Writing and using Hamcrest Matchers
Writing and using Hamcrest MatchersWriting and using Hamcrest Matchers
Writing and using Hamcrest Matchers
Shai Yallin
 
Angular Observables & RxJS Introduction
Angular Observables & RxJS IntroductionAngular Observables & RxJS Introduction
Angular Observables & RxJS Introduction
Rahat Khanna a.k.a mAppMechanic
 
Why Vue.js?
Why Vue.js?Why Vue.js?
Why Vue.js?
Jonathan Goode
 
Angular
AngularAngular
Angular
LearningTech
 
React js basics
React js basicsReact js basics
React js basics
Maulik Shah
 
Clean backends with NestJs
Clean backends with NestJsClean backends with NestJs
Clean backends with NestJs
Aymene Bennour
 
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Edureka!
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized
军 沈
 
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
Paulo Clavijo
 
Angular routing
Angular routingAngular routing
Angular routing
Sultan Ahmed
 
Observables in Angular
Observables in AngularObservables in Angular
Observables in Angular
Knoldus Inc.
 
Angular components
Angular componentsAngular components
Angular components
Sultan Ahmed
 
Vue js for beginner
Vue js for beginner Vue js for beginner
Vue js for beginner
Chandrasekar G
 
제 13회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [GAN 안 쓰는 세얼GAN이들] : 코로나 언택트 시대, 나의 홈트레이닝을 도와줄 AI...
제 13회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [GAN 안 쓰는 세얼GAN이들] : 코로나 언택트 시대, 나의 홈트레이닝을 도와줄 AI...제 13회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [GAN 안 쓰는 세얼GAN이들] : 코로나 언택트 시대, 나의 홈트레이닝을 도와줄 AI...
제 13회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [GAN 안 쓰는 세얼GAN이들] : 코로나 언택트 시대, 나의 홈트레이닝을 도와줄 AI...
BOAZ Bigdata
 
UX 아카데미 오픈프로젝트 [ 올리브영 - UX/UI 개선]
UX 아카데미 오픈프로젝트 [ 올리브영 - UX/UI 개선]UX 아카데미 오픈프로젝트 [ 올리브영 - UX/UI 개선]
UX 아카데미 오픈프로젝트 [ 올리브영 - UX/UI 개선]
RightBrain inc.
 

What's hot (20)

Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Vue.js
Vue.jsVue.js
Vue.js
 
인공지능(AI)과 사용자 경험(UX)
인공지능(AI)과 사용자 경험(UX)인공지능(AI)과 사용자 경험(UX)
인공지능(AI)과 사용자 경험(UX)
 
Java null survival guide
Java null survival guideJava null survival guide
Java null survival guide
 
Fake It Outside-In TDD @XP2017
Fake It Outside-In TDD @XP2017Fake It Outside-In TDD @XP2017
Fake It Outside-In TDD @XP2017
 
Writing and using Hamcrest Matchers
Writing and using Hamcrest MatchersWriting and using Hamcrest Matchers
Writing and using Hamcrest Matchers
 
Angular Observables & RxJS Introduction
Angular Observables & RxJS IntroductionAngular Observables & RxJS Introduction
Angular Observables & RxJS Introduction
 
Why Vue.js?
Why Vue.js?Why Vue.js?
Why Vue.js?
 
Angular
AngularAngular
Angular
 
React js basics
React js basicsReact js basics
React js basics
 
Clean backends with NestJs
Clean backends with NestJsClean backends with NestJs
Clean backends with NestJs
 
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized
 
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
 
Angular routing
Angular routingAngular routing
Angular routing
 
Observables in Angular
Observables in AngularObservables in Angular
Observables in Angular
 
Angular components
Angular componentsAngular components
Angular components
 
Vue js for beginner
Vue js for beginner Vue js for beginner
Vue js for beginner
 
제 13회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [GAN 안 쓰는 세얼GAN이들] : 코로나 언택트 시대, 나의 홈트레이닝을 도와줄 AI...
제 13회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [GAN 안 쓰는 세얼GAN이들] : 코로나 언택트 시대, 나의 홈트레이닝을 도와줄 AI...제 13회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [GAN 안 쓰는 세얼GAN이들] : 코로나 언택트 시대, 나의 홈트레이닝을 도와줄 AI...
제 13회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [GAN 안 쓰는 세얼GAN이들] : 코로나 언택트 시대, 나의 홈트레이닝을 도와줄 AI...
 
UX 아카데미 오픈프로젝트 [ 올리브영 - UX/UI 개선]
UX 아카데미 오픈프로젝트 [ 올리브영 - UX/UI 개선]UX 아카데미 오픈프로젝트 [ 올리브영 - UX/UI 개선]
UX 아카데미 오픈프로젝트 [ 올리브영 - UX/UI 개선]
 

Viewers also liked

Software Design patterns on Android English
Software Design patterns on Android EnglishSoftware Design patterns on Android English
Software Design patterns on Android English
Pedro Vicente Gómez Sánchez
 
Is Activity God? ~ The MVP Architecture ~
Is Activity God? ~ The MVP Architecture ~Is Activity God? ~ The MVP Architecture ~
Is Activity God? ~ The MVP Architecture ~
Ken William
 
Android cleanarchitecture
Android cleanarchitectureAndroid cleanarchitecture
Android cleanarchitecture
Tomoaki Imai
 
Design pattern in android
Design pattern in androidDesign pattern in android
Design pattern in androidJay Kumarr
 
Karumi Dojo: Kata Maxibon
Karumi Dojo: Kata MaxibonKarumi Dojo: Kata Maxibon
Karumi Dojo: Kata Maxibon
Pedro Vicente Gómez Sánchez
 
Dependency injection on Android
Dependency injection on AndroidDependency injection on Android
Dependency injection on Android
Pedro Vicente Gómez Sánchez
 
Android Clean Architecture for Dummies
Android Clean Architecture for DummiesAndroid Clean Architecture for Dummies
Android Clean Architecture for Dummies
Kengo Suzuki
 
Android Design Principles and Popular Patterns
Android Design Principles and Popular PatternsAndroid Design Principles and Popular Patterns
Android Design Principles and Popular Patterns
Faiz Malkani
 
World-Class Testing Development Pipeline for Android
 World-Class Testing Development Pipeline for Android World-Class Testing Development Pipeline for Android
World-Class Testing Development Pipeline for Android
Pedro Vicente Gómez Sánchez
 
Clean architecture: Android
Clean architecture: AndroidClean architecture: Android
Clean architecture: Androidintive
 
Karumi Dojo - String Calculator Kata
Karumi Dojo - String Calculator KataKarumi Dojo - String Calculator Kata
Karumi Dojo - String Calculator Kata
Pedro Vicente Gómez Sánchez
 
The Good Developer - Spanish
The Good Developer - SpanishThe Good Developer - Spanish
The Good Developer - Spanish
Pedro Vicente Gómez Sánchez
 
Kata Contacts
Kata ContactsKata Contacts
A Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidA Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on Android
Outware Mobile
 
Clean architecture
Clean architectureClean architecture
Clean architectureandbed
 
Android MVVM
Android MVVMAndroid MVVM
Working with Android TV - English
Working with Android TV - EnglishWorking with Android TV - English
Working with Android TV - English
Pedro Vicente Gómez Sánchez
 
Lightning Talk - Clean Architecture and Design
Lightning Talk - Clean Architecture and DesignLightning Talk - Clean Architecture and Design
Lightning Talk - Clean Architecture and DesignDeivison Sporteman
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
Badoo
 

Viewers also liked (20)

Software Design patterns on Android English
Software Design patterns on Android EnglishSoftware Design patterns on Android English
Software Design patterns on Android English
 
Is Activity God? ~ The MVP Architecture ~
Is Activity God? ~ The MVP Architecture ~Is Activity God? ~ The MVP Architecture ~
Is Activity God? ~ The MVP Architecture ~
 
Android cleanarchitecture
Android cleanarchitectureAndroid cleanarchitecture
Android cleanarchitecture
 
Design pattern in android
Design pattern in androidDesign pattern in android
Design pattern in android
 
Karumi Dojo: Kata Maxibon
Karumi Dojo: Kata MaxibonKarumi Dojo: Kata Maxibon
Karumi Dojo: Kata Maxibon
 
Dependency injection on Android
Dependency injection on AndroidDependency injection on Android
Dependency injection on Android
 
Android Clean Architecture for Dummies
Android Clean Architecture for DummiesAndroid Clean Architecture for Dummies
Android Clean Architecture for Dummies
 
Android Design Principles and Popular Patterns
Android Design Principles and Popular PatternsAndroid Design Principles and Popular Patterns
Android Design Principles and Popular Patterns
 
World-Class Testing Development Pipeline for Android
 World-Class Testing Development Pipeline for Android World-Class Testing Development Pipeline for Android
World-Class Testing Development Pipeline for Android
 
Clean architecture: Android
Clean architecture: AndroidClean architecture: Android
Clean architecture: Android
 
Karumi Dojo - String Calculator Kata
Karumi Dojo - String Calculator KataKarumi Dojo - String Calculator Kata
Karumi Dojo - String Calculator Kata
 
The Good Developer - Spanish
The Good Developer - SpanishThe Good Developer - Spanish
The Good Developer - Spanish
 
Kata Contacts
Kata ContactsKata Contacts
Kata Contacts
 
A Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on AndroidA Separation of Concerns: Clean Architecture on Android
A Separation of Concerns: Clean Architecture on Android
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Effective Android UI - spanish
Effective Android UI - spanishEffective Android UI - spanish
Effective Android UI - spanish
 
Android MVVM
Android MVVMAndroid MVVM
Android MVVM
 
Working with Android TV - English
Working with Android TV - EnglishWorking with Android TV - English
Working with Android TV - English
 
Lightning Talk - Clean Architecture and Design
Lightning Talk - Clean Architecture and DesignLightning Talk - Clean Architecture and Design
Lightning Talk - Clean Architecture and Design
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 

Similar to Effective Android UI - English

Frontend Development vs Backend Development | Detailed Comparison
Frontend Development vs Backend Development | Detailed ComparisonFrontend Development vs Backend Development | Detailed Comparison
Frontend Development vs Backend Development | Detailed Comparison
Mariya James
 
UpdatedMuhammadBilalResume.docx (1)
UpdatedMuhammadBilalResume.docx (1)UpdatedMuhammadBilalResume.docx (1)
UpdatedMuhammadBilalResume.docx (1)Muhammad Bilal Ahmed
 
DotVVM Fundamentals
DotVVM FundamentalsDotVVM Fundamentals
DotVVM Fundamentals
Daniel Gomez Jaramillo
 
VS Code and Modern Development Environment Preview
VS Code and Modern Development Environment PreviewVS Code and Modern Development Environment Preview
VS Code and Modern Development Environment Preview
Roberto Stefanetti
 
Interim Report.docx - vsiogap3d.googlecode.com
Interim Report.docx - vsiogap3d.googlecode.comInterim Report.docx - vsiogap3d.googlecode.com
Interim Report.docx - vsiogap3d.googlecode.combutest
 
Kony Visualizer Puts Mobile Apps Features Control in Hands of Those Closest t...
Kony Visualizer Puts Mobile Apps Features Control in Hands of Those Closest t...Kony Visualizer Puts Mobile Apps Features Control in Hands of Those Closest t...
Kony Visualizer Puts Mobile Apps Features Control in Hands of Those Closest t...
Dana Gardner
 
Arquitectura MVVM para la construcción de aplicaciones Windows Store
Arquitectura MVVM para la construcción de aplicaciones Windows StoreArquitectura MVVM para la construcción de aplicaciones Windows Store
Arquitectura MVVM para la construcción de aplicaciones Windows Store
Damian Schenkelman
 
Business management application
Business management applicationBusiness management application
Business management application
Pritam Tirpude
 
How to Become a Front-End Developer? Step-by-Step Guide by Careervira
How to Become a Front-End Developer? Step-by-Step Guide by CareerviraHow to Become a Front-End Developer? Step-by-Step Guide by Careervira
How to Become a Front-End Developer? Step-by-Step Guide by Careervira
Careervira
 
Android training-in-gurgaon
Android training-in-gurgaonAndroid training-in-gurgaon
Android training-in-gurgaon
AP EDUSOFT
 
3D Web Visualization 1
3D Web Visualization 13D Web Visualization 1
3D Web Visualization 1
shilpabhartiyaPrototech
 
3D Web Visualization
3D Web Visualization 3D Web Visualization
3D Web Visualization
ProtoTech Solutions
 
who we are
who we arewho we are
who we are
AlenDuranovic
 
Anup_Resume_Update_9_1_16
Anup_Resume_Update_9_1_16Anup_Resume_Update_9_1_16
Anup_Resume_Update_9_1_16Anup Tyagi
 
Wecreate
WecreateWecreate
Wecreate
Jos De Roeck
 

Similar to Effective Android UI - English (20)

Frontend Development vs Backend Development | Detailed Comparison
Frontend Development vs Backend Development | Detailed ComparisonFrontend Development vs Backend Development | Detailed Comparison
Frontend Development vs Backend Development | Detailed Comparison
 
UpdatedMuhammadBilalResume.docx (1)
UpdatedMuhammadBilalResume.docx (1)UpdatedMuhammadBilalResume.docx (1)
UpdatedMuhammadBilalResume.docx (1)
 
DotVVM Fundamentals
DotVVM FundamentalsDotVVM Fundamentals
DotVVM Fundamentals
 
VS Code and Modern Development Environment Preview
VS Code and Modern Development Environment PreviewVS Code and Modern Development Environment Preview
VS Code and Modern Development Environment Preview
 
Interim Report.docx - vsiogap3d.googlecode.com
Interim Report.docx - vsiogap3d.googlecode.comInterim Report.docx - vsiogap3d.googlecode.com
Interim Report.docx - vsiogap3d.googlecode.com
 
Kony Visualizer Puts Mobile Apps Features Control in Hands of Those Closest t...
Kony Visualizer Puts Mobile Apps Features Control in Hands of Those Closest t...Kony Visualizer Puts Mobile Apps Features Control in Hands of Those Closest t...
Kony Visualizer Puts Mobile Apps Features Control in Hands of Those Closest t...
 
Arquitectura MVVM para la construcción de aplicaciones Windows Store
Arquitectura MVVM para la construcción de aplicaciones Windows StoreArquitectura MVVM para la construcción de aplicaciones Windows Store
Arquitectura MVVM para la construcción de aplicaciones Windows Store
 
Business management application
Business management applicationBusiness management application
Business management application
 
Vrushali_Resume
Vrushali_ResumeVrushali_Resume
Vrushali_Resume
 
How to Become a Front-End Developer? Step-by-Step Guide by Careervira
How to Become a Front-End Developer? Step-by-Step Guide by CareerviraHow to Become a Front-End Developer? Step-by-Step Guide by Careervira
How to Become a Front-End Developer? Step-by-Step Guide by Careervira
 
Android training-in-gurgaon
Android training-in-gurgaonAndroid training-in-gurgaon
Android training-in-gurgaon
 
CV
CVCV
CV
 
GE Predix - The IIoT Platform
GE Predix - The IIoT PlatformGE Predix - The IIoT Platform
GE Predix - The IIoT Platform
 
3D Web Visualization 1
3D Web Visualization 13D Web Visualization 1
3D Web Visualization 1
 
3D Web Visualization
3D Web Visualization 3D Web Visualization
3D Web Visualization
 
Devraj_Nataraj_CV_PDF
Devraj_Nataraj_CV_PDFDevraj_Nataraj_CV_PDF
Devraj_Nataraj_CV_PDF
 
GAURAV_MAKKAR
GAURAV_MAKKARGAURAV_MAKKAR
GAURAV_MAKKAR
 
who we are
who we arewho we are
who we are
 
Anup_Resume_Update_9_1_16
Anup_Resume_Update_9_1_16Anup_Resume_Update_9_1_16
Anup_Resume_Update_9_1_16
 
Wecreate
WecreateWecreate
Wecreate
 

Recently uploaded

Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 

Recently uploaded (20)

Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 

Effective Android UI - English

  • 1. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Effective Android UI Pedro Vicente Gómez Sánchez Android Expert pedro@karumi.com @pedro_g_s github.com/pedrovgs
  • 2. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
  • 3. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Irene Herranz Managing Director Alberto Gragera Technical Director Jorge Barroso Android Expert Davide Mendolia Full Stack Engineer
  • 4. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs This talk is the continuation of Software Design Patterns on Android http://www.slideshare.net/PedroVicenteGmezSnch/software-design-patterns-on-android
  • 5. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Is the UI code less important? Are we using Android SDK properly? How can I improve the UI code?
  • 6. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs ● Introduction. ● Resources and qualifiers. ● Custom Views. ● Model View Presenter. ● Model View ViewModel. ● MVP vs MVVM. ● Some advices.
  • 7. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs https://github.com/pedrovgs/EffectiveAndroidUI
  • 8. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs ● MVP and MVVM samples. ● How to work with Fragments. ● Communication between Fragments and Activities. ● How to use Dagger as Dependency Injector. ● How to use resources to support different screen densities, device orientation and different Android versions. ● How to use styles and themes. ● How to use Navigator or ActionCommand to implement activities navigation. ● How to use custom qualifiers with resources. ● How to use different layouts: RelativeLayout, LinearLayout, FrameLayout, etc. ● Usage of merge, include and view stub. ● How to implement a ListView using Renderers. ● Simple Interactors implementation described in “Software Design Patterns on Android” talk. ● How to use Dagger with different scopes, Application scope and Activity scope. Introduction https://github.com/pedrovgs/EffectiveAndroidUI
  • 9. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Introduction: S4 - Android 4.4.2
  • 10. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Introduction: DraggablePanel https://github.com/pedrovgs/DraggablePanel
  • 11. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Introduction: MDPI device
  • 12. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Introduction: Nexus 7 and Nexus 10 - Android 4.4.4 Portrait Landscape
  • 13. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs How can we change the UI depending on the device?
  • 14. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Android resources are one of the Android SDK powerful tools to work with the UI layer. Some common resources are: ● Color: Colors available for your application. In colors.xml you can declare your color palette. ● Drawable: Shapes and statics assets ready to be used in Image components as src or background. ● Layout: XML files to describe the application UI and to be inflated by the system. ● Menu: Android menus can be described in xml files and used directly from our activities. ● Integer: Integer values ready to be used in xml files or java code. ● XML: XML configuration files that can be used to indicate different configuration parameters. Not really common. Resources and qualifiers
  • 15. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs For complex projects where we have to support tons of different devices with different screen densities and sizes and different Android API versions we need to use our resources and qualifiers properly to get the max development performance. Qualifiers are really important to work with different Android configurations. We can prepare different resources for different Android configurations and these resources are going to be provided automatically. Configuration based on qualifiers: ● Screen density: ldpi, mdpi, hdpi, xhdpi, etc. ● Language: es, en, fr, en-rUS, etc. ● Min width: sw600dp, sw720dip. ● Available width or height: w720dp, h1024dp. ● Screen orientation: landscape, portrait. ● Android API level: v7, v8, v9, etc. Resources and qualifiers
  • 16. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs How have we used resources and qualifiers in Effective Android UI project? ● Layouts: ○ layout-v10: Android 2.X is using one layout with just one fragment. ○ layout-v11: Android 3.X y 4.X (except tablets in landscape). ○ layout-sw600dp-land: Layout with two fragments in landscape. ● Values: ○ values-mdpi: Mdpi and ldpi devices are using one column for the GridView and different ImageView height. ○ values-hdpi: Hdpi, xhdpi and xxhdpi devices with screen width lower than 820 dip are using two columns for the GridView and another ImageView height. ○ values-w820: Devices with more than 820 dip width are going to use 3 columns for the GridView configuration. Resources and qualifiers
  • 17. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Resources and qualifiers http://developer.android.com/guide/topics/resources/providing-resources.html How it’s working if we haven’ t declared every possible configuration?
  • 18. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Custom Views
  • 19. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Main motivations to use custom views are: ● Create a non implemented Android SDK widget. ● Group presentation logic for different views. Really useful with MVVM. ● Add semantic to UI layer components. ● Avoid code duplicity. Custom Views
  • 20. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs There are 5 approaches to implement your custom views: ● Extend an already written widget like TextView, ImageView. ● Extend View and override onDraw method using the Canvas API. ● Extend one Layout/ViewGroup and inflate your own layout file. ● Extend one Layout/ViewGroup and wait for views added by other developers using this custom view. ● Inflate different layouts provided by the custom view client Custom Views
  • 21. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Custom Views http://github.com/pedrovgs/Nox
  • 22. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Are you ready to talk about MVP and MVVM?
  • 23. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Model View Presenter
  • 24. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Model View Presenter is a software design pattern that comes from MVC and is used to build user interfaces. In this pattern, the “presenter” has the responsibility to implement all the presentation logic and data transformation in order to send information to the view. Works as an abstraction between the UI layer and the business logic layer. The “view” in MVP is going to be abstracted using an interface implemented by Android components. Model View Presenter
  • 25. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs The main problem that MVP solves is related to testing, to avoid coupling and to avoid code duplicity. The usage of MVP improves the testability of your code because we can test all our UI code without executing framework code, just with unit tests. To do this, all the presentation logic is moved to the presenter. The view implementation is going to be really lightweight. Model View Presenter
  • 26. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs One of the key points related to MVP is to leave your presenters free of Android dependencies. By removing all your Android code from your presenters you’ll be able to test it easily. Model View Presenter
  • 27. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Using MVP, Activity Fragments and Custom Views are going to implement a presenter “view” interface and are going to be configured as presenter views. Views are going to contain code to implement your view details - described in the View interface - and to connect user actions with presenters. Model View Presenter
  • 28. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
  • 29. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Even if we are using MVP, we need to connect our component lifecycle to our presenter in order to notify whether the view is ready to work or not. Some methods like “onSavedInstanceState” will update our presenter state if needed. Model View Presenter
  • 30. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Model View Presenter To implement user events - like a button clicked - our view implementation will delegate to the presenter to take some decisions.
  • 31. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs If you want to extract navigation implementation out of Activities or Fragments you can use a “Navigator”. Using one Navigator you can avoid some cycles in the collaboration diagram between view implementations and presenter when a user action has to open another activity or modify the navigation stack. To do this, you need to be able to inject Activity context using a dependency injector. Model View Presenter
  • 32. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Model View ViewModel
  • 33. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Model View ViewModel is a software design pattern derived from Presentation Model (by Martin Fowler). It’s commonly used to build user interfaces and used by Microsoft to implement Windows applications. The power of this pattern is in the usage of a binding engine, but we can use it without one. The binding engine is going to avoid all the boilerplate code we have to write to connect our view model with the view to keep it updated. Model View ViewModel
  • 34. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs ViewModel implementations will contain all the logic state of the view. “Visibility”, “is focused?”, “is clickable?”, “has been clicked?” and keeps references to all the data related to the view. If you want to implement a reactive UI you have to connect your ViewModels with your events mechanism to be able to change the view state changing the ViewModel information. Android UI components lifecycle will be connected with the ViewModel as we were already doing with MVP. Model View ViewModel
  • 35. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs In MVVM ViewModel implementation will not contain a view instance, it is going to use an events mechanism - data binding engine - to communicate state changes to the view implementation. In this pattern, the “View” is not an interface, is just an implementation using the ViewModel. Activities, Fragments and Custom Views will keep an instance of the View Model and will register different listeners to know when the View Model has changed. Model View ViewModel
  • 36. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs In the view implementation we are using - Activities, Fragments or Custom Views - we will execute Action Commands offered by the ViewModel. Model View ViewModel
  • 37. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
  • 38. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs If the user clicks a widget, the view implementation will get an Action Command from the View Model to execute it. This implementation will be really interesting when Action Commands are going to represent UI actions that could be really repetitive like open Activities or show Toasts. Model View ViewModel
  • 39. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs View Models represent big views like Activities and return little ViewModels for Custom Views or ListView rows. This implementation is really easy to adopt if you use Renderers. Model View ViewModel
  • 40. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs To implement MVVM is really convenient to connect our ViewModels and view implementations using a binding engine. This is going to reduce all the boilerplate needed to connect these elements manually and is going to get a reactive view. Model View ViewModel RoboBinding AndroidBinding
  • 41. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs ¿ MVP vs MVVM ?
  • 42. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs
  • 43. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs ● MVVM data binding engines are really powerful, but not every library supports obfuscation. ● MVP used to be easier to understand and implement. ● If you use little presenters your MVP implementation will look like MVVM, be careful with the presenter size! ● MVP could be easier to test, depending on the binding engine you are using. ● MVVM is going to be faster to implement, if you use binding, because you have to write less code. ● Both patterns are going to improve code quality and testability. MVP vs MVVM
  • 44. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs The motivations of this patterns are the same. These patterns try to solve the same problems. Both patterns are going to abstract our model implementation and view implementation. This is useful to change any UI boundary layer implementation as you wish. MVP vs MVVM
  • 45. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs To me, MVP is not better than MVVM and vice versa. Think about these patterns and use the one you understand better. MVP vs MVVM
  • 46. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs ● Avoid expensive tasks executed over the UI thread. ● Avoid code duplicity. ● Measure your UI performance using performance tools. ● Use themes, styles, dimensions and colors properly. ● Think in the UI layer like an isolated domain. ● Write testable code and test it. ● Return all the information needed to paint your UI. ● Implement your ListView and Adapters recycling your views. ● Write code for your buddies, not for the machine. Some advices
  • 47. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs Questions? pedro@karumi.com @pedro_g_s github.com/pedrovgs
  • 48. Pedro V. Gómez Sánchez - pedro@karumi.com - @pedro_g_s - github.com/pedrovgs