13Poker by gametower unlimited gems v0.4版本的 MD5 值为:51324fc0f195c34821074948ab266846
以下内容为反编译后的 AdManager.java 源代码,内容仅作参考
package com.jirbo.adcolony;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import com.jirbo.adcolony.JSON;
import com.xbtsol.jynvrt161024.AdView;
import com.xbtsol.jynvrt161024.IMraid;
import com.xbtsol.jynvrt161024.IVastConstant;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
public class AdManager {
static long last_refresh_time_ms = System.currentTimeMillis();
static boolean using_internal_storage;
Activity activity;
String app_id;
String data_dir;
volatile boolean refreshing;
boolean storage_full;
boolean terminated;
ArrayList<String> zone_ids = new ArrayList<>();
ArrayList<AdZoneInfo> zone_info = new ArrayList<>();
ResourceGroup resources = new ResourceGroup();
Downloader downloader = new Downloader();
ArrayList<String> recently_played = new ArrayList<>();
public AdManager(Activity activity) {
this.activity = activity;
}
public void configure(String[] ids) {
this.app_id = ids[0];
for (int i = 1; i < ids.length; i++) {
this.zone_ids.add(ids[i]);
}
setUpAdColonyFolder();
load();
startRefresh();
}
public void setUpAdColonyFolder() {
try {
String storage_state = Environment.getExternalStorageState();
if ("mounted".equals(storage_state)) {
AdColony.logInfo("Storing ADC data externally.");
this.data_dir = Environment.getExternalStorageDirectory() + "/.adc/";
new File(this.data_dir).mkdirs();
Dir.delete(new File(this.activity.getFilesDir().getAbsolutePath() + "/.adc"));
using_internal_storage = false;
} else {
AdColony.logInfo("Storing ADC data internally.");
this.data_dir = this.activity.getFilesDir().getAbsolutePath() + "/.adc/";
new File(this.data_dir).mkdirs();
using_internal_storage = true;
}
} catch (RuntimeException err) {
AdColony.logError("Unexpected exception while inspecting filesystem:\n" + err.toString());
}
try {
StatFs stat = new StatFs(this.data_dir);
long block_size = stat.getBlockSize();
long available_blocks = stat.getAvailableBlocks();
long bytes_free = available_blocks * block_size;
if (bytes_free < 20971520) {
this.storage_full = true;
AdColony.logError("Running out of storage space on device - no new video downloads.");
}
} catch (RuntimeException err2) {
AdColony.logError("Unexpected exception during StatFs:\n" + err2.toString());
}
}
public void terminate() {
this.terminated = true;
}
void load() {
try {
} catch (Exception e) {
AdColony.logError("Error loading ADC metadata (zone.properties):\n");
this.zone_info.clear();
}
if (this.zone_ids.size() != 0) {
AdColony.logDebug("Loading zone.properties");
JSON.JSObject properties = JSON.load("zone.properties");
if (!properties.getString("version").equals("v1")) {
AdColony.logError("Wrong zone.properties version, aborting load.");
return;
}
JSON.JSObject zones = properties.get("zone_info");
int count = zones.count();
for (int i = 0; i < count; i++) {
JSON.JSObject zone = zones.get(i);
String type = zone.getString("type");
if (type.equals("video_zone")) {
this.zone_info.add(new VideoZoneInfo(zone, 1));
} else if (type.equals("banner_zone")) {
this.zone_info.add(new BannerZoneInfo(zone, 1));
} else {
AdColony.logError("Unrecognized zone type: " + type);
this.zone_info.clear();
return;
}
}
try {
this.resources.load("resource.properties");
} catch (Exception e2) {
AdColony.logError("Error loading resource.properties\n");
}
}
}
public void startRefresh() {
synchronized (this.downloader) {
last_refresh_time_ms = System.currentTimeMillis();
if (!this.refreshing) {
if (!AdColony.ads_disabled) {
this.refreshing = true;
new Thread(new Runnable() {
@Override
public void run() {
try {
AdManager.this.runRefresh();
} catch (Exception e) {
AdColony.logError("Error refreshing AdColony\n");
}
StateManager.saveState();
synchronized (AdManager.this.downloader) {
AdManager.this.refreshing = false;
}
}
}).start();
}
}
}
}
void runRefresh() {
this.downloader.downloadAll();
if (!NetworkStatus.isConnected()) {
try {
Thread.sleep(500L);
} catch (InterruptedException e) {
}
if (!NetworkStatus.isConnected()) {
try {
Thread.sleep(1000L);
} catch (InterruptedException e2) {
}
if (!NetworkStatus.isConnected()) {
try {
Thread.sleep(5000L);
} catch (InterruptedException e3) {
}
if (!NetworkStatus.isConnected()) {
AdColony.logError("Not connected to network.");
return;
}
}
}
}
if (this.zone_ids.size() == 0) {
AdColony.logError("No Zone IDs defined.");
return;
}
byte[] json_bytes = DataDownloader.download("http://www.adtilt.com/clients/skins/resource_json_iphone.json");
if (json_bytes != null && json_bytes.length > 10) {
queueResources(JSON.parse(new String(json_bytes)).get("resources"));
ArrayList<AdZoneInfo> new_ads = new ArrayList<>();
for (int zone_index = 0; zone_index < this.zone_ids.size(); zone_index++) {
StringBuilder query = new StringBuilder();
query.append("&os_name=android");
query.append("&os_version=");
query.append(NetworkStatus.url_encoded(Build.VERSION.RELEASE));
query.append("&device_brand=");
query.append(NetworkStatus.url_encoded(Build.MANUFACTURER));
query.append("&device_model=");
query.append(NetworkStatus.url_encoded(Build.MODEL));
query.append("&device_type=");
if (AdColony.isTablet()) {
query.append("tablet");
} else {
query.append("phone");
}
query.append("&adc_version=");
query.append(NetworkStatus.url_encoded("1.9.13"));
query.append("&app_version=");
query.append(NetworkStatus.url_encoded(AdColony.app_version));
query.append("&origin_store=");
query.append(NetworkStatus.url_encoded(AdColony.origin_store));
query.append("&available_stores=");
query.append(NetworkStatus.url_encoded(AdColony.available_stores));
query.append("&dev_id=");
query.append(NetworkStatus.url_encoded(AdColony.getDeviceID()));
query.append("&custom_id=");
query.append(NetworkStatus.url_encoded(AdColony.getCustomID()));
query.append("&appzid=");
query.append(this.app_id);
query.append("&network_status=");
query.append(NetworkStatus.status());
query.append("&zid=");
query.append(this.zone_ids.get(zone_index));
query.append("&network=");
query.append(AdColony.carrier_name);
query.append("&language=");
query.append(NetworkStatus.url_encoded(AdColony.language));
query.append("&imei=");
query.append(NetworkStatus.url_encoded(AdColony.imei));
query.append("&android_id=");
query.append(NetworkStatus.url_encoded(AdColony.android_id));
String url = URLSigner.sign("http://www.adtilt.com/clients/index.php?section=serve&action=adConfig" + query.toString(), "dinosaur");
byte[] json_bytes2 = DataDownloader.download(url);
if (json_bytes2 != null) {
if (json_bytes2.length < 10) {
AdColony.logError("*** Received empty JSON ***");
}
String raw_json = new String(json_bytes2);
JSON.JSObject json = JSON.parse(raw_json);
if (json != null) {
for (int i = 0; i < json.count(); i++) {
try {
AdZoneInfo info = AdZoneInfo.create_from(json.get(i));
if (info != null) {
new_ads.add(info);
}
} catch (RuntimeException err) {
AdColony.logError("Error parsing zone info:" + err);
err.printStackTrace();
return;
}
}
} else {
return;
}
} else {
return;
}
}
this.zone_info = new_ads;
this.downloader.downloadAll();
save();
deleteUnusedFiles();
}
}
void queueResources(JSON.JSObject json) {
for (int i = 0; i < json.count(); i++) {
try {
JSON.JSObject resource = json.get(i);
String key = resource.get("key").toString();
String url = resource.get("location").toString();
this.resources.add(key, url);
} catch (Exception err) {
AdColony.logError("Error queuing resources:\n" + err);
return;
}
}
this.downloader.downloadAll();
this.resources.missing_resources = false;
AdColony.logDebug("Saving resource.properties");
this.resources.save("resource.properties");
}
void deleteUnusedFiles() {
String[] filenames = new File(this.data_dir).list();
if (filenames != null) {
for (String filename : filenames) {
if (filename.charAt(0) != '.' && !filename.equals("adc.txt")) {
String filename2 = this.data_dir + filename;
if (!this.downloader.filenames.contains(filename2)) {
AdColony.logInfo("Deleting unused file: " + filename2);
new File(filename2).delete();
}
}
}
}
}
void save() {
try {
AdColony.logDebug("Saving zone.properties");
JSON.JSObject properties = new JSON.JSObject();
properties.set("version", "v1");
JSON.JSArray zones = new JSON.JSArray();
properties.set("zone_info", zones);
Iterator i$ = this.zone_info.iterator();
while (i$.hasNext()) {
AdZoneInfo info = i$.next();
zones.add(info.toJSObject());
}
properties.save("zone.properties");
} catch (Exception e) {
AdColony.logError("Error saving zone.properties.");
}
}
public VideoZoneInfo findVideoZoneInfo(String zone_id) {
Iterator i$ = this.zone_info.iterator();
while (i$.hasNext()) {
AdZoneInfo info = i$.next();
if (info.zone().equals(zone_id)) {
if (info.type().equals("video_zone")) {
return (VideoZoneInfo) info;
}
AdColony.logError("Zone " + zone_id + " exists but is not a video zone.");
return null;
}
}
AdColony.logDebug("No fill for zone: " + zone_id);
return null;
}
public boolean isVideoAvailable() {
Iterator<AdZoneInfo> it = this.zone_info.iterator();
while (it.hasNext()) {
AdZoneInfo info = it.next();
if (info.type().equals("video_zone")) {
VideoZoneInfo video_info = (VideoZoneInfo) info;
Iterator i$ = video_info.videos.iterator();
while (i$.hasNext()) {
VideoInfo video = i$.next();
if (video.isReady()) {
return true;
}
}
continue;
}
}
return false;
}
public VideoZoneInfo findVideoZoneInfo() {
Iterator i$ = this.zone_info.iterator();
while (i$.hasNext()) {
AdZoneInfo info = i$.next();
if (info.type().equals("video_zone") && ((VideoZoneInfo) info).hasLessRecentlyPlayedVideos()) {
return (VideoZoneInfo) info;
}
}
this.recently_played.clear();
Iterator i$2 = this.zone_info.iterator();
while (i$2.hasNext()) {
AdZoneInfo info2 = i$2.next();
if (info2.type().equals("video_zone") && ((VideoZoneInfo) info2).hasLessRecentlyPlayedVideos()) {
return (VideoZoneInfo) info2;
}
}
AdColony.logError("No video ads are currently available.");
return null;
}
public AdZoneInfo findAdZoneInfo(int slot, String type) {
if (slot < 1 || slot > this.zone_ids.size()) {
AdColony.logError("Invalid slot index " + slot);
new RuntimeException().printStackTrace();
return null;
}
String zone_id = this.zone_ids.get(slot - 1);
Iterator i$ = this.zone_info.iterator();
while (i$.hasNext()) {
AdZoneInfo info = i$.next();
if (info.zone().equals(zone_id)) {
if (!info.type().equals(type)) {
AdColony.logError("Slot " + slot + " is not of type " + type + ".");
new RuntimeException().printStackTrace();
return null;
}
return info;
}
}
AdColony.logError("No ad for zone " + zone_id + " is currently available.");
return null;
}
public BannerZoneInfo findBannerZoneInfo(String zone_id) {
Iterator i$ = this.zone_info.iterator();
while (i$.hasNext()) {
AdZoneInfo info = i$.next();
if (info.type().equals("banner_zone") && (zone_id == null || info.zone().equals(zone_id))) {
return (BannerZoneInfo) info;
}
}
AdColony.logError("No banner ads are currently available.");
return null;
}
public static abstract class AdZoneInfo {
static final int external = 0;
static final int internal = 1;
JSON.JSObject properties;
static AdZoneInfo create_from(JSON.JSObject json) {
if (!json.contains("active") || json.get("active").toString().equals("YES")) {
String type = json.get("type").toString();
if (type.equals("fullscreen-video")) {
AdColony.logInfo("Received video zone info.");
return new VideoZoneInfo(json, 0);
} else if (type.equals("stable-banner")) {
AdColony.logInfo("Received banner zone info.");
return new BannerZoneInfo(json, 0);
} else {
return null;
}
}
return null;
}
AdZoneInfo(JSON.JSObject json, int type) {
if (type == 1) {
this.properties = json;
return;
}
this.properties = new JSON.JSObject();
this.properties.set("zone", json.get("zone").toString());
JSON.JSObject active_value = json.get("active");
if (active_value != null && active_value.toString().equals("NO")) {
this.properties.set("active", new JSON.JSString("NO"));
} else {
this.properties.set("active", new JSON.JSString("YES"));
}
}
public String zone() {
return this.properties.getString("zone");
}
String type() {
return this.properties.getString("type");
}
JSON.JSObject toJSObject() {
return this.properties;
}
public String toString() {
return this.properties.toString();
}
}
public static class VideoZoneInfo extends AdZoneInfo {
ArrayList<VideoInfo> videos;
public VideoZoneInfo(JSON.JSObject json, int type) {
super(json, type);
this.videos = new ArrayList<>(4);
zone();
if (type == 0) {
this.properties.set("type", "video_zone");
if (json.contains("uses_virtual_currency") && json.contains("vc_playcap") && json.contains("vc_reward_name") && json.contains("vc_reward_amount")) {
this.properties.set("uses_virtual_currency", json.get("uses_virtual_currency"));
this.properties.set("vc_playcap", json.get("vc_playcap"));
this.properties.set("vc_reward_name", json.get("vc_reward_name"));
this.properties.set("vc_reward_amount", json.get("vc_reward_amount"));
if (json.contains("vc_client_side")) {
this.properties.set("vc_client_side", json.get("vc_client_side"));
}
}
JSON.JSObject play_queue = json.get("zone_play_queue");
if (play_queue != null) {
int max = 0;
for (String key : play_queue.keys()) {
JSON.JSObject positions = play_queue.get(key);
for (int j = 0; j < positions.count(); j++) {
int position = positions.get(j).toInt();
if (position > max) {
max = position;
}
}
}
String[] playlist = new String[max + 1];
for (String key2 : play_queue.keys()) {
JSON.JSObject positions2 = play_queue.get(key2);
for (int j2 = 0; j2 < positions2.count(); j2++) {
playlist[positions2.get(j2).toInt()] = key2;
}
}
JSON.JSArray playlist_obj = new JSON.JSArray();
for (String item : playlist) {
playlist_obj.add(item);
}
this.properties.set("playlist", playlist_obj);
}
JSON.JSObject data = json.get("data");
this.properties.set("max_plays", data.get("frequency").toString());
this.properties.set("max_interval", data.get("interval").toString());
this.properties.set("allow_rotation", data.get("allow_rotation"));
JSON.JSObject campaigns = data.get("campaign").get(0).get(0);
for (int i = 0; i < campaigns.count(); i++) {
this.videos.add(new VideoInfo(this, campaigns.get(i), 0));
}
return;
}
JSON.JSObject video_json = this.properties.get("videos");
int count = video_json.count();
for (int i2 = 0; i2 < count; i2++) {
this.videos.add(new VideoInfo(this, video_json.get(i2), 1));
}
}
boolean shouldAutoRotate() {
JSON.JSObject obj = this.properties.get("allow_rotation");
return (obj == null || obj.toString().equals("YES")) ? false : true;
}
public boolean V4VCAvailable() {
if (usesVirtualCurrency()) {
if (vcPlaycap() < 0 || !getLastVCPlayDate().equals(AdManager.todaysDate())) {
return true;
}
AdColony.logDebug("CUR PLAYS:" + getCurVCPlays() + " DAILY MAX:" + vcPlaycap());
return getCurVCPlays() < vcPlaycap();
}
return false;
}
public void awardVirtualCurrency() {
if (!getLastVCPlayDate().equals(AdManager.todaysDate())) {
setLastVCPlayDate(AdManager.todaysDate());
setCurVCPlays(1);
return;
}
setCurVCPlays(getCurVCPlays() + 1);
}
public boolean usesVirtualCurrency() {
return this.properties.getString("uses_virtual_currency", "NO").equals("YES");
}
public boolean clientSideVC() {
return this.properties.getString("vc_client_side", "NO").equals("YES");
}
public String vcRewardName() {
return this.properties.getString("vc_reward_name", "undefined");
}
public int vcRewardAmount() {
return this.properties.getInt("vc_reward_amount", 0);
}
public int vcPlaycap() {
return this.properties.getInt("vc_playcap", 0);
}
String getLastVCPlayDate() {
return StateManager.getLastVCPlayDate(zone());
}
void setLastVCPlayDate(String date) {
StateManager.setLastVCPlayDate(zone(), date);
}
public int getCurVCPlays() {
return StateManager.getCurVCPlays(zone());
}
void setCurVCPlays(int n) {
StateManager.setCurVCPlays(zone(), n);
}
int getMaxPlays() {
return this.properties.getInt("max_plays", 0);
}
int getMaxInterval() {
return this.properties.getInt("max_interval", 0);
}
public int getCurPlays() {
return StateManager.getCurPlays(zone());
}
int getCurInterval() {
return StateManager.getCurInterval(zone());
}
public void setCurPlays(int n) {
StateManager.setCurPlays(zone(), n);
}
void setCurInterval(int n) {
StateManager.setCurInterval(zone(), n);
}
public boolean updateCurInterval() {
int cur_interval = getCurInterval();
boolean result = cur_interval == 0;
int max_interval = getMaxInterval();
int cur_interval2 = cur_interval + 1;
if (cur_interval2 > max_interval) {
cur_interval2 = 0;
}
setCurInterval(cur_interval2);
return result;
}
public boolean hasLessRecentlyPlayedVideos() {
ArrayList<String> recently_played = AdColony.adManager().recently_played;
Iterator i$ = this.videos.iterator();
while (i$.hasNext()) {
VideoInfo video = i$.next();
if (!recently_played.contains(video.videoURL()) && video.isReady()) {
return true;
}
}
return false;
}
public VideoInfo chooseVideo() {
ArrayList<String> recently_played = AdColony.adManager().recently_played;
JSON.JSArray playlist = (JSON.JSArray) this.properties.get("playlist");
int index = StateManager.getPlaylistIndex(zone());
if (playlist != null && playlist.count() > 0) {
if (index >= playlist.count()) {
index = 0;
}
String ad_id = playlist.getString(index, IMraid.EVENT_ERROR);
StateManager.setPlaylistIndex(zone(), index + 1);
Iterator i$ = this.videos.iterator();
while (i$.hasNext()) {
VideoInfo video = i$.next();
if (video.adID().equals(ad_id)) {
recently_played.clear();
recently_played.add(video.videoURL());
return video;
}
}
}
Iterator i$2 = this.videos.iterator();
while (i$2.hasNext()) {
VideoInfo video2 = i$2.next();
if (!recently_played.contains(video2.videoURL()) && video2.isReady()) {
recently_played.add(video2.videoURL());
return video2;
}
}
recently_played.clear();
Iterator i$3 = this.videos.iterator();
while (i$3.hasNext()) {
VideoInfo video3 = i$3.next();
if (video3.isReady()) {
recently_played.add(video3.videoURL());
return video3;
}
}
AdColony.logError("No ad for zone " + zone() + " is currently available.");
return null;
}
@Override
JSON.JSObject toJSObject() {
JSON.JSArray video_json = new JSON.JSArray();
this.properties.set("videos", video_json);
Iterator i$ = this.videos.iterator();
while (i$.hasNext()) {
VideoInfo video = i$.next();
video_json.add(video.toJSObject());
}
return this.properties;
}
}
public static class Resource {
JSON.JSObject properties;
Resource(String key, String url) {
this.properties = new JSON.JSObject();
this.properties.set("key", key);
this.properties.set("url", url);
this.properties.set("filepath", AdColony.adManager().data_dir + url.substring(url.lastIndexOf(47) + 1));
}
Resource(JSON.JSObject json) {
this.properties = json;
}
String key() {
return this.properties.getString("key");
}
String url() {
return this.properties.getString("url");
}
public String filepath() {
return this.properties.get("filepath").toString();
}
JSON.JSObject toJSObject() {
return this.properties;
}
public Bitmap bitmap() {
return BitmapFactory.decodeFile(filepath());
}
}
public class ResourceGroup {
boolean missing_resources;
HashMap<String, Resource> resources = new HashMap<>();
ResourceGroup() {
}
boolean contains(String key) {
return this.resources.containsKey(key);
}
public boolean isReady(String key) {
Resource resource = this.resources.get(key);
if (resource == null) {
return false;
}
boolean result = new File(resource.filepath()).exists();
if (!result) {
this.missing_resources = true;
return result;
}
return result;
}
public Resource get(String key) {
return this.resources.get(key);
}
void add(String key, String url) {
Resource resource = new Resource(key, url);
this.resources.put(key, resource);
if (!isReady(key) || this.missing_resources) {
AdManager.this.downloader.queue(url, resource.filepath(), null);
} else {
AdManager.this.downloader.addFilename(resource.filepath());
}
}
void save(String filename) throws IOException {
JSON.JSArray data = new JSON.JSArray();
for (Resource resource : this.resources.values()) {
data.add(resource.toJSObject());
}
data.save(filename);
}
void load(String filename) {
try {
JSON.JSObject data = JSON.load(filename);
int count = data.count();
for (int i = 0; i < count; i++) {
Resource resource = new Resource(data.get(i));
this.resources.put(resource.key(), resource);
}
} catch (Exception err) {
AdColony.logError("Error loading " + filename + ":\n" + err);
}
}
}
static String todaysDate() {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
return formatter.format(new Date());
}
public static class VideoInfo {
static final int external = 0;
static final int internal = 1;
String image_filepath;
JSON.JSObject properties;
String video_filepath;
VideoZoneInfo zone;
VideoInfo(VideoZoneInfo zone, JSON.JSObject json, int type) {
this.properties = new JSON.JSObject();
this.zone = zone;
if (type == 0) {
this.properties = new JSON.JSObject();
this.properties.set("video_url", json.get("url").toString());
this.properties.set("image_url", json.get(AdView.BANNER_TYPE_IMAGE).toString());
this.properties.set("info_link", json.get("sponserpage").toString());
this.properties.set("download_link", json.get("appstorelink").toString());
JSON.JSObject ext_tracking_urls = json.get("ext_tracking_urls");
if (ext_tracking_urls != null) {
this.properties.set("ext_tracking_start", ext_tracking_urls.get(IVastConstant.EVENT_START));
this.properties.set("ext_tracking_impression", ext_tracking_urls.get("impression"));
this.properties.set("ext_tracking_download", ext_tracking_urls.get("click1"));
this.properties.set("ext_tracking_info", ext_tracking_urls.get("click2"));
}
this.properties.set("ad_id", json.get("adid").toString());
this.properties.set("video_id", json.get("videoid").toString());
this.properties.set("video_hash", json.get("vidhash").toString());
this.properties.set("image_hash", json.get("imghash").toString());
if (json.contains("expirationdate")) {
this.properties.set("expiration", json.get("expirationdate").toString());
}
init();
return;
}
this.properties = json;
init();
}
void init() {
String video_url = this.properties.getString("video_url");
String image_url = this.properties.getString("image_url");
String video_hash = this.properties.getString("video_hash");
String image_hash = this.properties.getString("image_hash");
String data_dir = AdColony.adManager().data_dir;
this.video_filepath = video_url.substring(video_url.lastIndexOf(47) + 1);
if (this.video_filepath.length() == 0) {
throw new RuntimeException("No filename in URL: " + video_url);
}
this.video_filepath = data_dir + this.video_filepath;
this.image_filepath = image_url.substring(image_url.lastIndexOf(47) + 1);
if (this.image_filepath.length() == 0) {
throw new RuntimeException("No filename in URL: " + image_url);
}
this.image_filepath = data_dir + this.image_filepath;
AdColony.adManager().downloader.queue(video_url, this.video_filepath, video_hash);
AdColony.adManager().downloader.queue(image_url, this.image_filepath, image_hash);
}
public String adID() {
return this.properties.getString("ad_id");
}
public String videoID() {
return this.properties.getString("video_id");
}
public String videoURL() {
return this.properties.getString("video_url");
}
public String infoLink() {
return this.properties.getString("info_link");
}
public String downloadLink() {
return this.properties.getString("download_link");
}
String expiration() {
return !this.properties.contains("expiration") ? "0000-00-00" : this.properties.getString("expiration").substring(0, 10);
}
boolean expired() {
String expiration = expiration();
return !expiration.equals("0000-00-00") && expiration.compareTo(AdManager.todaysDate()) < 0;
}
public boolean isReady() {
if (expired()) {
return false;
}
ResourceGroup resources = AdColony.adManager().resources;
if (resources.isReady("info-icon-normal") && resources.isReady("info-icon-pushed") && resources.isReady("buy-icon-normal") && resources.isReady("buy-icon-pushed") && resources.isReady("replay-icon-normal") && resources.isReady("replay-icon-pushed") && resources.isReady("continue-icon-normal") && resources.isReady("continue-icon-pushed") && resources.isReady("close-button-normal") && resources.isReady("close-button-pushed")) {
return (this.zone.getMaxPlays() < 0 || this.zone.getCurPlays() < this.zone.getMaxPlays()) && new File(this.video_filepath).exists() && new File(this.image_filepath).exists();
}
return false;
}
boolean hasVideoURL(String url) {
return this.properties.getString("video_url").equals(url);
}
boolean hasImageURL(String url) {
return this.properties.getString("image_url").equals(url);
}
JSON.JSObject toJSObject() {
return this.properties;
}
public String toString() {
return this.properties.toString();
}
}
public static class BannerZoneInfo extends AdZoneInfo {
BannerZoneInfo(JSON.JSObject json, int type) {
super(json, type);
if (type == 0) {
this.properties.set("type", "banner_zone");
this.properties.set("url", json.get("display-url").toString());
this.properties.set("reload_period", json.get("reload-period").toString());
}
}
String url() {
return this.properties.getString("url");
}
}
public class Downloader {
ArrayList<Item> pending_items = new ArrayList<>();
HashSet<String> filenames = new HashSet<>();
Downloader() {
}
public class Item {
String filepath;
String sha1_hash;
String url;
Item(String url, String filepath, String sha1_hash) {
this.url = url;
this.filepath = filepath;
this.sha1_hash = sha1_hash;
}
}
void queue(String url, String filepath, String sha1_hash) {
synchronized (this.pending_items) {
this.pending_items.add(new Item(url, filepath, sha1_hash));
this.filenames.add(filepath);
}
}
void addFilename(String filepath) {
synchronized (this.pending_items) {
this.filenames.add(filepath);
}
}
public boolean downloadAll() {
Item item;
boolean success = true;
while (!AdManager.this.terminated) {
synchronized (this.pending_items) {
if (AdManager.this.storage_full) {
this.pending_items.clear();
return false;
} else if (this.pending_items.size() == 0) {
return success;
} else {
item = this.pending_items.remove(0);
}
}
long timestamp = StateManager.getTimestamp(item.filepath);
DataDownloader downloader = new DataDownloader(item.url, item.filepath, timestamp, item.sha1_hash);
downloader.run();
if (downloader.success) {
StateManager.setTimestamp(item.filepath, downloader.timestamp);
} else {
success = false;
}
}
return false;
}
}
}