导航菜单

页面标题

页面副标题

Mint v5.7.3 - OnBoardPlayVideoActivity.java 源代码

正在查看: Mint v5.7.3 应用的 OnBoardPlayVideoActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.htmedia.mint.ui.activity.onboardjourney;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.upstream.DefaultDataSource;
import com.htmedia.mint.htsubscription.SubscriptionTrigger;
import com.htmedia.mint.htsubscription.WebEngageAnalytices;
import com.htmedia.mint.pojo.config.Config;
import com.htmedia.mint.ui.activity.HomeActivity;
import com.htmedia.mint.utils.o1;
import com.htmedia.mint.utils.q;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class OnBoardPlayVideoActivity extends AppCompatActivity implements View.OnClickListener {
    private PlayerView c;
    private ImageView d;
    private ProgressiveMediaSource e;
    private ArrayList<Integer> f;
    private ImageButton g;
    private ImageButton h;
    private Config i;
    private Handler q;
    private Runnable r;
    private final String a = "OnBoardPlayVideoActivity";
    private ExoPlayer b = null;
    private final long j = 0;
    private int o = 0;
    private int p = 0;

    class a implements View.OnClickListener {
        a() {
        }

        @Override
        public void onClick(View view) {
            OnBoardPlayVideoActivity onBoardPlayVideoActivity = OnBoardPlayVideoActivity.this;
            onBoardPlayVideoActivity.X(onBoardPlayVideoActivity.b == null || OnBoardPlayVideoActivity.this.b.getVolume() != 0.0f);
        }
    }

    class b implements Player.Listener {
        b() {
        }

        public void onIsPlayingChanged(boolean z) {
            super.onIsPlayingChanged(z);
        }

        public void onPlayerError(PlaybackException playbackException) {
            OnBoardPlayVideoActivity.this.a0();
            OnBoardPlayVideoActivity.this.stopTimer();
            OnBoardPlayVideoActivity.this.Y();
        }

        public void onPlayerStateChanged(boolean z, int i) {
            o1.a("OnBoardPlayVideoActivity", "**ExoPlayer.onPlayerStateChanged**");
            if (i == 1) {
                o1.a("OnBoardPlayVideoActivity", "**ExoPlayer.STATE_IDLE**");
                return;
            }
            if (i == 2) {
                o1.a("OnBoardPlayVideoActivity", "**ExoPlayer.STATE_BUFFERING**");
                return;
            }
            if (i == 3) {
                o1.a("OnBoardPlayVideoActivity", "**ExoPlayer.STATE_READY**");
                if (z) {
                    OnBoardPlayVideoActivity.this.setUpAutoScroll();
                    return;
                }
                return;
            }
            if (i != 4) {
                return;
            }
            o1.a("OnBoardPlayVideoActivity", "**ExoPlayer.STATE_ENDED**");
            OnBoardPlayVideoActivity.this.a0();
            OnBoardPlayVideoActivity.this.stopTimer();
            OnBoardPlayVideoActivity.this.Y();
        }

        public void onTimelineChanged(Timeline timeline, int i) {
            super.onTimelineChanged(timeline, i);
        }
    }

    class c implements Runnable {
        c() {
        }

        @Override
        public void run() {
            o1.a("OnBoardPlayVideoActivity", "**TOP RUNABLE SEEK POSITION**" + OnBoardPlayVideoActivity.this.p);
            o1.a("OnBoardPlayVideoActivity", "**TOP RUNABLE CURRENT POSITION**" + OnBoardPlayVideoActivity.this.o);
            if (OnBoardPlayVideoActivity.this.b != null && OnBoardPlayVideoActivity.this.f != null && OnBoardPlayVideoActivity.this.p < OnBoardPlayVideoActivity.this.f.size() && OnBoardPlayVideoActivity.this.p >= 0) {
                OnBoardPlayVideoActivity onBoardPlayVideoActivity = OnBoardPlayVideoActivity.this;
                onBoardPlayVideoActivity.o = (int) onBoardPlayVideoActivity.b.getCurrentPosition();
                OnBoardPlayVideoActivity onBoardPlayVideoActivity2 = OnBoardPlayVideoActivity.this;
                onBoardPlayVideoActivity2.V(onBoardPlayVideoActivity2.g, OnBoardPlayVideoActivity.this.f.size() >= 2 && OnBoardPlayVideoActivity.this.o > ((Integer) OnBoardPlayVideoActivity.this.f.get(1)).intValue());
                OnBoardPlayVideoActivity onBoardPlayVideoActivity3 = OnBoardPlayVideoActivity.this;
                onBoardPlayVideoActivity3.V(onBoardPlayVideoActivity3.h, OnBoardPlayVideoActivity.this.o <= ((Integer) OnBoardPlayVideoActivity.this.f.get(OnBoardPlayVideoActivity.this.f.size() - 1)).intValue());
                o1.a("OnBoardPlayVideoActivity", "**SEEKPOSITION RUNABLE SEEK POSITION**" + OnBoardPlayVideoActivity.this.o);
                StringBuilder sb2 = new StringBuilder();
                sb2.append("**SEEKPOSITION RUNABLE SEEK POSITION**");
                sb2.append(OnBoardPlayVideoActivity.this.p < OnBoardPlayVideoActivity.this.f.size() - 1 ? ((Integer) OnBoardPlayVideoActivity.this.f.get(OnBoardPlayVideoActivity.this.p + 1)).intValue() : OnBoardPlayVideoActivity.this.p);
                o1.a("OnBoardPlayVideoActivity", sb2.toString());
                if (OnBoardPlayVideoActivity.this.p < OnBoardPlayVideoActivity.this.f.size() - 1 && OnBoardPlayVideoActivity.this.o > ((Integer) OnBoardPlayVideoActivity.this.f.get(OnBoardPlayVideoActivity.this.p + 1)).intValue()) {
                    OnBoardPlayVideoActivity.O(OnBoardPlayVideoActivity.this);
                    o1.a("OnBoardPlayVideoActivity", "**BOttom RUNABLE SEEK POSITION**" + OnBoardPlayVideoActivity.this.p);
                }
                OnBoardPlayVideoActivity.this.stopTimer();
            }
            o1.a("OnBoardPlayVideoActivity", "**BOttom RUNABLE SEEK POSITION**" + OnBoardPlayVideoActivity.this.p);
            o1.a("OnBoardPlayVideoActivity", "**BOttom RUNABLE CURRENT POSITION**" + OnBoardPlayVideoActivity.this.o);
            OnBoardPlayVideoActivity.this.initHandler();
        }
    }

    static int O(OnBoardPlayVideoActivity onBoardPlayVideoActivity) {
        int i = onBoardPlayVideoActivity.p;
        onBoardPlayVideoActivity.p = i + 1;
        return i;
    }

    public void V(ImageButton imageButton, boolean z) {
        if (z) {
            imageButton.setColorFilter(ContextCompat.getColor(this, 2131101002), PorterDuff.Mode.MULTIPLY);
        } else {
            imageButton.setColorFilter(ContextCompat.getColor(this, 2131100371), PorterDuff.Mode.MULTIPLY);
        }
    }

    private void W(String str) {
        WebEngageAnalytices.onBoardScreenClick("Onboarding Video Screen Clicks", "Play");
        this.b = new ExoPlayer.Builder(this).build();
        ProgressiveMediaSource createMediaSource = new ProgressiveMediaSource.Factory(new DefaultDataSource.Factory(this)).createMediaSource(new MediaItem.Builder().setUri(str).setMimeType("application/mp4").build());
        this.e = createMediaSource;
        this.b.setMediaSource(createMediaSource);
        this.b.setPlayWhenReady(true);
        this.b.seekTo(0, 0L);
        this.b.prepare();
        this.c.setPlayer(this.b);
        this.b.addListener(new b());
        if (this.p == 0) {
            V(this.g, false);
        }
    }

    public void Y() {
        Config config = this.i;
        List<String> arrayList = (config == null || config.getNewOnBoarding() == null || this.i.getNewOnBoarding().getAndroidPosition() == null) ? new ArrayList<>() : this.i.getNewOnBoarding().getAndroidPosition();
        if (arrayList == null || arrayList.isEmpty()) {
            SubscriptionTrigger.openCardsActivity(this);
            return;
        }
        if (SubscriptionTrigger.ONBOARD_JOURNEY_TYPE.CONTENT == SubscriptionTrigger.mType) {
            SubscriptionTrigger.openCardsActivity(this);
            SubscriptionTrigger.mType = SubscriptionTrigger.ONBOARD_JOURNEY_TYPE.NONE;
        } else if (SubscriptionTrigger.ONBOARD_JOURNEY_TYPE.VIDEO != SubscriptionTrigger.mType) {
            goBack();
        } else {
            SubscriptionTrigger.openVideoActivity(this);
            SubscriptionTrigger.mType = SubscriptionTrigger.ONBOARD_JOURNEY_TYPE.NONE;
        }
    }

    private void Z(String str) {
        boolean z = true;
        String substring = str.substring(str.lastIndexOf("/") + 1);
        File file = null;
        if (getExternalFilesDir(null) != null && getExternalFilesDir(null).getPath() != null) {
            file = new File(getExternalFilesDir(null).getPath() + "/onBoardingVideo/" + substring);
        }
        if (file == null || !file.exists()) {
            Config config = this.i;
            if (config == null || config.getNewOnBoarding() == null || this.i.getNewOnBoarding().getVideo() == null || TextUtils.isEmpty(this.i.getNewOnBoarding().getVideo().getUrl())) {
                Y();
            } else {
                W(this.i.getNewOnBoarding().getVideo().getUrl());
            }
        } else {
            W(file.getPath());
        }
        if (this.i.getNewOnBoarding() != null && this.i.getNewOnBoarding().isMuteInitialStateSpeaker()) {
            z = false;
        }
        X(z);
    }

    private void b0(ArrayList<Integer> arrayList) {
        for (int i = 0; i < arrayList.size(); i++) {
            this.f.set(i, Integer.valueOf(arrayList.get(i).intValue() * 1000));
        }
    }

    private void goBack() {
        if (getIntent().getExtras() != null && getIntent().getExtras().containsKey("isNotification") && getIntent().getExtras().getInt("isNotification") > q.m.SPLASH.ordinal()) {
            startActivity(new Intent((Context) this, (Class<?>) HomeActivity.class));
        }
        a0();
        setResult(-1);
        finish();
    }

    public void initHandler() {
        if (this.q == null) {
            this.q = new Handler();
        }
        this.q.postDelayed(this.r, 1000L);
    }

    public void setUpAutoScroll() {
        this.r = new c();
        initHandler();
    }

    private void setupDarkMode() {
        getWindow().setStatusBarColor(-16777216);
        getWindow().getDecorView().setSystemUiVisibility(0);
    }

    public void stopTimer() {
        Handler handler = this.q;
        if (handler != null) {
            handler.removeCallbacks(this.r);
        }
    }

    void X(boolean z) {
        ExoPlayer exoPlayer = this.b;
        if (exoPlayer != null) {
            if (z) {
                exoPlayer.setVolume(0.0f);
                this.d.setImageResource(2131232292);
                WebEngageAnalytices.onBoardScreenClick("Onboarding Video Screen Clicks", "Unmute");
            } else {
                exoPlayer.setVolume(1.0f);
                this.d.setImageResource(2131232291);
                WebEngageAnalytices.onBoardScreenClick("Onboarding Video Screen Clicks", "Mute");
            }
        }
    }

    public void a0() {
        ExoPlayer exoPlayer = this.b;
        if (exoPlayer != null) {
            exoPlayer.release();
            this.b = null;
            this.e = null;
        }
    }

    protected void onActivityResult(int i, int i2, @Nullable Intent intent) {
        super/*androidx.fragment.app.FragmentActivity*/.onActivityResult(i, i2, intent);
        if (i == 1004 && i2 == -1) {
            goBack();
        }
    }

    public void onBackPressed() {
        goBack();
    }

    @Override
    public void onClick(View view) {
        int i;
        int i2;
        if (this.b != null) {
            int id2 = view.getId();
            if (id2 == 2131428387) {
                WebEngageAnalytices.onBoardScreenClick("Onboarding Video Screen Clicks", "Forward");
                o1.a("OnBoardPlayVideoActivity", "**TOP FORWARD SEEK POSITION**" + this.p);
                ArrayList<Integer> arrayList = this.f;
                if (arrayList != null && (i = this.p) >= 0 && i < arrayList.size() - 1) {
                    this.p = this.p + 1;
                    this.b.seekTo(this.f.get(r8).intValue());
                    V(this.h, this.p != this.f.size() - 1);
                }
                V(this.g, true);
                o1.a("OnBoardPlayVideoActivity", "**BOTTOM FORWARD SEEK POSITION**" + this.p);
                return;
            }
            if (id2 != 2131428407) {
                return;
            }
            WebEngageAnalytices.onBoardScreenClick("Onboarding Video Screen Clicks", "Backward");
            o1.a("OnBoardPlayVideoActivity", "**TOP REWIND SEEK POSITION**" + this.p);
            ArrayList<Integer> arrayList2 = this.f;
            if (arrayList2 != null && (i2 = this.p) >= 1 && i2 < arrayList2.size()) {
                this.p = this.p - 1;
                this.b.seekTo(this.f.get(r8).intValue());
                V(this.g, this.p != 0);
            }
            V(this.h, true);
            o1.a("OnBoardPlayVideoActivity", "**BOTTOM REWIND SEEK POSITION**" + this.p);
        }
    }

    @SuppressLint({"MissingInflatedId"})
    protected void onCreate(@Nullable Bundle bundle) {
        super/*androidx.fragment.app.FragmentActivity*/.onCreate(bundle);
        setContentView(2131624012);
        setupDarkMode();
        this.p = 0;
        this.o = 0;
        Config g = getApplication().g();
        this.i = g;
        if (g.getNewOnBoarding() != null && this.i.getNewOnBoarding().getVideo() != null && this.i.getNewOnBoarding().getVideo().getSeektimes() != null && this.i.getNewOnBoarding().getVideo().getSeektimes().size() > 0) {
            ArrayList<Integer> arrayList = (ArrayList) ((ArrayList) this.i.getNewOnBoarding().getVideo().getSeektimes()).clone();
            this.f = arrayList;
            b0(arrayList);
        }
        this.c = findViewById(2131430132);
        ImageButton imageButton = (ImageButton) findViewById(2131428407);
        this.g = imageButton;
        imageButton.setOnClickListener(this);
        ImageButton imageButton2 = (ImageButton) findViewById(2131428387);
        this.h = imageButton2;
        imageButton2.setOnClickListener(this);
        this.d = (ImageView) findViewById(2131432082);
        if (this.i.getNewOnBoarding() == null || !this.i.getNewOnBoarding().isShouldShowSpeaker()) {
            this.d.setVisibility(8);
        } else {
            this.d.setVisibility(0);
        }
        this.d.setImageResource(2131232291);
        this.d.setOnClickListener(new a());
        if (this.i.getNewOnBoarding() == null || this.i.getNewOnBoarding().getVideo() == null || TextUtils.isEmpty(this.i.getNewOnBoarding().getVideo().getUrl())) {
            Z("https://images.livemint.com/apps/images/newonboardingvideo.mp4");
        } else {
            Z(this.i.getNewOnBoarding().getVideo().getUrl());
        }
        WebEngageAnalytices.onBoardScreenView("Onboarding Video Screen View");
    }

    protected void onDestroy() {
        a0();
        stopTimer();
        if (this.r != null) {
            this.r = null;
        }
        this.q = null;
        super.onDestroy();
    }

    protected void onPause() {
        super/*androidx.fragment.app.FragmentActivity*/.onPause();
        ExoPlayer exoPlayer = this.b;
        if (exoPlayer == null || !exoPlayer.isPlaying()) {
            return;
        }
        WebEngageAnalytices.onBoardScreenClick("Onboarding Video Screen Clicks", "Pause");
        this.b.pause();
    }

    protected void onResume() {
        super/*androidx.fragment.app.FragmentActivity*/.onResume();
        ExoPlayer exoPlayer = this.b;
        if (exoPlayer != null) {
            exoPlayer.play();
        }
    }
}