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

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


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

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaMetadataRetriever;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.unity3d.services.ads.adunit.AdUnitActivity;
import com.yodo1.mas.Yodo1Mas;
import com.yodo1.mas.Yodo1MasLog;
import com.yodo1.mas.mediation.yodo1.Yodo1MasYodo1Adapter;
import com.yodo1.mas.utils.RR;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class Yodo1VPActivity extends Activity {
    private static final String TAG = "[Yodo1VPActivity]";
    private Bitmap bm;
    private Yodo1VideoCallback callback;
    private Yodo1CountDownView cdv;
    private SurfaceHolder holder;
    private ImageView img_bg;
    private ImageView imgclose;
    private MediaPlayer player;
    private RelativeLayout rel_down;
    private RelativeLayout rel_video;
    private SurfaceView surfaceView;
    int position = 0;
    private boolean videoPause = false;
    private String videoPath = "";

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        Intent intent = getIntent();
        int intExtra = intent.getIntExtra(AdUnitActivity.EXTRA_ORIENTATION, 1);
        if (intExtra == 1) {
            setRequestedOrientation(1);
        } else {
            setRequestedOrientation(0);
        }
        String stringExtra = intent.getStringExtra("adType");
        if (Yodo1Mas.AdType.Reward.getName().equals(stringExtra)) {
            this.callback = Yodo1VideoAds.yodo1VideoCallback;
        } else if (Yodo1Mas.AdType.RewardedInterstitial.getName().equals(stringExtra)) {
            this.callback = Yodo1RewardedInterVideoAds.yodo1VideoCallback;
        }
        getWindow().setFormat(-3);
        requestWindowFeature(1);
        getWindow().setFlags(1024, 1024);
        setContentView(RR.layout(this, "yodo1_vp_activity"));
        initView();
        this.videoPath = getCacheDir().getAbsolutePath() + "/local_video.mp4";
        loadLoaingPage(intExtra);
    }

    public void initView() {
        this.cdv = (Yodo1CountDownView) findViewById(RR.id(this, "yodo1_view_countdowm"));
        this.surfaceView = (SurfaceView) findViewById(RR.id(this, "yodo1_surfaceview_player"));
        this.rel_video = (RelativeLayout) findViewById(RR.id(this, "yodo1_rel_player"));
        this.rel_down = (RelativeLayout) findViewById(RR.id(this, "yodo1_rel_closepage"));
        this.img_bg = (ImageView) findViewById(RR.id(this, "yodo1_iv_bgimage"));
        this.imgclose = (ImageView) findViewById(RR.id(this, "yodo1_iv_close"));
        this.player = new MediaPlayer();
        this.img_bg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent("android.intent.action.VIEW");
                intent.setData(Uri.parse(Yodo1MasYodo1Adapter.YODO1_WEB_URL));
                Yodo1VPActivity.this.startActivity(intent);
                Yodo1VPActivity.this.callback.onVideoClicked();
            }
        });
        this.imgclose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Yodo1VPActivity.this.callback.onVideoClosed();
                Yodo1VPActivity.this.finish();
            }
        });
        this.surfaceView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Yodo1VPActivity.this.callback.onVideoClicked();
            }
        });
    }

    public void loadVideoView() {
        try {
            this.surfaceView.getHolder().addCallback(new MyCallBack());
            this.player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer mediaPlayer) {
                    Yodo1VPActivity.this.player.start();
                    Yodo1MasLog.d(Yodo1VPActivity.TAG, "Yodo1VP  playing success : ");
                    Yodo1VPActivity.this.callback.onVideoShow();
                }
            });
            this.player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                @Override
                public void onCompletion(MediaPlayer mediaPlayer) {
                    Yodo1MasLog.d(Yodo1VPActivity.TAG, "Yodo1VP  palying complete : ");
                    Yodo1VPActivity.this.callback.onVideoReward();
                    Yodo1VPActivity.this.rel_video.setVisibility(8);
                    Yodo1VPActivity.this.rel_down.setVisibility(0);
                    if (Yodo1VPActivity.this.bm != null) {
                        Yodo1VPActivity.this.img_bg.setImageBitmap(Yodo1VPActivity.this.bm);
                    } else if (Yodo1VPActivity.this.getResources().getConfiguration().orientation == 1) {
                        Yodo1VPActivity.this.img_bg.setImageResource(RR.drawable(Yodo1VPActivity.this, "yodo1splash_portrait"));
                    } else {
                        Yodo1VPActivity.this.img_bg.setImageResource(RR.drawable(Yodo1VPActivity.this, "yodo1splash_landscape"));
                    }
                }
            });
            MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
            mediaMetadataRetriever.setDataSource(this.videoPath);
            String extractMetadata = mediaMetadataRetriever.extractMetadata(9);
            int round = (int) Math.round(Double.valueOf(extractMetadata).doubleValue() / 1000.0d);
            setCdvCountDown(round);
            Yodo1MasLog.d(TAG, "Yodo1VP  cur video duration : " + extractMetadata);
            Yodo1MasLog.d(TAG, "Yodo1VP  cur video time : " + round);
        } catch (Exception unused) {
        }
    }

    private void setCdvCountDown(int i) {
        this.cdv.setCountdownTime(i);
        this.cdv.startCountDown();
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (this.videoPause) {
            this.videoPause = false;
            this.rel_video.setVisibility(0);
            this.rel_down.setVisibility(8);
        }
        loadVideoView();
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (this.rel_video.getVisibility() == 0) {
            this.videoPause = true;
        }
        MediaPlayer mediaPlayer = this.player;
        if (mediaPlayer == null || !mediaPlayer.isPlaying()) {
            return;
        }
        try {
            this.player.pause();
            this.videoPause = true;
        } catch (Exception unused) {
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        try {
            if (this.player != null) {
                if (this.player.isPlaying()) {
                    this.player.stop();
                }
                this.player.release();
                this.player.reset();
                this.player = null;
            }
        } catch (IllegalStateException unused) {
        }
    }

    @Override
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i == 4) {
            return false;
        }
        return super.onKeyDown(i, keyEvent);
    }

    public void loadLoaingPage(int i) {
        new OkHttpClient().newCall(new Request.Builder().url(i == 2 ? "https://docs.yodo1.com/media/ad-test-resource/ad-video-landing-page-landscape.png" : "https://docs.yodo1.com/media/ad-test-resource/ad-video-landing-page-portrait.png").build()).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException iOException) {
            }

            @Override
            public void onResponse(Call call, Response response) {
                Yodo1VPActivity.this.bm = BitmapFactory.decodeStream(response.body() != null ? response.body().byteStream() : null);
            }
        });
    }

    public class MyCallBack implements SurfaceHolder.Callback {
        @Override
        public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
        }

        private MyCallBack() {
        }

        @Override
        public void surfaceCreated(SurfaceHolder surfaceHolder) {
            Yodo1VPActivity.this.player.setDisplay(surfaceHolder);
            if (Yodo1VPActivity.this.player.isPlaying()) {
                return;
            }
            try {
                Yodo1VPActivity.this.player.reset();
                Yodo1VPActivity.this.player.setDataSource(Yodo1VPActivity.this.videoPath);
                Yodo1VPActivity.this.player.prepare();
                Yodo1VPActivity.this.player.seekTo(Yodo1VPActivity.this.position);
                Yodo1MasLog.d(Yodo1VPActivity.TAG, "Yodo1VP  start playing : " + Yodo1VPActivity.this.position);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
            if (Yodo1VPActivity.this.player.isPlaying()) {
                Yodo1VPActivity yodo1VPActivity = Yodo1VPActivity.this;
                yodo1VPActivity.position = yodo1VPActivity.player.getCurrentPosition();
                Yodo1VPActivity.this.player.stop();
                Yodo1MasLog.d(Yodo1VPActivity.TAG, "Yodo1VP  cur playing duration : " + Yodo1VPActivity.this.position);
            }
        }
    }
}