13Poker by gametower unlimited gems v0.4版本的 MD5 值为:51324fc0f195c34821074948ab266846

以下内容为反编译后的 AirPlay.java 源代码,内容仅作参考


package com.xbtsol.jynvrt161024;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.util.Log;
import com.adeco.adsdk.net.ServerCommunicationException;
import com.xbtsol.jynvrt161024.AdCallbackListener;
import com.xbtsol.jynvrt161024.FormatAds;
import com.xbtsol.jynvrt161024.Util;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;
public class AirPlay extends SDKIntializer {
    static final String TAG = "AirplaySDK";
    private static Activity activity;
    static AdCallbackListener adCallbackListener;
    static Handler handler;
    static FormatAds.ParseMraidJson parseMraidJson;
    private Caching caching;
    private static boolean isIntegrationIssue = false;
    static boolean enableCaching = true;

    public AirPlay(Activity activity2, AdCallbackListener adCallbackListener2, boolean enableCaching2) {
        adCallbackListener = adCallbackListener2;
        enableCaching = enableCaching2;
        Log.i("AirplaySDK", "Starting AirPlay.");
        if (activity2 == null) {
            Log.e("AirplaySDK", "Activity must not be null.");
            sendIntegrationError("Activty must not be null.");
        } else if (!(activity2 instanceof Activity)) {
            Log.e("AirplaySDK", "Invalid activty refrence.");
            sendIntegrationError("Invalid Activity reference.");
        } else {
            activity = activity2;
            Util.setContext(activity2);
            Util.startBusense(activity2);
            if (checkRequiredDetails(activity2) && checkSmartWallintegration()) {
                isIntegrationIssue = false;
                Log.i("AirplaySDK", "AppId: " + Util.getAppID());
                Util.setSESSION_ID();
                this.caching = new Caching(activity2);
                SharedPreferences SDKPrefs = activity2.getSharedPreferences(IConstants.SDK_PREFERENCE, 0);
                if (SDKPrefs == null || !SDKPrefs.contains(IConstants.SDK_ENABLED)) {
                    enableSDK(activity2, true);
                }
                handler = new Handler();
                sendUserInfo();
                return;
            }
            isIntegrationIssue = true;
        }
    }

    private void sendUserInfo() {
        if (isSDKEnabled(activity)) {
            try {
                AsyncTaskCompleteListener<String> asyncTaskCompleteListener = new AsyncTaskCompleteListener<String>() {
                    @Override
                    public void launchNewHttpTask() {
                        List<NameValuePair> values = new ArrayList<>();
                        values.add(new BasicNameValuePair("model", IConstants.MODEL_USER));
                        values.add(new BasicNameValuePair("action", IConstants.ACTION_SET_USER_INFO));
                        values.add(new BasicNameValuePair("type", IConstants.TYPE_APP));
                        Util.printDebugLog("UserInfo Values >>>>>>: " + values);
                        NetworkThread networkThread = new NetworkThread(AirPlay.activity, this, values, IConstants.URL_API_MESSAGE, 20000L, true);
                        new Thread(networkThread, "sn").start();
                    }

                    @Override
                    public void onTaskComplete(String result) {
                        Log.i("AirplaySDK", "Info sent: " + result);
                    }
                };
                if (Util.checkInternetConnection(activity)) {
                    asyncTaskCompleteListener.launchNewHttpTask();
                }
            } catch (Exception e) {
                Log.i("Activitymanager", e.toString());
            }
        }
    }

    @Override
    public void startSmartWallAd() {
        try {
            Log.i("AirplaySDK", "Initialising SmartWall.....");
            if (!isIntegrationIssue && checkSmartWallintegration()) {
                boolean available = Util.isIntentAvailable(activity, VideoAdActivity.class);
                if (!available) {
                    Log.e("AirplaySDK", "Required VideoAdActivity not found in Manifest. Please add");
                    sendIntegrationError("Required VideoAdActivity not found in Manifest. Please add");
                    new SendIntegrationError(activity, 102);
                } else if (activity != null && isSDKEnabled(activity)) {
                    if (SetPreferences.getNextAdCallTime(activity) > System.currentTimeMillis()) {
                        Log.i("AirplaySDK", "SmartWall Ad called within 10 secs. Ignoring request.");
                        sendAdError("SmartWall Ad called within 10 secs. Ignoring request.");
                    } else if (SmartWallActivity.isShowing()) {
                        Log.i("AirplaySDK", "Another ad is showing on screen.");
                        sendAdError("Another ad is showing on screen.");
                    } else {
                        SetPreferences.setNextAdCallTime(activity);
                        AsyncTaskCompleteListener<String> asyncTaskCompleteListener = new AsyncTaskCompleteListener<String>() {
                            @Override
                            public void onTaskComplete(String result) {
                                Log.i("AirplaySDK", "SmartWall JSON: " + result);
                                if (result != null) {
                                    try {
                                        JSONObject jsonObject = new JSONObject(result);
                                        int status = jsonObject.isNull("status") ? 0 : jsonObject.getInt("status");
                                        String msg = jsonObject.isNull("message") ? "" : jsonObject.getString("message");
                                        String adtype = jsonObject.isNull("adtype") ? "" : jsonObject.getString("adtype");
                                        if (status == 200 && msg.equalsIgnoreCase("Success") && !adtype.equals("")) {
                                            if (AirPlay.enableCaching) {
                                                if (!result.startsWith("<VAST>") || Build.VERSION.SDK_INT <= 7) {
                                                    AirPlay.this.caching.saveJson(AdCallbackListener.AdType.smartwall, result);
                                                    SDKIntializer.sendAdCached(AdCallbackListener.AdType.smartwall);
                                                    AirPlay.this.caching.setSmartWallAd(true);
                                                    return;
                                                }
                                                VideoAd videoAd = new VideoAd(AirPlay.activity);
                                                videoAd.parseVideoAd(result);
                                                return;
                                            }
                                            AirPlay.this.parseSmartwallJson(result);
                                        }
                                    } catch (Exception e) {
                                        Log.e("AirplaySDK", "Error: ", e);
                                    }
                                }
                            }

                            @Override
                            public void launchNewHttpTask() {
                                try {
                                    List<NameValuePair> nameValuePairs = new ArrayList<>();
                                    NetworkThread networkThread = new NetworkThread(AirPlay.activity, this, nameValuePairs, IConstants.URL_INTERSTITIAL, 0L, true);
                                    new Thread(networkThread, "SmartWall").start();
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        };
                        if (Util.checkInternetConnection(activity)) {
                            asyncTaskCompleteListener.launchNewHttpTask();
                        }
                    }
                } else {
                    Log.i("AirplaySDK", "AirPlay is disabled Please enable to recive ads.");
                    sendAdError("AirPlay is disabled Please enable to recive ads.");
                }
            }
        } catch (Exception exception) {
            Log.e("AirplaySDK", "Error occurred in startSmartWall method: ", exception);
        }
    }

    void parseSmartwallJson(String result) {
        try {
            if (result.startsWith("<VAST>") && Build.VERSION.SDK_INT > 7) {
                VideoAd videoAd = new VideoAd(activity);
                videoAd.parseVideoAd(result);
                return;
            }
            JSONObject jsonObject = new JSONObject(result);
            int status = jsonObject.isNull("status") ? 0 : jsonObject.getInt("status");
            String msg = jsonObject.isNull("message") ? "" : jsonObject.getString("message");
            String adtype = jsonObject.isNull("adtype") ? "" : jsonObject.getString("adtype");
            if (status == 200 && !adtype.equals("")) {
                if (adtype.equalsIgnoreCase(IConstants.AD_TYPE_AW)) {
                    parseAppWallJson(result);
                    return;
                } else if (adtype.equals("OLAU") || adtype.equals(IConstants.AD_TYPE_DAU) || adtype.equals(IConstants.AD_TYPE_DCC) || adtype.equals(IConstants.AD_TYPE_DCM)) {
                    showOverlayAd(result);
                    return;
                } else if (!adtype.equals("") && adtype.equalsIgnoreCase(IConstants.AD_TYPE_FP)) {
                    parseLandingPageAdJson(result);
                    return;
                } else if (!adtype.equals("") && adtype.equalsIgnoreCase(IConstants.AD_TYPE_MFP)) {
                    parseRichMediaInterstitialJson(jsonObject);
                    return;
                } else {
                    Log.i("AirplaySDK", "Invalid ad type delivered in SmartWall: " + adtype);
                    return;
                }
            }
            validateStatusCode(status, msg);
        } catch (JSONException e) {
            Log.e("AirplaySDK", "Error in Smart Wall json: ", e);
        } catch (Exception e2) {
            Log.e("AirplaySDK", "Error in Smart Wall response: ", e2);
        }
    }

    @Override
    public void startAppWall() {
        try {
            Log.i("AirplaySDK", "Initialising AppWall.....");
            if (!isIntegrationIssue && checkSmartWallActivity()) {
                if (activity != null && isSDKEnabled(activity)) {
                    if (SetPreferences.getNextAdCallTime(activity) > System.currentTimeMillis()) {
                        Log.i("AirplaySDK", "AppWall called within 10 secs. Ignoring request");
                        sendAdError("AppWall called within 10 secs. Ignoring request.");
                    } else if (SmartWallActivity.isShowing()) {
                        Log.i("AirplaySDK", "Another ad is showing on screen.");
                        sendAdError("Another ad is showing on screen.");
                    } else {
                        SetPreferences.setNextAdCallTime(activity);
                        AsyncTaskCompleteListener<String> asyncTaskCompleteListener = new AsyncTaskCompleteListener<String>() {
                            @Override
                            public void onTaskComplete(String result) {
                                Log.i("AirplaySDK", "AppWall Json: " + result);
                                if (result != null) {
                                    try {
                                        if (AirPlay.enableCaching) {
                                            JSONObject jsonObject = new JSONObject(result);
                                            int status = jsonObject.isNull("status") ? 0 : jsonObject.getInt("status");
                                            String msg = jsonObject.isNull("message") ? IConstants.INVALID : jsonObject.getString("message");
                                            if (status == 200 && msg.equalsIgnoreCase("Success")) {
                                                AirPlay.this.caching.saveJson(AdCallbackListener.AdType.appwall, result);
                                                SDKIntializer.sendAdCached(AdCallbackListener.AdType.appwall);
                                                return;
                                            }
                                            AirPlay.validateStatusCode(status, msg);
                                            return;
                                        }
                                        AirPlay.this.parseAppWallJson(result);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            }

                            @Override
                            public void launchNewHttpTask() {
                                try {
                                    List<NameValuePair> nameValuePairs = new ArrayList<>();
                                    NetworkThread networkThread = new NetworkThread(AirPlay.activity, this, nameValuePairs, IConstants.URL_APP_WALL, 0L, true);
                                    new Thread(networkThread, "AppWall").start();
                                } catch (NullPointerException e) {
                                    e.printStackTrace();
                                } catch (Exception e2) {
                                    e2.printStackTrace();
                                }
                            }
                        };
                        if (Util.checkInternetConnection(activity)) {
                            asyncTaskCompleteListener.launchNewHttpTask();
                        }
                    }
                } else {
                    Log.i("AirplaySDK", "AirPlay is disabled Please enable to recive ads.");
                    sendAdError("AirPlay is disabled Please enable to recive ads.");
                }
            }
        } catch (Exception exception) {
            Log.e("AirplaySDK", "Error occurred in appwall ", exception);
        }
    }

    @Override
    void parseAppWallJson(String json) {
        try {
            JSONObject jsonObject = new JSONObject(json);
            int status = jsonObject.isNull("status") ? 0 : jsonObject.getInt("status");
            String msg = jsonObject.isNull("message") ? "" : jsonObject.getString("message");
            if (status == 200 && msg.equals("Success")) {
                String url = jsonObject.getString("url");
                if (url != null && !url.equals("")) {
                    SetPreferences.setNextAdCallTime(activity);
                    Intent intent = new Intent(activity, SmartWallActivity.class);
                    intent.setFlags(268435456);
                    intent.addFlags(536870912);
                    intent.addFlags(8388608);
                    intent.setAction("appwallad");
                    intent.putExtra("adtype", IConstants.AD_TYPE_AW);
                    intent.putExtra("url", url);
                    try {
                        activity.startActivity(intent);
                        return;
                    } catch (ActivityNotFoundException e) {
                        Log.e("AirplaySDK", "Required SmartWallActivity not found in Manifest. Please add.");
                        return;
                    }
                }
                return;
            }
            validateStatusCode(status, msg);
        } catch (JSONException e2) {
            Log.e("AirplaySDK", "Error in AppWall json: ", e2);
        } catch (Exception e3) {
            Log.e("AirplaySDK", "Error in AppWall response: ", e3);
        }
    }

    @Override
    public void startLandingPageAd() {
        try {
            Log.i("AirplaySDK", "Initialising LandingPage AD.....");
            if (!isIntegrationIssue && checkSmartWallActivity()) {
                if (activity != null && isSDKEnabled(activity)) {
                    if (SetPreferences.getNextAdCallTime(activity) > System.currentTimeMillis()) {
                        Log.i("AirplaySDK", "LandingPage Ad called within 10 secs. Ignoring request");
                        sendAdError("LandingPage Ad called within 10 secs. Ignoring request");
                    } else if (SmartWallActivity.isShowing()) {
                        Log.i("AirplaySDK", "Another ad is showing on screen.");
                        sendAdError("Another ad is showing on screen.");
                    } else {
                        SetPreferences.setNextAdCallTime(activity);
                        AsyncTaskCompleteListener<String> asyncTaskCompleteListener = new AsyncTaskCompleteListener<String>() {
                            @Override
                            public void onTaskComplete(String result) {
                                Log.i("AirplaySDK", "LandingPage Json: " + result);
                                if (result != null) {
                                    try {
                                        if (AirPlay.enableCaching) {
                                            JSONObject jsonObject = new JSONObject(result);
                                            int status = jsonObject.isNull("status") ? 0 : jsonObject.getInt("status");
                                            String msg = jsonObject.isNull("message") ? IConstants.INVALID : jsonObject.getString("message");
                                            if (status == 200 && msg.equalsIgnoreCase("Success")) {
                                                AirPlay.this.caching.saveJson(AdCallbackListener.AdType.landing_page, result);
                                                SDKIntializer.sendAdCached(AdCallbackListener.AdType.landing_page);
                                                return;
                                            }
                                            AirPlay.validateStatusCode(status, msg);
                                            return;
                                        }
                                        AirPlay.this.parseLandingPageAdJson(result);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            }

                            @Override
                            public void launchNewHttpTask() {
                                try {
                                    List<NameValuePair> nameValuePairs = new ArrayList<>();
                                    NetworkThread networkThread = new NetworkThread(AirPlay.activity, this, nameValuePairs, IConstants.URL_FULL_PAGE, 0L, true);
                                    new Thread(networkThread, "SmartWall").start();
                                } catch (Exception e) {
                                }
                            }
                        };
                        if (Util.checkInternetConnection(activity)) {
                            asyncTaskCompleteListener.launchNewHttpTask();
                        }
                    }
                } else {
                    Log.i("AirplaySDK", "AirPlay is disabled Please enable to recive ads.");
                    sendAdError("AirPlay is disabled Please enable to recive ads.");
                }
            }
        } catch (Exception exception) {
            Log.e("AirplaySDK", "Error occurred in LandingPage ad: ", exception);
        }
    }

    @Override
    void parseLandingPageAdJson(String json) {
        String msg;
        String url;
        if (json != null) {
            try {
                try {
                    JSONObject jsonObject = new JSONObject(json);
                    int status = jsonObject.isNull("status") ? 200 : jsonObject.getInt("status");
                    if (jsonObject.isNull("message")) {
                        msg = IConstants.INVALID;
                    } else {
                        msg = jsonObject.getString("message");
                    }
                    if (status == 200 && msg.equals("Success")) {
                        if (jsonObject.isNull("url")) {
                            url = IConstants.INVALID;
                        } else {
                            url = jsonObject.getString("url");
                        }
                        if (!url.equals(IConstants.INVALID)) {
                            SetPreferences.setNextAdCallTime(activity);
                            Intent intent = new Intent(activity, SmartWallActivity.class);
                            intent.setAction("lpad");
                            intent.setFlags(268435456);
                            intent.addFlags(536870912);
                            intent.addFlags(8388608);
                            intent.putExtra("adtype", IConstants.AD_TYPE_FP);
                            intent.putExtra("url", url);
                            try {
                                activity.startActivity(intent);
                                return;
                            } catch (ActivityNotFoundException e) {
                                Log.e("AirplaySDK", "Required SmartWallActivity not found in Manifest. Please add.");
                                return;
                            } catch (Exception e2) {
                                return;
                            }
                        }
                        return;
                    }
                    validateStatusCode(status, msg);
                } catch (JSONException e3) {
                    Log.e("AirplaySDK", "Error in LandingPage json: ", e3);
                }
            } catch (Exception e4) {
                Log.e("AirplaySDK", "Error in LandingPage response: ", e4);
            }
        }
    }

    @Override
    public void showRichMediaInterstitialAd() {
        try {
            Log.i("AirplaySDK", "Initialising Rich Media Interstitial Ad.....");
            if (!isIntegrationIssue && checkSmartWallintegration()) {
                if (activity != null && isSDKEnabled(activity)) {
                    if (SetPreferences.getNextAdCallTime(activity) > System.currentTimeMillis()) {
                        Log.i("AirplaySDK", "Rich Media Interstitial Ad called within 10 secs. Ignoring request");
                        sendAdError("Rich Media Interstitial Ad called within 10 secs. Ignoring request");
                    } else if (SmartWallActivity.isShowing()) {
                        Log.i("AirplaySDK", "Another ad is showing on screen.");
                        sendAdError("Another ad is showing on screen.");
                    } else {
                        SetPreferences.setNextAdCallTime(activity);
                        AsyncTaskCompleteListener<String> asyncTaskCompleteListener = new AsyncTaskCompleteListener<String>() {
                            @Override
                            public void onTaskComplete(String result) {
                                Log.i("AirplaySDK", "Rich Media Ad Json: " + result);
                                if (result != null) {
                                    try {
                                        JSONObject jsonObject = new JSONObject(result);
                                        int status = jsonObject.isNull("status") ? 0 : jsonObject.getInt("status");
                                        String msg = jsonObject.isNull("message") ? IConstants.INVALID : jsonObject.getString("message");
                                        String adtype = jsonObject.isNull("adtype") ? null : jsonObject.getString("adtype");
                                        if (adtype == null || !adtype.equals(IConstants.AD_TYPE_MFP)) {
                                            Log.w("AirplaySDK", "Invalid adtype: " + adtype);
                                        } else if (status == 200 && msg.equalsIgnoreCase("Success")) {
                                            if (AirPlay.enableCaching) {
                                                AirPlay.this.caching.saveJson(AdCallbackListener.AdType.interstitial, result);
                                                SDKIntializer.sendAdCached(AdCallbackListener.AdType.interstitial);
                                                return;
                                            }
                                            AirPlay.this.parseRichMediaInterstitialJson(jsonObject);
                                        } else {
                                            AirPlay.validateStatusCode(status, msg);
                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            }

                            @Override
                            public void launchNewHttpTask() {
                                try {
                                    List<NameValuePair> list = new ArrayList<>();
                                    list.add(new BasicNameValuePair("banner_type", "rich_media"));
                                    list.add(new BasicNameValuePair("supports", "" + Util.getSupportsJson(AirPlay.activity)));
                                    list.add(new BasicNameValuePair("placement_type", "fullpage"));
                                    NetworkThread networkThread = new NetworkThread(AirPlay.activity, this, list, IConstants.URL_MRAID_API, 0L, true);
                                    Thread thread = new Thread(networkThread, "AdView");
                                    thread.start();
                                } catch (Exception e) {
                                }
                            }
                        };
                        if (Util.checkInternetConnection(activity)) {
                            asyncTaskCompleteListener.launchNewHttpTask();
                        }
                    }
                } else {
                    Log.i("AirplaySDK", "AirPlay is disabled Please enable to recive ads.");
                    sendAdError("AirPlay is disabled Please enable to recive ads.");
                }
            }
        } catch (Exception e) {
            Log.e("AirplaySDK", "Error occurred in Rich Media interstital ad: ", e);
        }
    }

    @Override
    void parseRichMediaInterstitialJson(JSONObject jsonObject) {
        try {
            parseMraidJson = new FormatAds.ParseMraidJson(activity, jsonObject);
            String doc = Util.getDoc(activity);
            if (doc != null && !doc.equals("")) {
                SetPreferences.setNextAdCallTime(activity);
                Intent intent = new Intent(activity, SmartWallActivity.class);
                intent.setAction("mfpad");
                intent.setFlags(268435456);
                intent.addFlags(8388608);
                intent.addFlags(536870912);
                intent.putExtra("adtype", IConstants.AD_TYPE_MFP);
                activity.startActivity(intent);
            } else {
                AsyncTaskCompleteListener<Boolean> getDoc = new AsyncTaskCompleteListener<Boolean>() {
                    @Override
                    public void onTaskComplete(Boolean result) {
                        if (result.booleanValue()) {
                            SetPreferences.setNextAdCallTime(AirPlay.activity);
                            Intent intent2 = new Intent(AirPlay.activity, SmartWallActivity.class);
                            intent2.setAction("mfpad");
                            intent2.setFlags(268435456);
                            intent2.addFlags(8388608);
                            intent2.addFlags(536870912);
                            intent2.putExtra("adtype", IConstants.AD_TYPE_MFP);
                            AirPlay.activity.startActivity(intent2);
                            return;
                        }
                        Log.e("AirplaySDK", "Not able to get doc.");
                    }

                    @Override
                    public void launchNewHttpTask() {
                        Util.NativeMraid nativeMraid = new Util.NativeMraid(AirPlay.activity, this);
                        new Thread(nativeMraid, "native").start();
                    }
                };
                if (Util.checkInternetConnection(activity)) {
                    getDoc.launchNewHttpTask();
                }
            }
        } catch (IOException e) {
            Log.i("AirplaySDK", "Rich Media Full Page: " + e.getMessage());
        } catch (JSONException e2) {
            e2.printStackTrace();
        } catch (Exception e3) {
            e3.printStackTrace();
        }
    }

    public static final void validateStatusCode(int status, String message) {
        if (message != null && !message.equals("")) {
            switch (status) {
                case 100:
                    sendIntegrationError(message);
                    return;
                case 120:
                    sendIntegrationError(message);
                    return;
                case 130:
                    sendIntegrationError(message);
                    return;
                case 150:
                    sendAdError(message);
                    return;
                case ServerCommunicationException.ERROR_NO_CONTENT:
                    sendAdError(message);
                    return;
                default:
                    return;
            }
        }
    }

    static boolean checkRequiredDetails(Context mContext) {
        boolean result = true;
        if (mContext == null) {
            try {
                Log.e("AirplaySDK", "Context is null.");
                sendIntegrationError("Context is null");
                result = false;
            } catch (Exception exception) {
                Log.e("AirplaySDK", "Error occurred while checking required details: ", exception);
                return false;
            }
        }
        if (!getDataFromManifest(mContext)) {
            result = false;
        }
        if (!checkRequiredPermission(mContext)) {
            result = false;
        }
        UserDetails details = new UserDetails(mContext);
        if (!details.setImeiInMd5()) {
            result = false;
        }
        new SetPreferences(mContext).setPreferencesData();
        return result;
    }

    private boolean checkSmartWallintegration() {
        try {
            boolean result = checkSmartWallActivity();
            if (!Util.isIntentAvailable(activity, BrowserActivity.class)) {
                Log.e("AirplaySDK", "Required BrowserActivity not found in Manifest. Please add.");
                sendIntegrationError("Required BrowserActivity not found in Manifest. Please add.");
                new SendIntegrationError(activity, 104);
                return false;
            }
            return result;
        } catch (Exception exception) {
            Log.e("AirplaySDK", "Error occurred while validating SmartWall: ", exception);
            return false;
        }
    }

    private boolean checkSmartWallActivity() throws NullPointerException, Exception {
        if (Util.isIntentAvailable(activity, SmartWallActivity.class)) {
            return true;
        }
        Log.e("AirplaySDK", "Required SmartWallActivity not found in Manifest. Please add.");
        sendIntegrationError("Required SmartWallActivity not found in Manifest. Please add.");
        new SendIntegrationError(activity, 103);
        return false;
    }

    @Override
    public void startVideoAd() {
        try {
            if (Build.VERSION.SDK_INT < 8) {
                Log.e("AirplaySDK", "Video ad supported on Android 2.2 and later devices.");
                sendAdError("Video ad supported on Android 2.2 and later devices.");
            } else {
                Log.i("AirplaySDK", "Initialising video ad.....");
                if (isSDKEnabled(activity)) {
                    if (isIntegrationIssue || !VideoAd.checkVideoAdPermission(activity)) {
                        Log.e("AirplaySDK", "Integration issue is there");
                    } else {
                        boolean available = Util.isIntentAvailable(activity, VideoAdActivity.class);
                        if (!available) {
                            Log.e("AirplaySDK", "Required VideoAdActivity not found in Manifest. Please add");
                            sendIntegrationError("Required VideoAdActivity not found in Manifest. Please add");
                            new SendIntegrationError(activity, 102);
                        } else {
                            String mediaState = Environment.getExternalStorageState();
                            if (mediaState != null && mediaState.equalsIgnoreCase("mounted")) {
                                if (SmartWallActivity.isShowing()) {
                                    Log.w("AirplaySDK", "Another ad is already showing on screen.");
                                    sendAdError("Another ad is already showing on screen.");
                                } else if (System.currentTimeMillis() < SetPreferences.getNextVideoAdCallTime(activity)) {
                                    Log.w("AirplaySDK", "Video ad is before 30 secs. Ignoring request.");
                                    sendAdError("Video ad is before 30 secs. Ignoring request.");
                                } else {
                                    VideoAd ad = new VideoAd(activity);
                                    if (Util.checkInternetConnection(activity)) {
                                        ad.launchNewHttpTask();
                                    }
                                }
                            } else {
                                Log.w("AirplaySDK", "Can't call video ad at this time. SD card not mounted.");
                                sendAdError("Can't call video ad at this time. SD card not mounted.");
                            }
                        }
                    }
                } else {
                    Log.e("AirplaySDK", "AirPlay is disabled please enable to receive ads.");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void startOverlayAd() {
        try {
            Log.i("AirplaySDK", "Initialising Overlay AD.....");
            if (!isIntegrationIssue && checkSmartWallActivity()) {
                if (isSDKEnabled(activity)) {
                    if (SetPreferences.getNextAdCallTime(activity) > System.currentTimeMillis()) {
                        Log.i("AirplaySDK", "Overlay Ad called within 10 secs. Ignoring request");
                        sendAdError("Overlay Ad called within 10 secs. Ignoring request");
                    } else if (SmartWallActivity.isShowing()) {
                        Log.i("AirplaySDK", "Another ad is showing on screen.");
                        sendAdError("Another ad is showing on screen.");
                    } else {
                        SetPreferences.setNextAdCallTime(activity);
                        AsyncTaskCompleteListener<String> asyncTaskCompleteListener = new AsyncTaskCompleteListener<String>() {
                            @Override
                            public void onTaskComplete(String result) {
                                Log.i("AirplaySDK", "Overlay Json: " + result);
                                if (result != null) {
                                    try {
                                        if (!AirPlay.enableCaching) {
                                            AirPlay.this.showOverlayAd(result);
                                            return;
                                        }
                                        JSONObject jsonObject = new JSONObject(result);
                                        int status = jsonObject.isNull("status") ? 0 : jsonObject.getInt("status");
                                        String msg = jsonObject.isNull("message") ? IConstants.INVALID : jsonObject.getString("message");
                                        if (status == 200 && msg.equalsIgnoreCase("Success")) {
                                            AirPlay.this.caching.saveJson(AdCallbackListener.AdType.overlay, result);
                                            SDKIntializer.sendAdCached(AdCallbackListener.AdType.overlay);
                                            return;
                                        }
                                        AirPlay.validateStatusCode(status, msg);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            }

                            @Override
                            public void launchNewHttpTask() {
                                try {
                                    List<NameValuePair> nameValuePairs = new ArrayList<>();
                                    NetworkThread networkThread = new NetworkThread(AirPlay.activity, this, nameValuePairs, "https://api.airpush.com/overlayads/overlayadcall.php", 0L, true);
                                    new Thread(networkThread, "overlay").start();
                                } catch (Exception e) {
                                    Log.e("AirplaySDK", "Error occurred in while requesting: ", e);
                                }
                            }
                        };
                        if (Util.checkInternetConnection(activity)) {
                            asyncTaskCompleteListener.launchNewHttpTask();
                        }
                    }
                } else {
                    Log.i("AirplaySDK", "AirPlay SDK is disabled Please enable to recive ads.");
                    sendAdError("AirPlay SDK is disabled Please enable to recive ads.");
                }
            }
        } catch (Exception exception) {
            Log.e("AirplaySDK", "Error occurred in Overlay ad: ", exception);
        }
    }

    public void showOverlayAd(String result) {
        try {
            JSONObject jsonObject = new JSONObject(result);
            int status = jsonObject.isNull("status") ? 0 : jsonObject.getInt("status");
            String msg = jsonObject.isNull("message") ? IConstants.INVALID : jsonObject.getString("message");
            final String adtype = jsonObject.isNull("adtype") ? "" : jsonObject.getString("adtype");
            boolean error = jsonObject.isNull(IMraid.EVENT_ERROR) ? false : jsonObject.getBoolean(IMraid.EVENT_ERROR);
            if (status == 200 && msg.equalsIgnoreCase("Success")) {
                String data = jsonObject.isNull("data") ? "nodata" : jsonObject.getString("data");
                if (!data.equals("nodata")) {
                    JSONObject jsonObject2 = new JSONObject(data);
                    String tag = jsonObject2.getString("tag");
                    int height = jsonObject2.getInt("height");
                    int width = jsonObject2.getInt("width");
                    String imp_url = jsonObject2.getString("api_url");
                    OverlayAd.setAdtype(adtype);
                    OverlayAd.setApiUrl(imp_url);
                    OverlayAd.setError(error);
                    OverlayAd.setWidth(width);
                    OverlayAd.setHeight(height);
                    OverlayAd.setTag(tag);
                    if (adtype.equals("OLAU") || adtype.equals(IConstants.AD_TYPE_DAU) || adtype.equals(IConstants.AD_TYPE_DCC) || adtype.equals(IConstants.AD_TYPE_DCM)) {
                        new Thread(new Runnable() {
                            @Override
                            public void run() {
                                Intent intent = new Intent(AirPlay.activity, SmartWallActivity.class);
                                intent.setFlags(268435456);
                                intent.addFlags(8388608);
                                intent.setAction("overlayad");
                                intent.putExtra("adtype", adtype);
                                AirPlay.activity.startActivity(intent);
                            }
                        }, "overlay_showing").start();
                        return;
                    } else {
                        Log.w("AirplaySDK", "Invalid adtype delivered in overylay ad " + adtype);
                        return;
                    }
                }
                return;
            }
            validateStatusCode(status, msg);
        } catch (Exception e) {
            Log.e("AirplaySDK", "Error occurred in overlay ad", e);
        }
    }

    @Override
    public void showCachedAd(Activity activity2, AdCallbackListener.AdType adType) {
        try {
            if (activity2 == null || adType == null) {
                Log.e("AirplaySDK", "Activity or Adtype is null.");
                sendIntegrationError("Activity or Adtype is null.");
                return;
            }
            activity = activity2;
            if (SmartWallActivity.isShowing()) {
                if (adCallbackListener != null) {
                    adCallbackListener.onAdError("Another ad is showing on screen.");
                    return;
                }
                return;
            }
            if (this.caching == null) {
                this.caching = new Caching(activity2);
            }
            switch (adType) {
                case smartwall:
                    String jsonString = this.caching.getJson(AdCallbackListener.AdType.smartwall);
                    if (jsonString != null && !jsonString.equals("")) {
                        parseSmartwallJson(jsonString);
                        return;
                    } else {
                        validateStatusCode(ServerCommunicationException.ERROR_NO_CONTENT, "SmartWall ad is not available in cache");
                        return;
                    }
                case appwall:
                    String jsonString2 = this.caching.getJson(AdCallbackListener.AdType.appwall);
                    if (jsonString2 != null && !jsonString2.equals("")) {
                        parseAppWallJson(jsonString2);
                        return;
                    } else {
                        validateStatusCode(ServerCommunicationException.ERROR_NO_CONTENT, "Appwall ad is not available in cache");
                        return;
                    }
                case landing_page:
                    String jsonString3 = this.caching.getJson(AdCallbackListener.AdType.landing_page);
                    if (jsonString3 != null && !jsonString3.equals("")) {
                        parseLandingPageAdJson(jsonString3);
                        return;
                    } else {
                        validateStatusCode(ServerCommunicationException.ERROR_NO_CONTENT, "Landingpage is not available in cache");
                        return;
                    }
                case interstitial:
                    String jsonString4 = this.caching.getJson(AdCallbackListener.AdType.interstitial);
                    if (jsonString4 != null && !jsonString4.equals("")) {
                        JSONObject jsonObject = new JSONObject(jsonString4);
                        parseRichMediaInterstitialJson(jsonObject);
                        return;
                    }
                    validateStatusCode(ServerCommunicationException.ERROR_NO_CONTENT, "Interstitial ad is not available in cache");
                    return;
                case video:
                    VideoAd videoAd = new VideoAd(activity2);
                    videoAd.starVideoAdActivity();
                    return;
                case overlay:
                    String jsonString5 = this.caching.getJson(AdCallbackListener.AdType.overlay);
                    if (jsonString5 != null && !jsonString5.equals("")) {
                        showOverlayAd(jsonString5);
                        return;
                    } else {
                        validateStatusCode(ServerCommunicationException.ERROR_NO_CONTENT, "Overlay ad is not available in cache");
                        return;
                    }
                default:
                    sendAdError("Invalid AdType.");
                    return;
            }
        } catch (Exception e) {
            Log.e("AirplaySDK", "Error occurred in caching ad", e);
        }
    }
}