User Login Use Case
data
result
Places list Use Case
data
result
Place Show Use Case
data
result
User Login Screen has -> 1 Activity + 1 Fragment
Places list -> 1 Activity + 1 Fragment
Places list -> 1 Activity + 1 Fragment
Prefer screen by each feature separately
User Login
Data
Primary Course
1. Fill form and request login with above data
2. System validates data
3. System authenticates user
4. System redirects to main screen
Exception Course
1. System delivers validation error
2. System delivers auth error
In the next presentation we will show MVP and cleaner layers
// RETROFIT //
// Define API
public interface GitHubService {
@GET("/users/{user}/repos")
Call<List<Repo>> listRepos(@Path("user") String user);
}
// Define service client to use for calls
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.github.com")
.build();
GitHubService service = retrofit.create(GitHubService.class);
// Make Asynchronous HTTP Call
Call<List<Repo>> repos = service.listRepos("octocat");// OTTO //
// Bus to send events
Bus bus = new Bus();
// Sends an event
bus.post(new AnswerAvailableEvent(42));
// Listen for an Event
@Subscribe public void answerAvailable(AnswerAvailableEvent event) {
// TODO: React to the event somehow!
}// DAGGER2 //
// Inject Constructor
class Thermosiphon implements Pump {
private final Heater heater;
@Inject
Thermosiphon(Heater heater) {
this.heater = heater;
}
...
}
// Inject fields
class CoffeeMaker {
@Inject Heater heater;
@Inject Pump pump;
...
}// This is the DEFAULT
activity.subtitle = (android.widget.TextView) activity.findViewById(R.id.title);
activity.footer = (android.widget.TextView) activity.findViewById(R.id.subtitle);
activity.title = (android.widget.TextView) activity.findViewById(R.id.footer);
// BUT This is COOL
class ExampleActivity extends Activity {
@Bind(R.id.title) TextView title;
@Bind(R.id.subtitle) TextView subtitle;
@Bind(R.id.footer) TextView footer;
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_activity);
ButterKnife.bind(this);
// TODO Use fields...
}
}
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png")
.into(imageView);Package by feature
Use Espresso & Robolectric for test