Android Open Source - playnomics-android Playnomics






From Project

Back to project page playnomics-android.

License

The source code is released under:

Apache License

If you think the Android project playnomics-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.playnomics.android.sdk;
/* w w  w  .j a  va  2  s.  c  o m*/
import java.util.Date;

import android.app.Activity;
import android.content.Context;

import com.playnomics.android.client.AssetClient;
import com.playnomics.android.client.EventWorker;
import com.playnomics.android.client.HttpConnectionFactory;
import com.playnomics.android.client.IEventWorker;
import com.playnomics.android.client.PlacementDataClient;
import com.playnomics.android.messaging.HtmlAdFactory;
import com.playnomics.android.messaging.MessagingManager;
import com.playnomics.android.messaging.ui.PlayViewFactory;
import com.playnomics.android.session.ActivityObserver;
import com.playnomics.android.session.HeartBeatProducer;
import com.playnomics.android.session.IActivityObserver;
import com.playnomics.android.session.IHeartBeatProducer;
import com.playnomics.android.session.Session;
import com.playnomics.android.util.AndroidLogger;
import com.playnomics.android.util.CacheFile;
import com.playnomics.android.util.Config;
import com.playnomics.android.util.ContextWrapper;
import com.playnomics.android.util.IConfig;
import com.playnomics.android.util.LogWriter;
import com.playnomics.android.util.Logger;
import com.playnomics.android.util.Logger.LogLevel;
import com.playnomics.android.util.Util;

public class Playnomics {
  private static final Object syncLock = new Object();
  private static Session instance;

  private static Logger logger;
  private static Util util;

  private static Session getInstance() {
    synchronized (Playnomics.syncLock) {
      if (instance == null) {
        LogWriter logWriter = new AndroidLogger("PLAYNOMICS");
        Playnomics.logger = new Logger(logWriter);

        HttpConnectionFactory connectionFactory = new HttpConnectionFactory(
            logger);
        IConfig config = new Config();
        Playnomics.util = new Util(logger);
        IEventWorker eventWorker = new EventWorker(config,
            connectionFactory, logger);
        IActivityObserver activityObserver = new ActivityObserver(util);
        IHeartBeatProducer heartbeatProducer = new HeartBeatProducer(config);
        HtmlAdFactory adFactory = new HtmlAdFactory(logger);
        AssetClient assetClient = new AssetClient(connectionFactory, logger);
        PlacementDataClient placementDataClient = new PlacementDataClient(
            assetClient, config, logger, adFactory, util);

        PlayViewFactory viewFactory = new PlayViewFactory();
        MessagingManager messagingManager = new MessagingManager(
            config, placementDataClient, util, logger, viewFactory);
        
        CacheFile cacheFile = new CacheFile(util, config);
        instance = new Session(config, util, connectionFactory, logger,
            eventWorker, activityObserver,
            heartbeatProducer, messagingManager, cacheFile);
      }
      return instance;
    }
  }
  
  @Deprecated
  public static void setTestMode(boolean testMode){
    //test mode is now driven by the server
  }
  
  public static void setLogLevel(LogLevel logLevel){
    Session session = getInstance();
    session.setLogLevel(logLevel);
  }
  
  public static void setOverrideEventsUrl(String eventsUrl){
    Session session = getInstance();
    session.setOverrideEventsUrl(eventsUrl);
  }

  public static void setOverrideMessagingUrl(String messagingUrl){
    Session session = getInstance();
    session.setOverrideMessagingUrl(messagingUrl);
  }
  
  public static void start(Context context, long applicationId, String userId) {
    Session session = getInstance();
    ContextWrapper contextWrapper = new ContextWrapper(context, logger,
        util);
    session.start(contextWrapper, applicationId, userId);
  }

  public static void start(Context context, long applicationId) {
    Session session = getInstance();

    ContextWrapper contextWrapper = new ContextWrapper(context, logger,
        util);
    session.start(contextWrapper, applicationId, null);
  }

  public static void onActivityResumed(Activity activity) {
    Session session = getInstance();
    session.onActivityResumed(activity);
  }

  public static void onActivityPaused(Activity activity) {
    Session session = getInstance();
    session.onActivityPaused(activity);
  }

  public static void transactionInUSD(float priceInUSD, int quantity) {
    Session session = getInstance();
    session.transactionInUSD(priceInUSD, quantity);
  }

  public static void customEvent(String customEventName) {
    Session session = getInstance();
    session.customEvent(customEventName);
  }

  public static void attributeInstall(String source, String campaign,
      Date installDateUtc) {
    Session session = getInstance();
    session.attributeInstall(source, campaign, installDateUtc);
  }

  public static void attributeInstall(String source, String campaign) {
    Session session = getInstance();
    session.attributeInstall(source, campaign, null);
  }

  public static void attributeInstall(String source) {
    Session session = getInstance();
    session.attributeInstall(source, null, null);
  }

  public static void preloadPlacements(String... placementNames) {
    Session session = getInstance();
    session.preloadPlacements(placementNames);
  }

  public static void showPlacement(String placementName, Activity activity,
      IPlaynomicsPlacementDelegate delegate) {
    Session session = getInstance();
    session.showPlacement(placementName, activity, delegate);
  }
  
  public static void showPlacement(String placementName, Activity activity,
      IPlaynomicsPlacementRawDelegate rawDelegate) {
    Session session = getInstance();
    session.showPlacement(placementName, activity, rawDelegate);
  }
  
  public static void showPlacement(String placementName, Activity activity) {
    Session session = getInstance();
    session.showPlacement(placementName, activity, null);
  }
  
  public static void hidePlacement(String placementName) {
    Session session = getInstance();
    session.hidePlacement(placementName);
  }
  
  public static void enablePushNotifications(IPushConfig pushConfig, IPushNotificationDelegate notificationDelegate){
    Session session = getInstance();
    session.enablePushNotifications(pushConfig, notificationDelegate);
  }

  public static void fetchUserSegmentIds(final IPlaynomicsSegmentationDelegate delegate) {
    Session session = getInstance();
    session.fetchUserSegmentIds(delegate);
  }

  public static void setUserGender(String gender) {
    Session session = getInstance();
    session.setUserGender(gender);
  }

  public static void setUserBirthYear(int year) {
    Session session = getInstance();
    session.setUserBirthYear(year);
  }

}




Java Source Code List

com.playnomics.PlaynomicsMoreTestActivity.java
com.playnomics.PlaynomicsTestAppActivity.java
com.playnomics.RichDataFrameDelegate.java
com.playnomics.android.client.AssetClient.java
com.playnomics.android.client.EventQueue.java
com.playnomics.android.client.EventWorker.java
com.playnomics.android.client.HttpConnectionFactory.java
com.playnomics.android.client.IEventQueue.java
com.playnomics.android.client.IEventWorker.java
com.playnomics.android.client.IHttpConnectionFactory.java
com.playnomics.android.client.PlacementDataClient.java
com.playnomics.android.client.SegmentationClient.java
com.playnomics.android.events.AppPageEvent.java
com.playnomics.android.events.AppPauseEvent.java
com.playnomics.android.events.AppResumeEvent.java
com.playnomics.android.events.AppRunningEvent.java
com.playnomics.android.events.AppStartEvent.java
com.playnomics.android.events.CustomEvent.java
com.playnomics.android.events.ExplicitEvent.java
com.playnomics.android.events.ImplicitEvent.java
com.playnomics.android.events.PlaynomicsEvent.java
com.playnomics.android.events.TransactionEvent.java
com.playnomics.android.events.UserInfoEvent.java
com.playnomics.android.messaging.CloseButton.java
com.playnomics.android.messaging.HtmlAdFactory.java
com.playnomics.android.messaging.HtmlAd.java
com.playnomics.android.messaging.HtmlCloseButton.java
com.playnomics.android.messaging.MessagingManager.java
com.playnomics.android.messaging.NativeCloseButton.java
com.playnomics.android.messaging.Placement.java
com.playnomics.android.messaging.Position.java
com.playnomics.android.messaging.Target.java
com.playnomics.android.messaging.ui.IPlayViewFactory.java
com.playnomics.android.messaging.ui.PlayDialog.java
com.playnomics.android.messaging.ui.PlayViewFactory.java
com.playnomics.android.messaging.ui.PlayWebView.java
com.playnomics.android.messaging.ui.RenderTaskFactory.java
com.playnomics.android.push.GcmBroadcastReceiver.java
com.playnomics.android.push.GcmIntentService.java
com.playnomics.android.push.GcmManager.java
com.playnomics.android.sdk.IGoogleCloudMessageConfig.java
com.playnomics.android.sdk.IPlacementDelegate.java
com.playnomics.android.sdk.IPlaynomicsPlacementDelegate.java
com.playnomics.android.sdk.IPlaynomicsPlacementRawDelegate.java
com.playnomics.android.sdk.IPlaynomicsSegmentationDelegate.java
com.playnomics.android.sdk.IPushConfig.java
com.playnomics.android.sdk.IPushNotificationDelegate.java
com.playnomics.android.sdk.Playnomics.java
com.playnomics.android.segments.UserSegmentIds.java
com.playnomics.android.session.ActivityObserver.java
com.playnomics.android.session.GameSessionInfo.java
com.playnomics.android.session.HeartBeatHandler.java
com.playnomics.android.session.HeartBeatProducer.java
com.playnomics.android.session.IActivityObserver.java
com.playnomics.android.session.ICallbackProcessor.java
com.playnomics.android.session.IHeartBeatProducer.java
com.playnomics.android.session.SessionStateMachine.java
com.playnomics.android.session.Session.java
com.playnomics.android.session.TouchEventHandler.java
com.playnomics.android.session.WindowCallbackProxy.java
com.playnomics.android.util.AndroidLogger.java
com.playnomics.android.util.AsyncTaskRunner.java
com.playnomics.android.util.CacheFile.java
com.playnomics.android.util.Config.java
com.playnomics.android.util.ContextWrapper.java
com.playnomics.android.util.EventTime.java
com.playnomics.android.util.IAsyncCall.java
com.playnomics.android.util.IConfig.java
com.playnomics.android.util.IRandomGenerator.java
com.playnomics.android.util.LargeGeneratedId.java
com.playnomics.android.util.LogWriter.java
com.playnomics.android.util.Logger.java
com.playnomics.android.util.Util.java