Package com.antonytrupe.client.mvp

Source Code of com.antonytrupe.client.mvp.AppActivityMapper

package com.antonytrupe.client.mvp;

import com.antonytrupe.client.ClientFactory;
import com.antonytrupe.client.activity.DisplayActivity;
import com.antonytrupe.client.activity.EditActivity;
import com.antonytrupe.client.activity.HistoryActivity;
import com.antonytrupe.client.place.DisplayPlace;
import com.antonytrupe.client.place.EditPlace;
import com.antonytrupe.client.place.HistoryPlace;
import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

public class AppActivityMapper implements ActivityMapper {

  private ClientFactory clientFactory;

  /**
   * AppActivityMapper associates each Place with its corresponding
   * {@link Activity}
   *
   * @param clientFactory
   *            Factory to be passed to activities
   */
  public AppActivityMapper(ClientFactory clientFactory) {
    super();
    this.clientFactory = clientFactory;
  }

  public static native void recordAnalyticsHit(String pageName) /*-{
    $wnd._gaq.push([ '_trackPageview', pageName ]);
  }-*/;

  /**
   * Map each Place to its corresponding Activity.
   */
  @Override
  public Activity getActivity(Place place) {

    if (place instanceof EditPlace)
      return new EditActivity((EditPlace) place, this.clientFactory);
    else if (place instanceof DisplayPlace) {
      AppActivityMapper.recordAnalyticsHit(((DisplayPlace) place)
          .getPageName());
      return new DisplayActivity((DisplayPlace) place, this.clientFactory);
    } else if (place instanceof HistoryPlace)
      return new HistoryActivity((HistoryPlace) place, this.clientFactory);
    return null;
  }
}
TOP

Related Classes of com.antonytrupe.client.mvp.AppActivityMapper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.