翰林优商.apk(点击下载) / CustomViewMessageWrap.java


package com.mbridge.msdk.widget.custom;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import com.mbridge.msdk.foundation.entity.CampaignEx;
import com.mbridge.msdk.foundation.same.b.c;
import com.mbridge.msdk.foundation.same.b.e;
import com.mbridge.msdk.foundation.tools.w;
import com.mbridge.msdk.out.ApkDisplayInfo;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ogg.DefaultOggSeeker;
import com.mbridge.msdk.system.NoProGuard;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class CustomViewMessageWrap implements NoProGuard {
    private ApkDisplayInfo apkDisplayInfo;
    private CampaignEx campaignEx;
    private String layoutFilePath;
    private Map<String, View> views;

    public boolean checkIsNull(Object obj) {
        return obj == null;
    }

    public CustomViewMessageWrap() {
    }

    public CustomViewMessageWrap(CampaignEx campaignEx2, String str) {
        ApkDisplayInfo apkDisplayInfo2;
        this.campaignEx = campaignEx2;
        if (campaignEx2 == null) {
            apkDisplayInfo2 = null;
        } else {
            apkDisplayInfo2 = campaignEx2.getApkDisplayInfo();
        }
        this.apkDisplayInfo = apkDisplayInfo2;
        this.layoutFilePath = str;
    }

    public CampaignEx getCampaignEx() {
        return this.campaignEx;
    }

    public View getView(String str) {
        Map<String, View> map = this.views;
        if (map != null) {
            return map.get(str);
        }
        return null;
    }

    public void putView(String str, View view) {
        if (this.views == null) {
            this.views = new HashMap();
        }
        this.views.put(str, view);
    }

    public String getApplicationName() {
        return checkIsNull(this.apkDisplayInfo) ? "" : this.apkDisplayInfo.getAppName();
    }

    public String getApplicationNameFromCampaign() {
        return checkIsNull(this.campaignEx) ? "" : this.campaignEx.getAppName();
    }

    public String getApplicationContext() {
        return checkIsNull(this.campaignEx) ? "" : this.campaignEx.getAppDesc();
    }

    public String getApplicationPrivacy() {
        return checkIsNull(this.apkDisplayInfo) ? "" : this.apkDisplayInfo.getPriUrl();
    }

    public String getApplicationUpdateTime() {
        return checkIsNull(this.apkDisplayInfo) ? "" : this.apkDisplayInfo.getUpdateTime();
    }

    public String getApplicationPermissions() {
        if (checkIsNull(this.apkDisplayInfo)) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        ArrayList<String> permDescAllList = this.apkDisplayInfo.getPermDescAllList();
        if (permDescAllList != null && permDescAllList.size() > 0) {
            for (int i = 0; i < permDescAllList.size(); i++) {
                String str = permDescAllList.get(i);
                if (!TextUtils.isEmpty(str)) {
                    sb.append(str);
                    if (i < permDescAllList.size() - 1) {
                        sb.append("\n");
                    }
                }
            }
        }
        return sb.toString();
    }

    public String getApplicationDeveloper() {
        return checkIsNull(this.apkDisplayInfo) ? "" : this.apkDisplayInfo.getDevName();
    }

    public String getApplicationVersion() {
        return checkIsNull(this.apkDisplayInfo) ? "" : this.apkDisplayInfo.getAppVersion();
    }

    public String getApplicationScore() {
        if (checkIsNull(this.campaignEx)) {
            return String.format("已有 %s 人评分", String.valueOf(new Random().nextInt(10000) + DefaultOggSeeker.MATCH_BYTE_RANGE));
        }
        return String.format("已有 %s 人评分", String.valueOf(this.campaignEx.getNumberRating()));
    }

    public String getApplicationLogo() {
        return checkIsNull(this.campaignEx) ? "" : this.campaignEx.getIconUrl();
    }

    public String getApplicationImage() {
        return checkIsNull(this.campaignEx) ? "" : this.campaignEx.getImageUrl();
    }

    public int getStarCount() {
        if (checkIsNull(this.campaignEx)) {
            return 5;
        }
        return (int) Math.ceil(this.campaignEx.getRating());
    }

    public String getLayoutFilePath() {
        return this.layoutFilePath;
    }

    public static final String getMessage(CustomViewMessageWrap customViewMessageWrap, String str) {
        if (TextUtils.isEmpty(str) && customViewMessageWrap == null) {
            return null;
        }
        try {
            Method method = customViewMessageWrap.getClass().getMethod(str, new Class[0]);
            method.setAccessible(true);
            Object invoke = method.invoke(customViewMessageWrap, new Object[0]);
            if (invoke != null) {
                return String.valueOf(invoke);
            }
            return "";
        } catch (NoSuchMethodException e) {
            w.d("CustomViewMessageWrap", e.getMessage());
            return "";
        } catch (InvocationTargetException e2) {
            w.d("CustomViewMessageWrap", e2.getMessage());
            return "";
        } catch (IllegalAccessException e3) {
            w.d("CustomViewMessageWrap", e3.getMessage());
            return "";
        }
    }

    public static final String getViewFilePath(String str) {
        if (!TextUtils.equals(str, "mbridge_download_dialog_view")) {
            return "";
        }
        return e.b(c.MBRIDGE_OTHER) + "/" + str + ".xml";
    }

    public static final void copyViewFile(Context context, String str) {
        copyAssetsDir2Phone(context, str);
    }

    /* JADX WARNING: Removed duplicated region for block: B:45:0x00dd A[SYNTHETIC, Splitter:B:45:0x00dd] */
    /* JADX WARNING: Removed duplicated region for block: B:49:0x00e7  */
    /* JADX WARNING: Removed duplicated region for block: B:53:0x00ee A[SYNTHETIC, Splitter:B:53:0x00ee] */
    /* JADX WARNING: Removed duplicated region for block: B:57:0x00f8 A[SYNTHETIC, Splitter:B:57:0x00f8] */
    /* JADX WARNING: Removed duplicated region for block: B:66:? A[RETURN, SYNTHETIC] */
    private static void copyAssetsDir2Phone(Context context, String str) {
        InputStream inputStream;
        Throwable th;
        IOException e;
        InputStream inputStream2;
        FileOutputStream fileOutputStream = null;
        try {
            String[] list = context.getAssets().list(str);
            if (list.length > 0) {
                new File(e.b(c.MBRIDGE_OTHER) + File.separator + str).mkdirs();
                for (String str2 : list) {
                    String str3 = str + File.separator + str2;
                    copyAssetsDir2Phone(context, str3);
                    str = str3.substring(0, str3.lastIndexOf(File.separator));
                }
                inputStream2 = null;
            } else {
                inputStream2 = context.getAssets().open(str);
                try {
                    File file = new File(e.b(c.MBRIDGE_OTHER) + File.separator + str);
                    if (!file.exists() || file.length() == 0) {
                        FileOutputStream fileOutputStream2 = new FileOutputStream(file);
                        try {
                            byte[] bArr = new byte[1024];
                            while (true) {
                                int read = inputStream2.read(bArr);
                                if (read == -1) {
                                    break;
                                }
                                fileOutputStream2.write(bArr, 0, read);
                            }
                            fileOutputStream = fileOutputStream2;
                        } catch (IOException e2) {
                            inputStream = inputStream2;
                            e = e2;
                            fileOutputStream = fileOutputStream2;
                            try {
                                w.d("wrap", e.getMessage());
                                if (fileOutputStream != null) {
                                    try {
                                        fileOutputStream.flush();
                                        fileOutputStream.close();
                                    } catch (IOException unused) {
                                    }
                                }
                                if (inputStream != null) {
                                    inputStream.close();
                                    return;
                                }
                                return;
                            } catch (Throwable th2) {
                                th = th2;
                                if (fileOutputStream != null) {
                                    try {
                                        fileOutputStream.flush();
                                        fileOutputStream.close();
                                    } catch (IOException unused2) {
                                    }
                                }
                                if (inputStream != null) {
                                    try {
                                        inputStream.close();
                                    } catch (IOException unused3) {
                                    }
                                }
                                throw th;
                            }
                        } catch (Throwable th3) {
                            inputStream = inputStream2;
                            th = th3;
                            fileOutputStream = fileOutputStream2;
                            if (fileOutputStream != null) {
                            }
                            if (inputStream != null) {
                            }
                            throw th;
                        }
                    }
                } catch (IOException e3) {
                    inputStream = inputStream2;
                    e = e3;
                    w.d("wrap", e.getMessage());
                    if (fileOutputStream != null) {
                    }
                    if (inputStream != null) {
                    }
                } catch (Throwable th4) {
                    inputStream = inputStream2;
                    th = th4;
                    if (fileOutputStream != null) {
                    }
                    if (inputStream != null) {
                    }
                    throw th;
                }
            }
            if (fileOutputStream != null) {
                try {
                    fileOutputStream.flush();
                    fileOutputStream.close();
                } catch (IOException unused4) {
                }
            }
            if (inputStream2 != null) {
                try {
                    inputStream2.close();
                } catch (IOException unused5) {
                }
            }
        } catch (IOException e4) {
            e = e4;
            inputStream = null;
            w.d("wrap", e.getMessage());
            if (fileOutputStream != null) {
            }
            if (inputStream != null) {
            }
        } catch (Throwable th5) {
            th = th5;
            inputStream = null;
            if (fileOutputStream != null) {
            }
            if (inputStream != null) {
            }
            throw th;
        }
    }
}