Android Open Source - plus1-android-sdk Mraid Command






From Project

Back to project page plus1-android-sdk.

License

The source code is released under:

Copyright (c) 2012, WapStart All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Red...

If you think the Android project plus1-android-sdk 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 ru.wapstart.plus1.sdk;
/*from w ww.  j av a2  s  .co m*/
import java.util.Map;

abstract class MraidCommand {
  protected Map<String, String> mParams;
  protected MraidView mView;

  MraidCommand(Map<String, String> params, MraidView view) {
    mParams = params;
    mView = view;
  }

  abstract void execute();

  protected int getIntFromParamsForKey(String key) {
    String s = mParams.get(key);
    if (s == null) return -1;
    else {
      try {
        return Integer.parseInt(s, 10);
      } catch (NumberFormatException e) {
        return -1;
      }
    }
  }

  protected String getStringFromParamsForKey(String key) {
    return mParams.get(key);
  }

  protected float getFloatFromParamsForKey(String key) {
    String s = mParams.get(key);
    if (s == null) return 0.0f;
    else {
      try {
        return Float.parseFloat(key);
      } catch (NumberFormatException e) {
        return 0.0f;
      }
    }
  }

  protected boolean getBooleanFromParamsForKey(String key) {
    return "true".equals(mParams.get(key));
  }
}

class MraidCommandClose extends MraidCommand {
  MraidCommandClose(Map<String, String> params, MraidView view) {
    super(params, view);
  }

  void execute() {
    mView.getDisplayController().close();
  }
}

class MraidCommandExpand extends MraidCommand {
  MraidCommandExpand(Map<String, String> params, MraidView view) {
    super(params, view);
  }

  void execute() {
    int width = getIntFromParamsForKey("w");
    int height = getIntFromParamsForKey("h");
    String url = getStringFromParamsForKey("url");
    boolean shouldUseCustomClose = getBooleanFromParamsForKey("shouldUseCustomClose");
    boolean shouldLockOrientation = getBooleanFromParamsForKey("lockOrientation");

    if (width <= 0) width = mView.getDisplayController().mScreenWidth;
    if (height <= 0) height = mView.getDisplayController().mScreenHeight;

    mView.getDisplayController().expand(url, width, height, shouldUseCustomClose,
        shouldLockOrientation);
  }
}

class MraidCommandUseCustomClose extends MraidCommand {
  MraidCommandUseCustomClose(Map<String, String> params, MraidView view) {
    super(params, view);
  }

  void execute() {
    boolean shouldUseCustomClose = getBooleanFromParamsForKey("shouldUseCustomClose");
    mView.getDisplayController().useCustomClose(shouldUseCustomClose);
  }
}

class MraidCommandOpen extends MraidCommand {
  MraidCommandOpen(Map<String, String> params, MraidView view) {
    super(params, view);
  }

  void execute() {
    String url = getStringFromParamsForKey("url");
    mView.getBrowserController().open(url);
  }
}




Java Source Code List

ru.wapstart.plus1.bart.BartActivity.java
ru.wapstart.plus1.sdk.AdView.java
ru.wapstart.plus1.sdk.ApplicationBrowser.java
ru.wapstart.plus1.sdk.Base64.java
ru.wapstart.plus1.sdk.BaseAdView.java
ru.wapstart.plus1.sdk.BaseRequestLoader.java
ru.wapstart.plus1.sdk.Constants.java
ru.wapstart.plus1.sdk.HtmlBannerDownloader.java
ru.wapstart.plus1.sdk.InitRequestLoader.java
ru.wapstart.plus1.sdk.JsonHelper.java
ru.wapstart.plus1.sdk.MraidAbstractController.java
ru.wapstart.plus1.sdk.MraidBrowserController.java
ru.wapstart.plus1.sdk.MraidCommandRegistry.java
ru.wapstart.plus1.sdk.MraidCommand.java
ru.wapstart.plus1.sdk.MraidDisplayController.java
ru.wapstart.plus1.sdk.MraidProperty.java
ru.wapstart.plus1.sdk.MraidView.java
ru.wapstart.plus1.sdk.Plus1AdAnimator.java
ru.wapstart.plus1.sdk.Plus1BannerAsker.java
ru.wapstart.plus1.sdk.Plus1BannerDownloadListener.java
ru.wapstart.plus1.sdk.Plus1BannerView.java
ru.wapstart.plus1.sdk.Plus1Helper.java
ru.wapstart.plus1.sdk.Plus1Request.java