Java tutorial
/* * Copyright 2012 Nabeel Mukhtar * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.appspot.socialinquirer.client; import com.appspot.socialinquirer.client.activity.ActivityActivity; import com.appspot.socialinquirer.client.activity.HomeActivity; import com.appspot.socialinquirer.client.activity.NetworkActivity; import com.appspot.socialinquirer.client.activity.PageActivity; import com.appspot.socialinquirer.client.activity.PagesActivity; import com.appspot.socialinquirer.client.activity.QuestionActivity; import com.appspot.socialinquirer.client.activity.QuestionsActivity; import com.appspot.socialinquirer.client.activity.SettingsActivity; import com.appspot.socialinquirer.client.activity.TopicsActivity; import com.appspot.socialinquirer.client.place.ActivityPlace; import com.appspot.socialinquirer.client.place.HomePlace; import com.appspot.socialinquirer.client.place.NetworkPlace; import com.appspot.socialinquirer.client.place.NewspaperPlace; import com.appspot.socialinquirer.client.place.PagesPlace; import com.appspot.socialinquirer.client.place.QuestionPlace; import com.appspot.socialinquirer.client.place.QuestionsPlace; import com.appspot.socialinquirer.client.place.SettingsPlace; import com.appspot.socialinquirer.client.place.TopicsPlace; import com.google.gwt.activity.shared.Activity; import com.google.gwt.activity.shared.ActivityMapper; import com.google.gwt.place.shared.Place; /** * The Class AppActivityMapper. */ public class AppActivityMapper implements ActivityMapper { /** The client factory. */ private ClientFactory clientFactory; /** * Instantiates a new app activity mapper. * * @param clientFactory the client factory */ public AppActivityMapper(ClientFactory clientFactory) { super(); this.clientFactory = clientFactory; } /* * (non-Javadoc) * * @see com.google.gwt.activity.shared.ActivityMapper#getActivity(com.google.gwt.place.shared.Place) */ @Override public Activity getActivity(Place place) { // This is begging for GIN if (place instanceof HomePlace) return new HomeActivity((HomePlace) place, clientFactory); else if (place instanceof NetworkPlace) return new NetworkActivity((NetworkPlace) place, clientFactory); // else if (place instanceof DashboardPlace) // return new DashboardActivity((DashboardPlace) place, // clientFactory); else if (place instanceof QuestionPlace) return new QuestionActivity((QuestionPlace) place, clientFactory); else if (place instanceof QuestionsPlace) return new QuestionsActivity((QuestionsPlace) place, clientFactory); else if (place instanceof ActivityPlace) return new ActivityActivity((ActivityPlace) place, clientFactory); else if (place instanceof PagesPlace) return new PagesActivity((PagesPlace) place, clientFactory); else if (place instanceof SettingsPlace) return new SettingsActivity((SettingsPlace) place, clientFactory); else if (place instanceof NewspaperPlace) return new PageActivity((NewspaperPlace) place, clientFactory); else if (place instanceof TopicsPlace) return new TopicsActivity((TopicsPlace) place, clientFactory); return null; } }