13Poker by gametower unlimited gems v0.4版本的 MD5 值为:51324fc0f195c34821074948ab266846
以下内容为反编译后的 VideoAd.java 源代码,内容仅作参考
package com.xbtsol.jynvrt161024;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.util.Log;
import com.adeco.adsdk.net.ServerCommunicationException;
import com.xbtsol.jynvrt161024.AdCallbackListener;
import com.xbtsol.jynvrt161024.VastXmlParser;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.http.NameValuePair;
import org.xmlpull.v1.XmlPullParserException;
public class VideoAd implements AsyncTaskCompleteListener<String> {
private static final String TAG = "AirPlayVast";
private static VastXmlParser vastXmlParser;
private Context context;
public static VastXmlParser getVastXmlParser() {
return vastXmlParser;
}
public VideoAd(Context context) {
this.context = context;
}
@Override
public void launchNewHttpTask() {
try {
List<NameValuePair> list = new ArrayList<>();
NetworkThread networkThread = new NetworkThread(this.context, this, list, "https://api.airpush.com/Vast/vastadcall.php", 0L, true);
new Thread(networkThread, "vast").start();
} catch (NullPointerException e) {
Log.e("AirPlayVast", "Video ad", e);
} catch (Exception e2) {
Log.e("AirPlayVast", "Error occurred while fetching Video ad", e2);
}
}
@Override
public void onTaskComplete(String result) {
Log.i("AirPlayVast", "Video Ad: " + result);
if (result == null || result.equals("")) {
Log.w("AirPlayVast", "Video ad response is null");
} else {
parseVideoAd(result);
}
}
public void parseVideoAd(String result) {
try {
SetPreferences.setNextVideoAdCall(this.context);
StringReader reader = new StringReader(result);
vastXmlParser = new VastXmlParser(reader);
List<VastXmlParser.Creative> creatives = vastXmlParser.getCreativesList();
VastXmlParser.Creative creative = creatives.get(0);
List<HashMap<String, Object>> mediaFiles = creative.getMediaFiles();
HashMap<String, Object> media = mediaFiles.get(0);
String url = media.get(IVastConstant.MEDIA_FILE).toString();
String delivery = media.get(IVastConstant.MEDIA_FILE_DELIVERY).toString();
if (url != null && !url.equals("")) {
if (delivery != null && delivery.equals("progressive")) {
downloadVideo(url);
} else if (AirPlay.enableCaching) {
Caching caching = new Caching(this.context);
caching.saveVideoJson(AdCallbackListener.AdType.video, result, url);
AirPlay.sendAdCached(AdCallbackListener.AdType.video);
} else {
Log.e("AirPlayVast", "deleviery type streaming " + url);
Intent intent = new Intent(this.context, VideoAdActivity.class);
intent.setAction("play_video");
intent.setFlags(268435456);
intent.addFlags(8388608);
intent.addFlags(536870912);
intent.setData(Uri.parse(url));
this.context.startActivity(intent);
SetPreferences.setNextVideoAdCall(this.context);
}
} else {
Log.e("AirPlayVast", "Ad url is invalid: " + url);
}
} catch (VastXmlParser.InvalidVastXML e) {
} catch (VastXmlParser.VastException e2) {
Log.e("AirPlayVast", e2.getMessage());
AirPlay.validateStatusCode(e2.getCode(), e2.getMessage());
} catch (XmlPullParserException e3) {
e3.printStackTrace();
} catch (Exception e4) {
e4.printStackTrace();
} catch (Throwable e5) {
e5.printStackTrace();
}
}
public void starVideoAdActivity() {
try {
Caching caching = new Caching(this.context);
String[] ad = caching.getVideoAdJson(AdCallbackListener.AdType.video);
if (ad != null && ad[1] != null) {
Log.i("AirPlayVast", "deleviery type streaming " + ad[1]);
Intent intent = new Intent(this.context, VideoAdActivity.class);
intent.setAction("play_video");
intent.setFlags(268435456);
intent.addFlags(8388608);
intent.addFlags(536870912);
intent.setData(Uri.parse(ad[1]));
this.context.startActivity(intent);
SetPreferences.setNextVideoAdCall(this.context);
} else {
AirPlay.validateStatusCode(ServerCommunicationException.ERROR_NO_CONTENT, "Video ad is not available in cache");
}
} catch (Exception e) {
}
}
private void downloadVideo(String video_url) {
try {
String state = Environment.getExternalStorageState();
Boolean isSDCardPresent = Boolean.valueOf(state.equals("mounted") && !state.equals("mounted_ro"));
if (!isSDCardPresent.booleanValue()) {
String message = "SD Card is not available for caching video. SD Card storage state: " + state;
Log.e("AirPlayVast", message);
AirPlay.sendAdError(message);
return;
}
AsyncTaskCompleteListener<String> downlaodVideoTask = new AnonymousClass1(video_url);
if (Util.checkInternetConnection(this.context)) {
downlaodVideoTask.launchNewHttpTask();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public class AnonymousClass1 implements AsyncTaskCompleteListener<String> {
String local_file_url = "";
final String val$video_url;
AnonymousClass1(String str) {
this.val$video_url = str;
}
@Override
public void onTaskComplete(String result) {
Util.printDebugLog("Video file: " + result);
if (result != null) {
try {
if (!result.equals("")) {
if (AirPlay.enableCaching) {
Caching caching = new Caching(VideoAd.this.context);
if (caching.saveVideoJson(AdCallbackListener.AdType.video, result, result)) {
AirPlay.sendAdCached(AdCallbackListener.AdType.video);
} else if (AirPlay.adCallbackListener != null) {
AirPlay.sendAdError("Video ad not cached.");
}
} else {
Intent intent = new Intent(VideoAd.this.context, VideoAdActivity.class);
intent.setAction("play_video");
intent.setFlags(268435456);
intent.addFlags(8388608);
intent.addFlags(536870912);
intent.setData(Uri.parse(result));
VideoAd.this.context.startActivity(intent);
SetPreferences.setNextVideoAdCall(VideoAd.this.context);
}
}
} catch (Exception e) {
Log.e("AirPlayVast", "Error occured while download video", e);
return;
}
}
Log.e("AirPlayVast", "Not able to download video");
}
@Override
public void launchNewHttpTask() {
try {
File path = Environment.getExternalStorageDirectory();
File file = new File(path, "ap_video");
if (file.exists() && file.isDirectory()) {
VastUtils.deleteRecursive(file);
file.mkdirs();
this.local_file_url = file.getAbsolutePath();
} else if (file.mkdirs()) {
this.local_file_url = file.getAbsolutePath();
}
new Thread(new Runnable() {
@Override
public void run() {
try {
URL url = new URL(AnonymousClass1.this.val$video_url);
URLConnection connection = url.openConnection();
connection.setConnectTimeout(7000);
connection.setReadTimeout(7000);
connection.connect();
Log.i("AirPlayVast", "Content-length: " + connection.getContentLength());
InputStream stream = connection.getInputStream();
File file2 = new File(AnonymousClass1.this.local_file_url, "ad_video.mp4");
try {
if (file2.exists()) {
file2.delete();
}
} catch (Exception e) {
e.printStackTrace();
}
FileOutputStream fileOutputStream = new FileOutputStream(file2);
byte[] buffer = new byte[1024];
while (true) {
int sz = stream.read(buffer);
if (sz <= 0) {
fileOutputStream.close();
AnonymousClass1.this.onTaskComplete(file2.getAbsolutePath());
return;
}
fileOutputStream.write(buffer, 0, sz);
}
} catch (MalformedURLException e2) {
e2.printStackTrace();
AnonymousClass1.this.onTaskComplete((String) null);
} catch (SocketTimeoutException e3) {
e3.printStackTrace();
AnonymousClass1.this.onTaskComplete((String) null);
} catch (IOException e4) {
e4.printStackTrace();
AnonymousClass1.this.onTaskComplete((String) null);
} finally {
}
}
}, "dwn_video").start();
} catch (Exception e) {
e.printStackTrace();
} catch (Throwable th) {
}
}
}
public static boolean checkVideoAdPermission(Context context) {
boolean val = true;
try {
boolean external = context.checkCallingOrSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") == 0;
boolean access = context.checkCallingOrSelfPermission("android.permission.ACCESS_WIFI_STATE") == 0;
if (!external) {
val = false;
Log.e(IConstants.TAG, "Required permission WRITE_EXTERNAL_STORAGE not found in Manifest. Please add.");
AirPlay.sendIntegrationError("Required permission WRITE_EXTERNAL_STORAGE not found in Manifest. Please add.");
}
if (!access) {
val = false;
Log.e(IConstants.TAG, "Required permission ACCESS_WIFI_STATE not found in Manifest. Please add.");
AirPlay.sendIntegrationError("Required permission ACCESS_WIFI_STATE not found in Manifest. Please add.");
}
if (!val) {
new SendIntegrationError(context, 110);
return val;
}
return val;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}