-
-
Save UndefinedPotato/c9011994d7e8958c50d6b92f7dcbfc37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends Activity implements MapInteractor { | |
MapView mapView; | |
public void onCreate() { | |
// View A from example | |
MapFragment mapFragment = MapFragment.newInstance(); // Implements MapView interface | |
// View B from example | |
TaskFragment taskFragment = TaskFragment.newInstance(); | |
setTopFragment(mapFragment); | |
setBottomFragment(taskFragment); | |
mapView = mapFragment; | |
} | |
@Override | |
public void putTaskOnMap(Task task) { | |
// sends off to map view which goes to the map presenter to update the model then updates the view | |
mapView.putTaskOnMap(task); | |
} | |
@Override | |
public void centerMap() { | |
mapView.centerMap(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TaskFragment extends Fragment implements TaskContract.View { | |
private MapInteractor mapInteractor; | |
@Override | |
public void onAttach(Activity activity) { | |
mapInteractor = (MapInteractor) activity; | |
} | |
@Override | |
public void putTaskOnMap(Task task) { | |
mapInteractor.putTaskOnMap(task); | |
} | |
@Override | |
public void centerMap() { | |
mapInteractor.centerMap(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Presenter B from the example | |
public class TaskPresenter { | |
void start() { | |
// TaskPresenter -> view -> activity -> MapView | |
view.centerMap(); | |
// other ideas | |
// mapInteractor.centerMap(); | |
// bus.post(centerMapEvent); | |
// mapView.centerMap(); | |
} | |
void getData() { | |
Task task = taskRepository.getTask("id"); | |
view.display(task); | |
view.putOnMap(task); | |
// other ideas but doesn't make sense for centering the map | |
// mapMarkerStore.addMapMarker(task); // MapPresenter would listen for changes and add or remove map makrer | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment