Back to project page AndroidWeatherBuoyDemo.
The source code is released under:
Apache License
If you think the Android project AndroidWeatherBuoyDemo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.kevinrschultz.weatherbuoy.ui; // ww w.j ava 2 s . c o m import com.kevinrschultz.weatherbuoy.data.FakeBuoyListingGenerator; import com.kevinrschultz.weatherbuoy.model.BuoyDescription; import com.kevinrschultz.weatherbuoy.model.Region; import java.util.List; /** * @author Kevin Schultz (kschultz@gilt.com) */ public class BuoyListingPresenter { private BuoyListingView view; public BuoyListingPresenter() { this.view = new NoOpBuoyListingView(); } // Lifecycle methods public void setView(BuoyListingView view) { this.view = view; selectRegion(Region.ATLANTIC); } public void clearView() { setView(new NoOpBuoyListingView()); } // Business logic public void selectRegion(Region region) { if (region == null) { region = Region.ATLANTIC; } List<BuoyDescription> descriptions; switch(region) { case ATLANTIC: descriptions = FakeBuoyListingGenerator.makeAtlanticBuoyListings(); break; case CARIBBEAN: descriptions = FakeBuoyListingGenerator.makeCaribbeanBuoyListings(); break; case PACIFIC: descriptions = FakeBuoyListingGenerator.makePacificBuoyListings(); break; default: descriptions = FakeBuoyListingGenerator.makeAtlanticBuoyListings(); } view.updateList(descriptions); } private static class NoOpBuoyListingView implements BuoyListingView { @Override public void updateList(List<BuoyDescription> descriptionList) { } } }