3. 3
Bez rozdziału
▪Co robią Activities
▪co powinny
▪uruchamianie usług
▪komunikacja z API
▪obsługa user input
▪obsługa bazy
▪I/O
▪zarządzanie fragmentami
▪występy w reality show
▪jazda autostopem
12. MVP – testy
@Override
protected void setUp() throws Exception {
super.setUp();
screen = mock(RegistrationScreen.class);
presenter = new RegistrationPresenter(screen, null);
}
/**
* Once Presenter gets notified an account was successfully created,
* it must request from the Screen that we move on to the next screen
*/
public void testRegistration_whenAccountCreated_requestsOpeningAnotherActivity() {
// ACT
presenter.handleCreateAccountResponse(successfullyCreatedAccountResponse());
// ASSERT
verify(screen).goToNextScreen();
verify(screen, never()).showNumberInputError();
}
14. MVP – elastyczność
Presenter A View 1
Presenter A View 2
View 1 Presenter A
View 1 Presenter B
MegapresenterÜberview
Presenter A View 1 Presenter B View 2
15. MVP – elastyczność
Blokada PIN
Ustawianie (powtórzenie 2x)
Tryb blokady (bez rezygnacji)
Wyłączanie (z rezygnacją)
20. 20
MVP – podsumowanie
łatwe
dumb View
Presenter wie jak aplikacja działa
Presenter nie wie, że jest w Androidzie
testowalność, elastyczność, radość
25. 25
M V VM
private static class User extends BaseObservable {
private String name;
@Bindable
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
notifyPropertyChanged(BR.name);
}
}
31. 31
MVVM – podsumowanie
View: żadnych więcej @id
ViewModel: modeluje widok
Brakuje:
Two-Mode
pełna obsługa list (do uzupełnienia)
wsparcie w IDE
gwarancja stabilności / wstecznej kompatybilności