Using MVP...
Create a View interface that has ListView, DetailView, and
ThumbnailView implement it. Your presenter will take a default view
implementation. On change of view, apply the different implementation
to your view and update your view.
class Result {
String url;
String data1;
String data2;
...
}
interface View {
public displayResults(List<Result> results);
...
}
class ListView implements View {
displayResults(List<Result> results) {
for (result : results) {
// display each row.
}
}
...
}
...
class Presenter {
View currentView;
Presenter() {
this.listView = new ListView();
this.detailView = new DetailView();
this.currentView = listView; // Default.
}
onViewChange(enum viewType) {
switch viewType:
this.currentView = detailView;
...
view.displayResults(results); // Display results with new view.