Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The android past · present · future#
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Erik Jhordan Rey
April 21, 2016
2
670
The android past · present · future#
GDG Open Lima hangouts, April 2016
Erik Jhordan Rey
April 21, 2016
Tweet
Share
More Decks by Erik Jhordan Rey
See All by Erik Jhordan Rey
The android eras tour
erikjhordan_rey
0
190
Android Apps in modular structure paradigms
erikjhordan_rey
0
310
Discipline your Android builds to be delivered at any time.
erikjhordan_rey
0
660
Technologies to develop mobile apps
erikjhordan_rey
1
300
Dependency Injection the masterpiece on Android
erikjhordan_rey
0
560
Building scalable applications inspired into Micro-service Architecture
erikjhordan_rey
0
250
Building scalable applications inspired into Micro-service Architecture
erikjhordan_rey
0
570
Pragmatic Mobile Testing Strategies
erikjhordan_rey
1
680
Android Oreo Behind Scenes
erikjhordan_rey
0
700
Featured
See All Featured
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
450
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
480
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Tell your own story through comics
letsgokoyo
1
840
Optimizing for Happiness
mojombo
378
71k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
180
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
180
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
230
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
67
37k
Transcript
None
None
• • •
None
• • •
None
None
None
None
None
None
Model View Presenter View Presenter Model User interaction notify user
event request data Update UI with entities delivers entities
Kata
MVP Example
public interface ArtistsMvpView extends MvpView{ void showLoading(); void hideLoading(); void
showArtistNotFoundMessage(); void showConnectionErrorMessage(); void renderArtists(List<Artist> artists); void launchArtistDetail(Artist artist); } View
public class ArtistsPresenter implements Presenter<ArtistsMvpView>, ArtistCallback { private ArtistsMvpView artistsMvpView;
private ArtistsInteractor artistsInteractor; public ArtistsPresenter() { } @Override public void setView(ArtistsMvpView view) { if (view == null) throw new IllegalArgumentException("You can't set a null view"); artistsMvpView = view; artistsInteractor = new ArtistsInteractor(artistsMvpView.getContext()); } @Override public void detachView() { artistsMvpView = null; } public void onSearchArtist(String string) { artistsMvpView.showLoading(); artistsInteractor.loadDataFromApi(string, this); } public void launchArtistDetail(Artist artist) { artistsMvpView.launchArtistDetail(artist); } //more methods } Presenter
Interactor public class ArtistsInteractor { public void loadDataFromApi(String query, ArtistCallback
artistCallback) { mSpotifyService.searchArtist(query) .subscribeOn(mSpotifyApp.SubscribeScheduler()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(ArtistsSearch -> onSuccess(ArtistsSearch, artistCallback), throwable -> onError(throwable, artistCallback)); } // more methods }
User interaction public void onSearchArtist(String string) { artistsMvpView.showLoading(); artistsInteractor.loadDataFromApi(string, this);
} View Presenter public void loadDataFromApi(String query, ArtistCallback artistCallback) { mSpotifyService.searchArtist(query) .subscribeOn(mSpotifyApp.SubscribeScheduler()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(ArtistsSearch -> onSuccess(ArtistsSearch, artistCallback), throwable -> onError(throwable, artistCallback)); } Interactor @Override public boolean onQueryTextSubmit(String query) { artistsPresenter.onSearchArtist(query); return true; } Notify user event Request data Search an Artist
private void onSuccess(ArtistsSearch artistsSearch, ArtistCallback artistCallback) { if (artistsSearch.getArtists() !=
null) { if (artistsSearch.getArtists().size() > 0) { artistCallback.onResponse(artistsSearch.getArtists()); } else { artistCallback.onArtistNotFound(); } } Delivers entities Interactor @Override public void onResponse(List<Artist> artists) { artistsMvpView.hideLoading(); artistsMvpView.renderArtists(artists); } Presenter View Update UI with entities @Override public void renderArtists(List<Artist> artists) { ArtistsAdapter adapter = (ArtistsAdapter) rv_artist.getAdapter(); adapter.setArtists(artists); adapter.notifyDataSetChanged(); }
None
None
None
Model View ViewModel View ViewModel Model DataBinding and Commands ViewModel
updates the model Send Notifications Send Notifications
None
• •
dataBinding { enabled = true }
None
None
None
Kata
None
None
• These patterns try to solve the same problems •
Both patterns are going to improve code quality and testability. • Think about these patterns and use the one you understand better.
None
• Effective Android UI https://www.youtube. com/watch?v=N6yqe88ysNw • Data Binding --
Write Apps Faster https://www. youtube.com/watch?v=NBbeQMOcnZ0 • MVVM_Hacker_News https://github.com/hitherejoe/MVVM_Hacker_News • My Personal Blog https://erikcaffrey.github.io
Erik Jhordan González Reyes Android Developer +Erik Jhordan Rey Caffrey
@ErikJhordan_Rey erikcaffrey erikcaffrey.github.io
None