Idle Tower v2.48版本的 MD5 值为:56f20496f6a85726b376356ed2ecee23

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


package com.yodo1.mas.mediation.yodo1.kit;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import androidx.work.Data;
import com.unity3d.services.ads.adunit.AdUnitActivity;
import com.yodo1.mas.Yodo1Mas;
import com.yodo1.mas.Yodo1MasLog;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class Yodo1RewardedInterVideoAds {
    private static final String TAG = "[Yodo1RewardedInterVideoAds]";
    private static boolean isDownloading = false;
    private static boolean isVideoLoaded = false;
    public static Yodo1VideoCallback yodo1VideoCallback;

    public static void setYodo1VideoCallback(Yodo1VideoCallback yodo1VideoCallback2) {
        yodo1VideoCallback = yodo1VideoCallback2;
    }

    public static void showVideoAds(Activity activity) {
        Intent intent = new Intent(activity, (Class<?>) Yodo1VPActivity.class);
        intent.putExtra(AdUnitActivity.EXTRA_ORIENTATION, activity.getResources().getConfiguration().orientation);
        intent.putExtra("adType", Yodo1Mas.AdType.RewardedInterstitial.getName());
        activity.startActivity(intent);
    }

    public static boolean isReady() {
        return isVideoLoaded;
    }

    public static void loadYodo1Video(Context context) {
        if (isVideoLoaded) {
            Yodo1MasLog.d(TAG, "Yodo1VideoAd  video has cached, drop this load request");
            Yodo1VideoCallback yodo1VideoCallback2 = yodo1VideoCallback;
            if (yodo1VideoCallback2 != null) {
                yodo1VideoCallback2.onVideoLoaded();
                return;
            }
            return;
        }
        if (isDownloading) {
            return;
        }
        isDownloading = true;
        loadVideoRes(context);
    }

    private static String getVideoUrl(Context context) {
        return "https://docs.yodo1.com/" + (context.getResources().getConfiguration().orientation == 1 ? "media/ad-test-resource/ad-video-portrait.mp4" : "media/ad-test-resource/ad-video-landscape.mp4");
    }

    private static void loadVideoRes(final Context context) {
        new OkHttpClient().newCall(new Request.Builder().url(getVideoUrl(context)).build()).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException iOException) {
                Yodo1MasLog.d(Yodo1RewardedInterVideoAds.TAG, "loadVideoRes onFailure error:" + iOException.getMessage());
                boolean unused = Yodo1RewardedInterVideoAds.isDownloading = false;
                if (Yodo1RewardedInterVideoAds.yodo1VideoCallback != null) {
                    Yodo1RewardedInterVideoAds.yodo1VideoCallback.onVideoLoadFailed();
                }
            }

            @Override
            public void onResponse(Call call, Response response) {
                File file = new File(context.getCacheDir().getAbsolutePath() + "/local_video.mp4");
                Yodo1RewardedInterVideoAds.writeFile(file, response);
                Yodo1MasLog.d(Yodo1RewardedInterVideoAds.TAG, "syncDownloadExecutor onFinish, filePath: " + file.getAbsolutePath() + ", download finish time: " + System.currentTimeMillis());
                boolean unused = Yodo1RewardedInterVideoAds.isVideoLoaded = true;
                if (Yodo1RewardedInterVideoAds.yodo1VideoCallback != null) {
                    Yodo1RewardedInterVideoAds.yodo1VideoCallback.onVideoLoaded();
                }
            }
        });
    }

    public static void writeFile(File file, Response response) {
        FileOutputStream fileOutputStream;
        if (response == null || response.body() == null) {
            return;
        }
        FileOutputStream fileOutputStream2 = null;
        InputStream byteStream = response.body().byteStream();
        try {
            try {
                try {
                    fileOutputStream = new FileOutputStream(file);
                } catch (IOException e) {
                    e = e;
                }
            } catch (Throwable th) {
                th = th;
            }
            try {
                byte[] bArr = new byte[Data.MAX_DATA_BYTES];
                while (true) {
                    int read = byteStream.read(bArr);
                    if (read == -1) {
                        break;
                    } else {
                        fileOutputStream.write(bArr, 0, read);
                    }
                }
                if (byteStream != null) {
                    byteStream.close();
                }
                fileOutputStream.close();
            } catch (IOException e2) {
                e = e2;
                fileOutputStream2 = fileOutputStream;
                e.printStackTrace();
                if (byteStream != null) {
                    byteStream.close();
                }
                if (fileOutputStream2 != null) {
                    fileOutputStream2.close();
                }
            } catch (Throwable th2) {
                th = th2;
                fileOutputStream2 = fileOutputStream;
                if (byteStream != null) {
                    try {
                        byteStream.close();
                    } catch (IOException e3) {
                        e3.printStackTrace();
                        throw th;
                    }
                }
                if (fileOutputStream2 != null) {
                    fileOutputStream2.close();
                }
                throw th;
            }
        } catch (IOException e4) {
            e4.printStackTrace();
        }
    }
}