鸠摩搜书官方正版 v1.7版本的 MD5 值为:01c9a20d2c415de3233d7f691829edf5

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


package com.adchina.android.ads.controllers;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.os.Message;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import com.adchina.android.ads.AdEngine;
import com.adchina.android.ads.AdManager;
import com.adchina.android.ads.LogUtil;
import com.adchina.android.ads.Utils;
import com.adchina.android.ads.views.AdView;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import org.xmlpull.v1.XmlPullParserException;

public final class a extends BaseController {
    private static int[] h;
    private static int[] i;

    private long f76a;
    private LinkedList b;
    private HashMap c;
    private int d;
    private int e;
    private boolean f;
    private boolean g;

    public a(Context context) {
        super(context);
        this.f76a = 0L;
        this.b = new LinkedList();
        this.c = new HashMap();
        this.d = 0;
        this.e = 0;
        this.f = true;
        this.g = false;
    }

    private void a(int i2, int i3) {
        this.d = i2;
        this.e = i3;
    }

    private InputStream b(String str) {
        InputStream inputStream;
        Exception exc;
        InputStream inputStream2;
        InputStream inputStream3;
        boolean z = false;
        boolean z2 = false;
        try {
            LogUtil.addLog("开始下载素材 ");
            this.logger.c(Utils.concatString("++ start to download Banner Img file", str));
            File file = new File(com.adchina.android.ads.k.d);
            if (!file.exists()) {
                file.mkdirs();
            }
            com.adchina.android.ads.t tVar = this.mHttpEngine;
            inputStream = com.adchina.android.ads.t.b(str);
            try {
                if (file.exists()) {
                    File file2 = new File(file, Utils.concatString(Utils.getNowTime("yyyyMMddHHmmss"), "bnImg.tmp"));
                    ?? exists = file2.exists();
                    if (exists != 0) {
                        file2.delete();
                    }
                    try {
                        try {
                            try {
                                exists = new FileOutputStream(file2);
                            } catch (Throwable th) {
                                th = th;
                            }
                        } catch (Exception e) {
                            e = e;
                        } catch (Throwable th2) {
                            th = th2;
                            exists = 0;
                            z = false;
                        }
                        try {
                            byte[] bArr = new byte[16384];
                            boolean z3 = false;
                            while (true) {
                                try {
                                    int read = inputStream.read(bArr);
                                    if (read <= 0) {
                                        break;
                                    }
                                    exists.write(bArr, 0, read);
                                    z3 = true;
                                } catch (Exception e2) {
                                    e = e2;
                                    LogUtil.addLog("异常1  downLoadAndSaveImg------------------>");
                                    e.printStackTrace();
                                    if (file2.exists()) {
                                        file2.delete();
                                    }
                                    throw e;
                                }
                            }
                            if (z3) {
                                com.adchina.android.ads.t tVar2 = this.mHttpEngine;
                                com.adchina.android.ads.t.a(inputStream);
                            }
                            Utils.closeStream((OutputStream) exists);
                            this.c.put(str, file2.getAbsolutePath());
                            f();
                            inputStream3 = new FileInputStream(file2.getAbsolutePath());
                        } catch (Exception e3) {
                            e = e3;
                        } catch (Throwable th3) {
                            th = th3;
                            z = false;
                            if (z) {
                                com.adchina.android.ads.t tVar3 = this.mHttpEngine;
                                com.adchina.android.ads.t.a(inputStream);
                            }
                            Utils.closeStream((OutputStream) exists);
                            throw th;
                        }
                    } catch (Exception e4) {
                        exc = e4;
                        z2 = false;
                        inputStream2 = inputStream;
                        try {
                            LogUtil.addLog("异常2 downLoadAndSaveImg------------------>");
                            String concatString = Utils.concatString("Failed to download Banner Img file, err = ", exc.toString());
                            this.logger.c(concatString);
                            Log.e("AdChinaError", concatString);
                            if (!z2 && inputStream2 != null) {
                                return inputStream2;
                            }
                            com.adchina.android.ads.t tVar4 = this.mHttpEngine;
                            return com.adchina.android.ads.t.b(str);
                        } catch (Throwable th4) {
                            inputStream = inputStream2;
                            th = th4;
                            if (!z2 || inputStream == null) {
                                com.adchina.android.ads.t tVar5 = this.mHttpEngine;
                                com.adchina.android.ads.t.b(str);
                            }
                            throw th;
                        }
                    } catch (Throwable th5) {
                        th = th5;
                        z2 = false;
                        if (!z2) {
                        }
                        com.adchina.android.ads.t tVar52 = this.mHttpEngine;
                        com.adchina.android.ads.t.b(str);
                        throw th;
                    }
                } else {
                    inputStream3 = inputStream;
                }
                if (inputStream3 != null) {
                    return inputStream3;
                }
                com.adchina.android.ads.t tVar6 = this.mHttpEngine;
                return com.adchina.android.ads.t.b(str);
            } catch (Exception e5) {
                exc = e5;
                inputStream2 = inputStream;
            } catch (Throwable th6) {
                th = th6;
            }
        } catch (Exception e6) {
            exc = e6;
            inputStream2 = null;
        } catch (Throwable th7) {
            th = th7;
            inputStream = null;
        }
    }

    private void c() {
        LogUtil.addLog("开始  得到素材onGetImgMaterial");
        this.logger.c("++ onGetImgMaterial");
        setRecvAdStatus(com.adchina.android.ads.g.EIdle);
        InputStream inputStream = null;
        try {
            try {
                String stringBuffer = this.mImgAddr.toString();
                if (com.adchina.android.ads.l.EAdNONE != this.mAdModel && com.adchina.android.ads.l.EAdTXT != this.mAdModel) {
                    if (this.c.containsKey(stringBuffer)) {
                        InputStream fileInputStream = new FileInputStream((String) this.c.get(stringBuffer));
                        try {
                            this.logger.c("++ load local banner img");
                            inputStream = fileInputStream;
                        } catch (Exception e) {
                            e = e;
                            inputStream = fileInputStream;
                            LogUtil.addLog("异常  onGetImgMaterial------------------>");
                            String concatString = Utils.concatString("Failed to get ad material, err = ", e.toString());
                            if (concatString.contains("Null")) {
                                concatString = String.valueOf(concatString) + 1;
                            }
                            sendMessage(2, concatString);
                            this.logger.c(concatString);
                            Log.e("AdChinaError", concatString);
                            com.adchina.android.ads.t tVar = this.mHttpEngine;
                            com.adchina.android.ads.t.a(inputStream);
                            LogUtil.addLog("结束  得到素材onGetImgMaterial");
                            this.logger.c(Utils.concatString("-- onGetImgMaterial, AdModel = ", this.mAdModel));
                            return;
                        } catch (Throwable th) {
                            th = th;
                            inputStream = fileInputStream;
                            com.adchina.android.ads.t tVar2 = this.mHttpEngine;
                            com.adchina.android.ads.t.a(inputStream);
                            LogUtil.addLog("结束  得到素材onGetImgMaterial");
                            this.logger.c(Utils.concatString("-- onGetImgMaterial, AdModel = ", this.mAdModel));
                            throw th;
                        }
                    } else {
                        inputStream = b(stringBuffer);
                        this.logger.c("++ load remote banner img");
                    }
                }
                if (com.adchina.android.ads.l.EAdJPG == this.mAdModel) {
                    Bitmap convertStreamToBitmap = Utils.convertStreamToBitmap(inputStream);
                    if (convertStreamToBitmap != null) {
                        a(convertStreamToBitmap.getWidth(), convertStreamToBitmap.getHeight());
                        sendMessage(1, convertStreamToBitmap);
                    } else {
                        sendMessage(2, "JPG AdMaterial is null");
                    }
                } else if (com.adchina.android.ads.l.EAdPNG == this.mAdModel) {
                    Bitmap convertStreamToBitmap2 = Utils.convertStreamToBitmap(inputStream);
                    if (convertStreamToBitmap2 != null) {
                        a(convertStreamToBitmap2.getWidth(), convertStreamToBitmap2.getHeight());
                        sendMessage(1, convertStreamToBitmap2);
                    } else {
                        sendMessage(2, "PNG AdMaterial is null");
                    }
                } else if (com.adchina.android.ads.l.EAdGIF == this.mAdModel) {
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    while (true) {
                        int read = inputStream.read();
                        if (read == -1) {
                            break;
                        } else {
                            byteArrayOutputStream.write(read);
                        }
                    }
                    byte[] byteArray = byteArrayOutputStream.toByteArray();
                    if (byteArray != null) {
                        com.adchina.android.ads.o a2 = com.adchina.android.ads.o.a(byteArray);
                        a(a2.b(), a2.c());
                        sendMessage(1, a2);
                    }
                    byteArrayOutputStream.close();
                }
                com.adchina.android.ads.t tVar3 = this.mHttpEngine;
                com.adchina.android.ads.t.a(inputStream);
                LogUtil.addLog("结束  得到素材onGetImgMaterial");
                this.logger.c(Utils.concatString("-- onGetImgMaterial, AdModel = ", this.mAdModel));
            } catch (Exception e2) {
                e = e2;
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    private void d() {
        File file = new File(com.adchina.android.ads.k.d);
        if (file.exists()) {
            File[] listFiles = file.listFiles();
            for (File file2 : listFiles) {
                if (!this.c.containsValue(file2.getAbsolutePath())) {
                    file2.delete();
                }
            }
        }
    }

    private void e() {
        InputStreamReader inputStreamReader;
        FileInputStream fileInputStream;
        char[] cArr;
        FileInputStream fileInputStream2 = null;
        this.logger.c("loadLocalBannerImgList");
        try {
            cArr = new char[(int) this.mContext.getFileStreamPath("adchinaBNImgs.fc").length()];
            fileInputStream = this.mContext.openFileInput("adchinaBNImgs.fc");
            try {
                inputStreamReader = new InputStreamReader(fileInputStream);
            } catch (Exception e) {
                e = e;
                inputStreamReader = null;
                fileInputStream2 = fileInputStream;
            } catch (Throwable th) {
                th = th;
                inputStreamReader = null;
            }
        } catch (Exception e2) {
            e = e2;
            inputStreamReader = null;
        } catch (Throwable th2) {
            th = th2;
            inputStreamReader = null;
            fileInputStream = null;
        }
        try {
            inputStreamReader.read(cArr);
            String str = new String(cArr);
            this.c.clear();
            for (String str2 : str.split("\n")) {
                int indexOf = str2.indexOf("|||");
                String substring = str2.substring(0, indexOf);
                String substring2 = str2.substring(indexOf + 3);
                File file = new File(substring2);
                if (file.exists() && !Utils.isCachedFileTimeout(file.getName())) {
                    this.c.put(substring, substring2);
                }
            }
            try {
                inputStreamReader.close();
                if (fileInputStream != null) {
                    fileInputStream.close();
                }
                d();
            } catch (IOException e3) {
                this.logger.c(Utils.concatString("Exceptions in loadLocalBannerImgList , err = ", e3.toString()));
            }
        } catch (Exception e4) {
            e = e4;
            fileInputStream2 = fileInputStream;
            try {
                this.logger.c(Utils.concatString("Exceptions in loadLocalBannerImgList , err = ", e.toString()));
                if (inputStreamReader != null) {
                    try {
                        inputStreamReader.close();
                    } catch (IOException e5) {
                        this.logger.c(Utils.concatString("Exceptions in loadLocalBannerImgList , err = ", e5.toString()));
                        return;
                    }
                }
                if (fileInputStream2 != null) {
                    fileInputStream2.close();
                }
                d();
            } catch (Throwable th3) {
                th = th3;
                fileInputStream = fileInputStream2;
                if (inputStreamReader != null) {
                    try {
                        inputStreamReader.close();
                    } catch (IOException e6) {
                        this.logger.c(Utils.concatString("Exceptions in loadLocalBannerImgList , err = ", e6.toString()));
                        throw th;
                    }
                }
                if (fileInputStream != null) {
                    fileInputStream.close();
                }
                d();
                throw th;
            }
        } catch (Throwable th4) {
            th = th4;
            if (inputStreamReader != null) {
            }
            if (fileInputStream != null) {
            }
            d();
            throw th;
        }
    }

    private void f() {
        OutputStreamWriter outputStreamWriter;
        FileOutputStream fileOutputStream;
        FileOutputStream fileOutputStream2 = null;
        this.logger.c("saveLocalBannerImgList");
        try {
            fileOutputStream = this.mContext.openFileOutput("adchinaBNImgs.fc", 0);
            try {
                outputStreamWriter = new OutputStreamWriter(fileOutputStream);
            } catch (Exception e) {
                e = e;
                outputStreamWriter = null;
                fileOutputStream2 = fileOutputStream;
            } catch (Throwable th) {
                th = th;
                outputStreamWriter = null;
            }
        } catch (Exception e2) {
            e = e2;
            outputStreamWriter = null;
        } catch (Throwable th2) {
            th = th2;
            outputStreamWriter = null;
            fileOutputStream = null;
        }
        try {
            for (String str : this.c.keySet()) {
                outputStreamWriter.write(str);
                outputStreamWriter.write("|||");
                outputStreamWriter.write((String) this.c.get(str));
                outputStreamWriter.write("\n");
            }
            outputStreamWriter.flush();
            try {
                outputStreamWriter.close();
                if (fileOutputStream != null) {
                    fileOutputStream.close();
                }
            } catch (IOException e3) {
            }
        } catch (Exception e4) {
            e = e4;
            fileOutputStream2 = fileOutputStream;
            try {
                this.logger.c(Utils.concatString("Exceptions in saveLocalBannerImgList, err = ", e.toString()));
                if (outputStreamWriter != null) {
                    try {
                        outputStreamWriter.close();
                    } catch (IOException e5) {
                        return;
                    }
                }
                if (fileOutputStream2 != null) {
                    fileOutputStream2.close();
                }
            } catch (Throwable th3) {
                th = th3;
                fileOutputStream = fileOutputStream2;
                if (outputStreamWriter != null) {
                    try {
                        outputStreamWriter.close();
                    } catch (IOException e6) {
                        throw th;
                    }
                }
                if (fileOutputStream != null) {
                    fileOutputStream.close();
                }
                throw th;
            }
        } catch (Throwable th4) {
            th = th4;
            if (outputStreamWriter != null) {
            }
            if (fileOutputStream != null) {
            }
            throw th;
        }
    }

    private static int[] g() {
        int[] iArr = h;
        if (iArr == null) {
            iArr = new int[com.adchina.android.ads.g.valuesCustom().length];
            try {
                iArr[com.adchina.android.ads.g.EGetImgMaterial.ordinal()] = 3;
            } catch (NoSuchFieldError e) {
            }
            try {
                iArr[com.adchina.android.ads.g.EGetShrinkFSImgMaterial.ordinal()] = 2;
            } catch (NoSuchFieldError e2) {
            }
            try {
                iArr[com.adchina.android.ads.g.EIdle.ordinal()] = 17;
            } catch (NoSuchFieldError e3) {
            }
            try {
                iArr[com.adchina.android.ads.g.EReceiveAd.ordinal()] = 1;
            } catch (NoSuchFieldError e4) {
            }
            try {
                iArr[com.adchina.android.ads.g.ERefreshAd.ordinal()] = 6;
            } catch (NoSuchFieldError e5) {
            }
            try {
                iArr[com.adchina.android.ads.g.ESendFullScreenEndedTrack.ordinal()] = 16;
            } catch (NoSuchFieldError e6) {
            }
            try {
                iArr[com.adchina.android.ads.g.ESendFullScreenImpTrack.ordinal()] = 14;
            } catch (NoSuchFieldError e7) {
            }
            try {
                iArr[com.adchina.android.ads.g.ESendFullScreenStartedTrack.ordinal()] = 13;
            } catch (NoSuchFieldError e8) {
            }
            try {
                iArr[com.adchina.android.ads.g.ESendFullScreenThdImpTrack.ordinal()] = 15;
            } catch (NoSuchFieldError e9) {
            }
            try {
                iArr[com.adchina.android.ads.g.ESendImpTrack.ordinal()] = 4;
            } catch (NoSuchFieldError e10) {
            }
            try {
                iArr[com.adchina.android.ads.g.ESendShrinkFSImpTrack.ordinal()] = 7;
            } catch (NoSuchFieldError e11) {
            }
            try {
                iArr[com.adchina.android.ads.g.ESendShrinkFSThdImpTrack.ordinal()] = 8;
            } catch (NoSuchFieldError e12) {
            }
            try {
                iArr[com.adchina.android.ads.g.ESendThdImpTrack.ordinal()] = 5;
            } catch (NoSuchFieldError e13) {
            }
            try {
                iArr[com.adchina.android.ads.g.ESendVideoEndedImpTrack.ordinal()] = 11;
            } catch (NoSuchFieldError e14) {
            }
            try {
                iArr[com.adchina.android.ads.g.ESendVideoEndedThdImpTrack.ordinal()] = 12;
            } catch (NoSuchFieldError e15) {
            }
            try {
                iArr[com.adchina.android.ads.g.ESendVideoStartedImpTrack.ordinal()] = 9;
            } catch (NoSuchFieldError e16) {
            }
            try {
                iArr[com.adchina.android.ads.g.ESendVideoStartedThdImpTrack.ordinal()] = 10;
            } catch (NoSuchFieldError e17) {
            }
            h = iArr;
        }
        return iArr;
    }

    private static int[] h() {
        int[] iArr = i;
        if (iArr == null) {
            iArr = new int[com.adchina.android.ads.f.valuesCustom().length];
            try {
                iArr[com.adchina.android.ads.f.EIdle.ordinal()] = 14;
            } catch (NoSuchFieldError e) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendBtnClkTrack.ordinal()] = 3;
            } catch (NoSuchFieldError e2) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendBtnThdClkTrack.ordinal()] = 4;
            } catch (NoSuchFieldError e3) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendClkTrack.ordinal()] = 1;
            } catch (NoSuchFieldError e4) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendFullScreenClkThdTrack.ordinal()] = 12;
            } catch (NoSuchFieldError e5) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendFullScreenClkTrack.ordinal()] = 11;
            } catch (NoSuchFieldError e6) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendFullScreenCloseTrack.ordinal()] = 13;
            } catch (NoSuchFieldError e7) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendShrinkFSClkTrack.ordinal()] = 5;
            } catch (NoSuchFieldError e8) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendShrinkFSThdClkTrack.ordinal()] = 6;
            } catch (NoSuchFieldError e9) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendThdClkTrack.ordinal()] = 2;
            } catch (NoSuchFieldError e10) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendVideoClkTrack.ordinal()] = 7;
            } catch (NoSuchFieldError e11) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendVideoCloseClkTrack.ordinal()] = 9;
            } catch (NoSuchFieldError e12) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendVideoCloseThdClkTrack.ordinal()] = 10;
            } catch (NoSuchFieldError e13) {
            }
            try {
                iArr[com.adchina.android.ads.f.ESendVideoThdClkTrack.ordinal()] = 8;
            } catch (NoSuchFieldError e14) {
            }
            i = iArr;
        }
        return iArr;
    }

    public final void a() {
        int i2 = 0;
        for (int i3 = 0; i3 < this.b.size(); i3++) {
            if (((AdView) this.b.get(i3)).getVisibility() == 0) {
                i2++;
            }
        }
        if (i2 <= 0) {
            this.g = true;
        }
    }

    public final void a(AdView adView) {
        if (adView == null) {
            return;
        }
        if (!this.b.contains(adView)) {
            this.b.add(adView);
        }
        adView.setController(this);
    }

    public final void a(AdView adView, MotionEvent motionEvent) {
        Rect rect;
        boolean z;
        int width;
        int round;
        int i2;
        int round2;
        float x = motionEvent.getX();
        float y = motionEvent.getY();
        try {
            if (this.mBtnType.length() <= 0) {
                onClickBackground();
                return;
            }
            float floatValue = Float.valueOf(this.mBtnX.toString()).floatValue() / 100.0f;
            float floatValue2 = Float.valueOf(this.mBtnY.toString()).floatValue() / 100.0f;
            float floatValue3 = Float.valueOf(this.mBtnW.toString()).floatValue() / 100.0f;
            float floatValue4 = Float.valueOf(this.mBtnH.toString()).floatValue() / 100.0f;
            if (adView.getWidth() == 0 || adView.getHeight() == 0 || this.d == 0 || this.e == 0) {
                rect = new Rect(0, 0, 0, 0);
            } else {
                if ((adView.getWidth() * 1.0d) / adView.getHeight() > (this.d * 1.0d) / this.e) {
                    round = adView.getHeight();
                    width = (int) Math.round(((round * 1.0d) / this.e) * this.d);
                    round2 = 0;
                    i2 = (int) Math.round((adView.getWidth() - width) / 2.0d);
                } else {
                    width = adView.getWidth();
                    round = (int) Math.round(((width * 1.0d) / this.d) * this.e);
                    i2 = 0;
                    round2 = (int) Math.round((adView.getHeight() - round) / 2.0d);
                }
                int round3 = i2 + Math.round(floatValue * width);
                int round4 = round2 + Math.round(round * floatValue2);
                rect = new Rect(round3, round4, Math.round(width * floatValue3) + round3, Math.round(round * floatValue4) + round4);
            }
            if (!rect.contains((int) x, (int) y)) {
                onClickBackground();
                return;
            }
            setClkTrackStatus(com.adchina.android.ads.f.ESendBtnClkTrack);
            if (this.mBtnType.toString().equalsIgnoreCase("down")) {
                this.logger.c(Utils.concatString("++ open ", this.mBtnDownloadUrl, " with browser"));
                AdEngine.getAdEngine().openBrowser(this.mBtnDownloadUrl.toString());
                this.logger.c("-- open browser");
                return;
            }
            if (!this.mBtnType.toString().equalsIgnoreCase("sms")) {
                if (this.mBtnType.toString().equalsIgnoreCase("call")) {
                    this.logger.c(Utils.concatString("++ make call to number ", this.mBtnCallNumber));
                    AdEngine.getAdEngine().makeCall(this.mBtnCallNumber.toString());
                    this.logger.c("-- make call");
                    return;
                }
                return;
            }
            try {
                z = mAdListener.OnRecvSms(adView, Utils.concatString("SMS:", this.mBtnSmsContent, " To:", this.mBtnSmsNumber));
            } catch (Exception e) {
                this.logger.c(e.toString());
                z = false;
            }
            if (z) {
                this.logger.c(Utils.concatString("++ send sms to number ", this.mBtnSmsNumber));
            }
            AdEngine.getAdEngine().sendSms(this.mBtnSmsNumber.toString(), this.mBtnSmsContent.toString());
            this.logger.c("-- send sms");
        } catch (Exception e2) {
            this.logger.c(Utils.concatString("Failed to AdView.onTouchEvent, err = ", e2.toString()));
        }
    }

    public final void a(String str) {
        this.mAdClickUrl.setLength(0);
        this.mAdClickUrl.append(str);
        this.mSmsType.setLength(0);
        this.mSmsType.append("2");
    }

    public final void b() {
        this.g = false;
    }

    public final void b(AdView adView) {
        if (adView == null) {
            return;
        }
        if (this.b.contains(adView)) {
            this.b.remove(adView);
        }
        if (this.b.size() == 0) {
            stop();
        }
    }

    @Override
    public final boolean handleMessage(Message message) {
        if (message != null) {
            switch (message.what) {
                case 1:
                    if (mAdListener != null) {
                        Iterator it = this.b.iterator();
                        while (it.hasNext()) {
                            AdView adView = (AdView) it.next();
                            if (this.mRefreshAd) {
                                try {
                                    mAdListener.onRefreshAd(adView);
                                } catch (Exception e) {
                                    this.logger.c(e.toString());
                                }
                            } else {
                                try {
                                    mAdListener.onReceiveAd(adView);
                                } catch (Exception e2) {
                                    this.logger.c(e2.toString());
                                }
                            }
                        }
                    }
                    LogUtil.addLog("开始展示广告 mAdModel->" + this.mAdModel);
                    this.logger.c(Utils.concatString("++ onDisplayAd, mAdModel = ", this.mAdModel));
                    this.mRefreshAd = true;
                    if (this.b != null && this.b.size() != 0) {
                        Iterator it2 = this.b.iterator();
                        while (it2.hasNext()) {
                            AdView adView2 = (AdView) it2.next();
                            try {
                                if (com.adchina.android.ads.l.EAdTXT == this.mAdModel) {
                                    adView2.setContent(this.mTxtLnkText.toString());
                                } else if (com.adchina.android.ads.l.EAdJPG == this.mAdModel || com.adchina.android.ads.l.EAdPNG == this.mAdModel) {
                                    adView2.setContent((Bitmap) message.obj);
                                } else if (com.adchina.android.ads.l.EAdGIF == this.mAdModel) {
                                    adView2.setContent((com.adchina.android.ads.o) message.obj);
                                } else if (com.adchina.android.ads.l.EAdHTML5 == this.mAdModel) {
                                    adView2.setContent_html5(this.mImgAddr.toString());
                                } else if (com.adchina.android.ads.l.EAdIHTML5 == this.mAdModel) {
                                    adView2.setContent_ihtml5(this.mImgAddr.toString());
                                }
                            } catch (Exception e3) {
                                Log.e("AdChinaError", Utils.concatString("Failed to DisplayAd, err = ", e3.toString()));
                                LogUtil.addLog("异常  onDisplayAd---------------->");
                            }
                        }
                        if (com.adchina.android.ads.l.EAdHTML5 != this.mAdModel && com.adchina.android.ads.l.EAdIHTML5 != this.mAdModel) {
                            this.mHasAd = true;
                            setRecvAdStatus(com.adchina.android.ads.g.ESendImpTrack);
                            this.logger.c("-- onDisplayAd");
                        }
                        LogUtil.addLog("结束展示图片 mAdModel->" + this.mAdModel);
                        break;
                    } else {
                        this.logger.c(Utils.concatString("Failed to DisplayAd, err = ", "no AdView is visible"));
                        this.mHasAd = false;
                        setRecvAdStatus(com.adchina.android.ads.g.ERefreshAd);
                        break;
                    }
                    break;
                case 2:
                    if (mAdListener != null) {
                        Iterator it3 = this.b.iterator();
                        while (it3.hasNext()) {
                            AdView adView3 = (AdView) it3.next();
                            if (this.mRefreshAd) {
                                try {
                                    mAdListener.onFailedToRefreshAd(adView3);
                                } catch (Exception e4) {
                                    this.logger.c(e4.toString());
                                }
                            } else {
                                try {
                                    mAdListener.onFailedToReceiveAd(adView3);
                                } catch (Exception e5) {
                                    this.logger.c(e5.toString());
                                }
                            }
                        }
                    }
                    this.mHasAd = false;
                    if (!AdManager.d) {
                        try {
                            AdManager.e = Integer.valueOf(this.mRefTime.toString()).intValue();
                        } catch (NumberFormatException e6) {
                            AdManager.e = AdManager.c;
                        }
                    }
                    break;
                case 3:
                    setRecvAdStatus(com.adchina.android.ads.g.ERefreshAd);
                    break;
            }
        }
        if (message != null) {
            this.mMsgHandler.removeMessages(message.what);
        }
        return true;
    }

    @Override
    public final void onClickBackground() {
        LogUtil.addLog("开始点击 onClick");
        this.logger.c("++ onClick");
        if (this.mSmsType.length() <= 0) {
            return;
        }
        this.logger.c(Utils.concatString("++ open ", this.mAdClickUrl, " with browser"));
        AdEngine.getAdEngine().openBrowser(this.mAdClickUrl.toString());
        this.logger.c("-- open browser");
        Utils.splitTrackUrl(this.mThdClkTrack.toString(), this.mThdClkTrackList);
        setClkTrackStatus(com.adchina.android.ads.f.ESendThdClkTrack);
        this.logger.c("-- onClick");
        LogUtil.addLog("结束点击 onClick");
    }

    @Override
    public final void onHtmlPageLoaded() {
        this.mHasAd = true;
        setRecvAdStatus(com.adchina.android.ads.g.ESendImpTrack);
        this.logger.c("-- onDisplayAd");
    }

    @Override
    public final void onSendActevt(String str) {
        LogUtil.addLog("开始发送消息 onSendActevt");
        com.adchina.android.ads.a.a(new b(this, str), null);
    }

    @Override
    public final void onTouchEvent(View view) {
        boolean z;
        if (this.mBtnType.toString().length() > 0) {
            setClkTrackStatus(com.adchina.android.ads.f.ESendBtnClkTrack);
            if (this.mBtnType.toString().equalsIgnoreCase("down")) {
                this.logger.c(Utils.concatString("++ open ", this.mBtnDownloadUrl, " with browser"));
                AdEngine.getAdEngine().openBrowser(this.mBtnDownloadUrl.toString());
                this.logger.c("-- open browser");
                return;
            }
            if (!this.mBtnType.toString().equalsIgnoreCase("sms")) {
                if (this.mBtnType.toString().equalsIgnoreCase("call")) {
                    this.logger.c(Utils.concatString("++ make call to number ", this.mBtnCallNumber));
                    AdEngine.getAdEngine().makeCall(this.mBtnCallNumber.toString());
                    this.logger.c("-- make call");
                    return;
                }
                return;
            }
            try {
                z = mAdListener.OnRecvSms((AdView) view, Utils.concatString("SMS:", this.mBtnSmsContent, " To:", this.mBtnSmsNumber));
            } catch (Exception e) {
                this.logger.c(e.toString());
                z = false;
            }
            if (z) {
                this.logger.c(Utils.concatString("++ send sms to number ", this.mBtnSmsNumber));
            }
            AdEngine.getAdEngine().sendSms(this.mBtnSmsNumber.toString(), this.mBtnSmsContent.toString());
            this.logger.c("-- send sms");
        }
    }

    @Override
    protected final String readFcParams() {
        return readFcParams("adchinaFC.fc");
    }

    @Override
    public final void runClkTrackJob(c cVar) {
        while (!this.mStop && !cVar.f78a) {
            switch (h()[this.mClickStatus.ordinal()]) {
                case 1:
                    this.logger.c("++ onSendClkTrack");
                    LogUtil.addLog("开始发送点击消息-->1");
                    setClkTrackStatus(com.adchina.android.ads.f.EIdle);
                    try {
                        String concatString = Utils.concatString(this.mReportBaseUrl, "1", ",0,0,0", setupMaParams());
                        com.adchina.android.ads.t tVar = this.mHttpEngine;
                        com.adchina.android.ads.t.a(concatString);
                        this.logger.c(Utils.concatString("send ClkTrack to ", concatString));
                    } catch (Exception e) {
                        String concatString2 = Utils.concatString("Exceptions in onSendClkTrack, err = ", e.toString());
                        this.logger.c(concatString2);
                        LogUtil.addLog("发送点击消息异常");
                        Log.e("AdChinaError", concatString2);
                    } finally {
                        setClkTrackStatus(com.adchina.android.ads.f.ESendThdClkTrack);
                        this.logger.c("-- onSendClkTrack");
                        LogUtil.addLog("结束发送点击消息");
                    }
                    try {
                        Thread.sleep(50L);
                    } catch (InterruptedException e2) {
                    }
                case 2:
                    setClkTrackStatus(com.adchina.android.ads.f.EIdle);
                    int size = this.mThdClkTrackList.size();
                    this.logger.c(Utils.concatString("++ onSendThdClkTrack, Size of list is ", Integer.valueOf(size)));
                    if (size > 0) {
                        try {
                            String str = (String) this.mThdClkTrackList.get(size - 1);
                            this.mThdClkTrackList.removeLast();
                            com.adchina.android.ads.t tVar2 = this.mHttpEngine;
                            com.adchina.android.ads.t.a(str);
                            this.logger.c(Utils.concatString("send ThdClkTrack to ", str));
                            LogUtil.addLog("开始发送第三方点击消息");
                        } catch (Exception e3) {
                            String concatString3 = Utils.concatString("Failed to onSendThdClkTrack, err = ", e3.toString());
                            this.logger.c(concatString3);
                            Log.e("AdChinaError", concatString3);
                        } finally {
                            setClkTrackStatus(com.adchina.android.ads.f.ESendThdClkTrack);
                            this.logger.c("-- onSendThdClkTrack");
                            LogUtil.addLog("结束发送第三方点击消息");
                        }
                    }
                    Thread.sleep(50L);
                case 3:
                    this.logger.c("++ onSendBtnClkTrack");
                    setClkTrackStatus(com.adchina.android.ads.f.EIdle);
                    try {
                        String concatString4 = Utils.concatString(this.mReportBaseUrl, "200", ",0,0,0", setupMaParams());
                        com.adchina.android.ads.t tVar3 = this.mHttpEngine;
                        com.adchina.android.ads.t.a(concatString4);
                        this.logger.c(Utils.concatString("send BtnClkTrack to ", concatString4));
                        LogUtil.addLog("开始发送ActionButton点击消息-->200");
                    } catch (Exception e4) {
                        String concatString5 = Utils.concatString("Exceptions in onSendBtnClkTrack, err = ", e4.toString());
                        this.logger.c(concatString5);
                        Log.e("AdChinaError", concatString5);
                    } finally {
                        Utils.splitTrackUrl(this.mBtnThdClkTrack.toString(), this.mBtnThdClkTrackList);
                        setClkTrackStatus(com.adchina.android.ads.f.ESendBtnThdClkTrack);
                        this.logger.c("-- onSendBtnClkTrack");
                        LogUtil.addLog("结束发送ActionButton点击消息");
                    }
                    Thread.sleep(50L);
                case 4:
                    setClkTrackStatus(com.adchina.android.ads.f.EIdle);
                    int size2 = this.mBtnThdClkTrackList.size();
                    this.logger.c(Utils.concatString("++ onSendBtnThdClkTrack, Size of list is ", Integer.valueOf(size2)));
                    if (size2 > 0) {
                        try {
                            String str2 = (String) this.mBtnThdClkTrackList.get(size2 - 1);
                            this.mBtnThdClkTrackList.removeLast();
                            com.adchina.android.ads.t tVar4 = this.mHttpEngine;
                            com.adchina.android.ads.t.a(str2);
                            this.logger.c(Utils.concatString("send btnthdclktrack to ", str2));
                            LogUtil.addLog("开始发送ActionButton第三方点击消息");
                        } catch (Exception e5) {
                            String concatString6 = Utils.concatString("Failed to onSendBtnThdClkTrack, err = ", e5.toString());
                            this.logger.c(concatString6);
                            Log.e("AdChinaError", concatString6);
                        } finally {
                            setClkTrackStatus(com.adchina.android.ads.f.ESendBtnThdClkTrack);
                            this.logger.c("-- onSendBtnThdClkTrack");
                            LogUtil.addLog("结束发送ActionButton第三方点击消息");
                        }
                    }
                    Thread.sleep(50L);
                default:
                    Thread.sleep(50L);
            }
        }
    }

    @Override
    public final void runRecvAdThreadJob(d dVar) {
        while (!this.mStop && !dVar.f79a) {
            switch (g()[this.mRunState.ordinal()]) {
                case 1:
                    LogUtil.addLog("Time: " + LogUtil.getNowTime());
                    LogUtil.addLog("开始 banner onReceiveAd");
                    if (this.f && !this.g) {
                        this.logger.c("++ onReceiveAd");
                        setRecvAdStatus(com.adchina.android.ads.g.EIdle);
                        InputStream inputStream = null;
                        try {
                            if (AdManager.getDebugMode()) {
                                String str = setupAdserverUrlFromConfig();
                                if (str != null) {
                                    LogUtil.addLog("请求地址-->" + com.adchina.android.ads.k.f);
                                    this.logger.c(Utils.concatString("AdserverUrl:", str));
                                    com.adchina.android.ads.t tVar = this.mHttpEngine;
                                    String str2 = com.adchina.android.ads.k.f;
                                    this.mAdspaceId.toString();
                                    inputStream = com.adchina.android.ads.t.a(str2, str);
                                }
                            } else {
                                LogUtil.addLog("请求地址-->http://amob.acs86.com/a.htm");
                                String str3 = setupAdserverUrl();
                                this.logger.c(Utils.concatString("AdserverUrl:", str3));
                                com.adchina.android.ads.t tVar2 = this.mHttpEngine;
                                this.mAdspaceId.toString();
                                inputStream = com.adchina.android.ads.t.a("http://amob.acs86.com/a.htm", str3);
                            }
                            readAdserverInfo(inputStream);
                            if (!AdManager.d) {
                                try {
                                    AdManager.e = Integer.valueOf(this.mRefTime.toString()).intValue();
                                } catch (NumberFormatException e) {
                                    AdManager.e = AdManager.c;
                                }
                            }
                            LogUtil.addLog("刷新时间为-->" + AdManager.e);
                            if (com.adchina.android.ads.l.EAdTXT != this.mAdModel) {
                                if (com.adchina.android.ads.l.EAdJPG != this.mAdModel && com.adchina.android.ads.l.EAdPNG != this.mAdModel && com.adchina.android.ads.l.EAdGIF != this.mAdModel) {
                                    if (com.adchina.android.ads.l.EAdHTML5 != this.mAdModel && com.adchina.android.ads.l.EAdIHTML5 != this.mAdModel) {
                                        throw new XmlPullParserException("Invalidate mAdModel,可能因为不在广告定向区域,所以Banner广告位上现在没有可供展示的广告");
                                        break;
                                    } else {
                                        sendMessage(1, this.mImgAddr.toString());
                                    }
                                } else {
                                    e();
                                    setRecvAdStatus(com.adchina.android.ads.g.EGetImgMaterial);
                                }
                            } else {
                                sendMessage(1, this.mTxtLnkText.toString());
                            }
                            Utils.splitTrackUrl(this.mThdClkTrack.toString(), this.mThdClkTrackList);
                            Utils.splitTrackUrl(this.mThdImpTrack.toString(), this.mThdImpTrackList);
                            Utils.splitTrackUrl(this.mBtnThdClkTrack.toString(), this.mBtnThdClkTrackList);
                        } catch (Exception e2) {
                            String concatString = Utils.concatString("Exceptions in onReceiveAd, err = ", e2.toString());
                            sendMessage(2, concatString);
                            this.logger.c(concatString);
                            Log.e("AdChinaError", concatString);
                            LogUtil.addLog("异常 onReceiveAd------------------>");
                        } finally {
                            com.adchina.android.ads.t tVar3 = this.mHttpEngine;
                            com.adchina.android.ads.t.a(inputStream);
                            this.logger.c("-- onReceiveAd");
                            LogUtil.addLog("结束 banner onReceiveAd");
                        }
                    }
                    try {
                        Thread.sleep(50L);
                    } catch (InterruptedException e3) {
                    }
                    break;
                case 2:
                default:
                    Thread.sleep(50L);
                case 3:
                    c();
                    Thread.sleep(50L);
                case 4:
                    this.logger.c("++ onSendImpTrack");
                    LogUtil.addLog("开始发送印象数给AdServer-->2");
                    try {
                        String concatString2 = Utils.concatString(this.mReportBaseUrl.toString(), "2", ",0,0,0", setupMaParams());
                        com.adchina.android.ads.t tVar4 = this.mHttpEngine;
                        com.adchina.android.ads.t.a(concatString2);
                        this.logger.c(Utils.concatString("send ImpTrack to ", concatString2));
                    } catch (Exception e4) {
                        String concatString3 = Utils.concatString("Exceptions in onSendImpTrack, err = ", e4.toString());
                        this.logger.c(concatString3);
                        Log.e("AdChinaError", concatString3);
                    } finally {
                        setRecvAdStatus(com.adchina.android.ads.g.ESendThdImpTrack);
                        this.logger.c("-- onSendImpTrack");
                        LogUtil.addLog("结束发送印象数给AdServer");
                    }
                    Thread.sleep(50L);
                case 5:
                    setRecvAdStatus(com.adchina.android.ads.g.EIdle);
                    int size = this.mThdImpTrackList.size();
                    this.logger.c(Utils.concatString("++ onSendThdImpTrack, Size of list is ", Integer.valueOf(size)));
                    if (size > 0) {
                        try {
                            String str4 = (String) this.mThdImpTrackList.get(size - 1);
                            this.mThdImpTrackList.removeLast();
                            com.adchina.android.ads.t tVar5 = this.mHttpEngine;
                            com.adchina.android.ads.t.a(str4);
                            this.logger.c(Utils.concatString("send ThdImpTrack to ", str4));
                            LogUtil.addLog("开始发送第三方印象数");
                        } catch (Exception e5) {
                            String concatString4 = Utils.concatString("Failed to onSendThdImpTrack, err = ", e5.toString());
                            this.logger.c(concatString4);
                            Log.e("AdChinaError", concatString4);
                            LogUtil.addLog("异常 发送第三方印象数");
                        } finally {
                            setRecvAdStatus(com.adchina.android.ads.g.ESendThdImpTrack);
                            LogUtil.addLog("结束发送第三方印象数");
                        }
                    } else if (AdManager.e != AdManager.f71a) {
                        sendMessage(3, "RefreshAd");
                    }
                    this.logger.c("-- onSendThdImpTrack");
                    Thread.sleep(50L);
                case 6:
                    this.logger.c("++ onRefreshAd");
                    LogUtil.addLog("开始准备刷新banner");
                    try {
                        try {
                            int i2 = AdManager.e;
                            try {
                                LogUtil.addLog("刷新等待 " + i2 + "秒");
                                if (i2 < AdManager.b) {
                                    i2 = AdManager.c;
                                }
                                Thread.sleep(i2 * 1000);
                                setRecvAdStatus(com.adchina.android.ads.g.EReceiveAd);
                                this.logger.c(Utils.concatString("-- onRefreshAd, delay = ", Integer.valueOf(i2)));
                                LogUtil.addLog("结束准备刷新banner");
                            } catch (Exception e6) {
                                setRecvAdStatus(com.adchina.android.ads.g.EReceiveAd);
                                this.logger.c(Utils.concatString("-- onRefreshAd, delay = ", Integer.valueOf(i2)));
                                LogUtil.addLog("结束准备刷新banner");
                            } catch (Throwable th) {
                                setRecvAdStatus(com.adchina.android.ads.g.EReceiveAd);
                                this.logger.c(Utils.concatString("-- onRefreshAd, delay = ", Integer.valueOf(i2)));
                                LogUtil.addLog("结束准备刷新banner");
                                throw th;
                            }
                        } catch (Throwable th2) {
                            try {
                                LogUtil.addLog("刷新等待 30秒");
                                r1 = 30 < AdManager.b ? AdManager.c : 30;
                                Thread.sleep(r1 * 1000);
                                setRecvAdStatus(com.adchina.android.ads.g.EReceiveAd);
                                this.logger.c(Utils.concatString("-- onRefreshAd, delay = ", Integer.valueOf(r1)));
                                LogUtil.addLog("结束准备刷新banner");
                            } catch (Exception e7) {
                                setRecvAdStatus(com.adchina.android.ads.g.EReceiveAd);
                                this.logger.c(Utils.concatString("-- onRefreshAd, delay = ", Integer.valueOf(r1)));
                                LogUtil.addLog("结束准备刷新banner");
                            } catch (Throwable th3) {
                                setRecvAdStatus(com.adchina.android.ads.g.EReceiveAd);
                                this.logger.c(Utils.concatString("-- onRefreshAd, delay = ", Integer.valueOf(r1)));
                                LogUtil.addLog("结束准备刷新banner");
                                throw th3;
                            }
                            throw th2;
                        }
                    } catch (Exception e8) {
                        int i3 = AdManager.c;
                        try {
                            LogUtil.addLog("刷新等待 " + i3 + "秒");
                            if (i3 < AdManager.b) {
                                i3 = AdManager.c;
                            }
                            Thread.sleep(i3 * 1000);
                            setRecvAdStatus(com.adchina.android.ads.g.EReceiveAd);
                            this.logger.c(Utils.concatString("-- onRefreshAd, delay = ", Integer.valueOf(i3)));
                            LogUtil.addLog("结束准备刷新banner");
                        } catch (Exception e9) {
                            setRecvAdStatus(com.adchina.android.ads.g.EReceiveAd);
                            this.logger.c(Utils.concatString("-- onRefreshAd, delay = ", Integer.valueOf(i3)));
                            LogUtil.addLog("结束准备刷新banner");
                        } catch (Throwable th4) {
                            setRecvAdStatus(com.adchina.android.ads.g.EReceiveAd);
                            this.logger.c(Utils.concatString("-- onRefreshAd, delay = ", Integer.valueOf(i3)));
                            LogUtil.addLog("结束准备刷新banner");
                            throw th4;
                        }
                    }
                    Thread.sleep(50L);
            }
        }
    }

    @Override
    protected final void setupAdspaceId() {
        this.mAdspaceId.setLength(0);
        this.mAdspaceId.append(AdManager.getAdspaceId());
    }

    @Override
    protected final void writeFcParams(String str) {
        writeFcParams(str, "adchinaFC.fc");
    }
}