com.sangnd.gwt.faceme.client.activities.PhoneActivityMapper.java Source code

Java tutorial

Introduction

Here is the source code for com.sangnd.gwt.faceme.client.activities.PhoneActivityMapper.java

Source

/*
 * Copyright 2013 heroandtn3 (heroandtn3 [at] gmail.com - www.sangnd.com
 * )
 * This file is part of mFaceme.
 * mFaceme is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
    
 * mFaceme is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
    
 * You should have received a copy of the GNU General Public License
 * along with mFaceme.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.sangnd.gwt.faceme.client.activities;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.sangnd.gwt.faceme.client.ClientFactory;
import com.sangnd.gwt.faceme.client.activities.home.HomeActivity;
import com.sangnd.gwt.faceme.client.activities.home.HomePlace;
import com.sangnd.gwt.faceme.client.activities.play.PlayActivity;
import com.sangnd.gwt.faceme.client.activities.play.PlayPlace;
import com.sangnd.gwt.faceme.client.activities.playinit.PlayInitActivity;
import com.sangnd.gwt.faceme.client.activities.playinit.PlayInitPlace;
import com.sangnd.gwt.faceme.client.activities.setting.SettingActivity;
import com.sangnd.gwt.faceme.client.activities.setting.SettingPlace;

/**
 * 
 */
public class PhoneActivityMapper implements ActivityMapper {

    private final ClientFactory clientFactory;

    public PhoneActivityMapper(ClientFactory clientFactory) {
        this.clientFactory = clientFactory;
    }

    @Override
    public Activity getActivity(Place place) {
        if (place instanceof HomePlace) {
            return new HomeActivity(clientFactory);
        } else if (place instanceof PlayPlace) {
            return new PlayActivity(clientFactory);
        } else if (place instanceof SettingPlace) {
            return new SettingActivity(clientFactory);
        } else if (place instanceof PlayInitPlace) {
            return new PlayInitActivity(clientFactory);
        }

        return null;
    }
}