CAG v5.7.4版本的 MD5 值为:bc57ead76a7a30559f0708e9d60d749f

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


package com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewParent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import androidx.collection.ArrayMap;
import androidx.lifecycle.Lifecycle;
import com.google.android.gms.common.GoogleApiAvailabilityLight;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.pierfrancescosoffritti.androidyoutubeplayer.R$raw;
import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.PlayerConstants$PlayerState;
import e.q.i;
import e.q.j;
import e.q.n;
import i.p.a.a.a.b;
import i.p.a.a.a.d.a;
import i.p.a.a.a.e.d;
import i.p.a.a.a.f.c;
import io.github.inflationx.calligraphy3.BuildConfig;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import kotlin.Metadata;
import n.e;
import n.i.a.l;
import n.i.b.h;
import org.apache.lucene.analysis.shingle.ShingleFilter;
import org.apache.lucene.analysis.wikipedia.WikipediaTokenizer;
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u009a\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0007\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\f\n\u0002\u0010!\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0006\u0018\u00002\u00020\u00012\u00020\u0002B%\u0012\u0006\u0010Y\u001a\u00020X\u0012\n\b\u0002\u0010[\u001a\u0004\u0018\u00010Z\u0012\b\b\u0002\u0010]\u001a\u00020\\¢\u0006\u0004\b^\u0010_B\u0011\b\u0016\u0012\u0006\u0010Y\u001a\u00020X¢\u0006\u0004\b^\u0010`B\u001d\b\u0016\u0012\u0006\u0010Y\u001a\u00020X\u0012\n\b\u0002\u0010[\u001a\u0004\u0018\u00010Z¢\u0006\u0004\b^\u0010aJ\u000f\u0010\u0004\u001a\u00020\u0003H\u0003¢\u0006\u0004\b\u0004\u0010\u0005J\u0017\u0010\t\u001a\u00020\b2\u0006\u0010\u0007\u001a\u00020\u0006H\u0002¢\u0006\u0004\b\t\u0010\nJ\u000f\u0010\u000b\u001a\u00020\u0003H\u0002¢\u0006\u0004\b\u000b\u0010\u0005J\u001f\u0010\u000e\u001a\u00020\u00032\u0006\u0010\u0007\u001a\u00020\u00062\b\b\u0002\u0010\r\u001a\u00020\f¢\u0006\u0004\b\u000e\u0010\u000fJ\u000f\u0010\u0010\u001a\u00020\u0003H\u0007¢\u0006\u0004\b\u0010\u0010\u0005J\u000f\u0010\u0011\u001a\u00020\u0003H\u0007¢\u0006\u0004\b\u0011\u0010\u0005J\u000f\u0010\u0012\u001a\u00020\u0003H\u0007¢\u0006\u0004\b\u0012\u0010\u0005J\u0015\u0010\u0015\u001a\u00020\f2\u0006\u0010\u0014\u001a\u00020\u0013¢\u0006\u0004\b\u0015\u0010\u0016J\r\u0010\u0017\u001a\u00020\u0003¢\u0006\u0004\b\u0017\u0010\u0005J\r\u0010\u0018\u001a\u00020\u0003¢\u0006\u0004\b\u0018\u0010\u0005J\u0015\u0010\u001b\u001a\u00020\f2\u0006\u0010\u001a\u001a\u00020\u0019¢\u0006\u0004\b\u001b\u0010\u001cR\u001c\u0010\"\u001a\u00020\u001d8\u0000@\u0000X\u0080\u0004¢\u0006\f\n\u0004\b\u001e\u0010\u001f\u001a\u0004\b \u0010!R\u0016\u0010$\u001a\u00020\f8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0018\u0010#R$\u0010'\u001a\u00020\f2\u0006\u0010%\u001a\u00020\f8\u0006@BX\u0086\u000e¢\u0006\f\n\u0004\b&\u0010#\u001a\u0004\b'\u0010(R\u0016\u0010+\u001a\u00020)8\u0002@\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\t\u0010*R\u0019\u00101\u001a\u00020,8\u0006@\u0006¢\u0006\f\n\u0004\b-\u0010.\u001a\u0004\b/\u00100R\u0013\u00105\u001a\u0002028F@\u0006¢\u0006\u0006\u001a\u0004\b3\u00104R0\u0010=\u001a\u0010\u0012\f\u0012\n\u0012\u0004\u0012\u00020\u0003\u0018\u000107068\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b\u000b\u00108\u001a\u0004\b9\u0010:\"\u0004\b;\u0010<R\"\u0010\u0007\u001a\u00020\u00068\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b>\u0010?\u001a\u0004\b@\u0010A\"\u0004\bB\u0010CR\u001c\u0010G\u001a\b\u0012\u0004\u0012\u00020\u00190D8\u0002@\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bE\u0010FR\u001e\u0010K\u001a\n I*\u0004\u0018\u00010H0H8\u0002@\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u000e\u0010JR\"\u0010S\u001a\u00020L8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\bM\u0010N\u001a\u0004\bO\u0010P\"\u0004\bQ\u0010RR\u0016\u0010W\u001a\u00020T8\u0002@\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bU\u0010V¨\u0006b"}, d2 = {"Lcom/pierfrancescosoffritti/androidyoutubeplayer/core/player/views/YouTubePlayerView;", "Lcom/pierfrancescosoffritti/androidyoutubeplayer/core/player/views/SixteenByNineFrameLayout;", "Le/q/i;", "Ln/e;", "onResume", "()V", "", "videoId", "", "m", "(Ljava/lang/String;)F", GoogleApiAvailabilityLight.TRACKING_SOURCE_NOTIFICATION, "", "autoPlay", "l", "(Ljava/lang/String;Z)V", BuildConfig.BUILD_TYPE, "onPause", "onStop", "Li/p/a/a/a/c/d;", "youTubePlayerListener", "f", "(Li/p/a/a/a/c/d;)Z", "g", "k", "Li/p/a/a/a/c/c;", "fullScreenListener", WikipediaTokenizer.CATEGORY, "(Li/p/a/a/a/c/c;)Z", "Lcom/pierfrancescosoffritti/androidyoutubeplayer/core/player/views/LegacyYouTubePlayerView;", WikipediaTokenizer.ITALICS, "Lcom/pierfrancescosoffritti/androidyoutubeplayer/core/player/views/LegacyYouTubePlayerView;", "getLegacyTubePlayerView$youtubeplayer_release", "()Lcom/pierfrancescosoffritti/androidyoutubeplayer/core/player/views/LegacyYouTubePlayerView;", "legacyTubePlayerView", "Z", "startBuffering", "<set-?>", "r", "isFullScreen", "()Z", "Li/p/a/a/a/e/d;", "Li/p/a/a/a/e/d;", "tracker", "Lcom/pierfrancescosoffritti/androidyoutubeplayer/core/player/views/ThumbnailView;", "o", "Lcom/pierfrancescosoffritti/androidyoutubeplayer/core/player/views/ThumbnailView;", "getThumbnailView", "()Lcom/pierfrancescosoffritti/androidyoutubeplayer/core/player/views/ThumbnailView;", "thumbnailView", "Li/p/a/a/a/a;", "getYoutubePlayer", "()Li/p/a/a/a/a;", "youtubePlayer", "Ljava/util/ArrayList;", "Lkotlin/Function0;", "Ljava/util/ArrayList;", "getOnClickMasks", "()Ljava/util/ArrayList;", "setOnClickMasks", "(Ljava/util/ArrayList;)V", "onClickMasks", "p", "Ljava/lang/String;", "getVideoId", "()Ljava/lang/String;", "setVideoId", "(Ljava/lang/String;)V", "", "s", "Ljava/util/List;", "fullScreenListeners", "Landroid/content/SharedPreferences;", "kotlin.jvm.PlatformType", "Landroid/content/SharedPreferences;", "sp", "Lcom/pierfrancescosoffritti/androidyoutubeplayer/core/player/PlayerConstants$PlayerState;", "q", "Lcom/pierfrancescosoffritti/androidyoutubeplayer/core/player/PlayerConstants$PlayerState;", "getLastState", "()Lcom/pierfrancescosoffritti/androidyoutubeplayer/core/player/PlayerConstants$PlayerState;", "setLastState", "(Lcom/pierfrancescosoffritti/androidyoutubeplayer/core/player/PlayerConstants$PlayerState;)V", "lastState", "Landroid/widget/ProgressBar;", "j", "Landroid/widget/ProgressBar;", "progressBar", "Landroid/content/Context;", "context", "Landroid/util/AttributeSet;", "attrs", "", "defStyleAttr", "<init>", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "(Landroid/content/Context;)V", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", "youtubeplayer_release"}, k = 1, mv = {1, 4, 1})
public final class YouTubePlayerView extends SixteenByNineFrameLayout implements i {
    public static final int f3916t = 0;
    public final LegacyYouTubePlayerView f3917i;
    public final ProgressBar f3918j;
    public boolean f3919k;
    public final SharedPreferences f3920l;
    public final d f3921m;
    public ArrayList<n.i.a.a<e>> f3922n;
    public final ThumbnailView f3923o;
    public String f3924p;
    public PlayerConstants$PlayerState f3925q;
    public boolean f3926r;
    public final List<i.p.a.a.a.c.c> f3927s;

    public static final class a implements View.OnTouchListener {
        public a() {
        }

        @Override
        public final boolean onTouch(View view, MotionEvent motionEvent) {
            h.d(motionEvent, "event");
            if (motionEvent.getAction() == 0) {
                Iterator<T> it = YouTubePlayerView.this.getOnClickMasks().iterator();
                while (it.hasNext()) {
                    n.i.a.a aVar = (n.i.a.a) it.next();
                    if (aVar != null) {
                        e eVar = (e) aVar.invoke();
                    }
                }
                return false;
            }
            return false;
        }
    }

    public static final class b extends i.p.a.a.a.c.a {
        public b() {
        }

        @Override
        public void a(i.p.a.a.a.a aVar, float f2) {
            h.e(aVar, "youTubePlayer");
            h.e(aVar, "youTubePlayer");
            YouTubePlayerView.this.f3918j.setVisibility(8);
        }

        @Override
        @SuppressLint({"CommitPrefEdits"})
        public void e(i.p.a.a.a.a aVar, PlayerConstants$PlayerState playerConstants$PlayerState) {
            h.e(aVar, "youTubePlayer");
            h.e(playerConstants$PlayerState, "state");
            YouTubePlayerView.this.setLastState(playerConstants$PlayerState);
            YouTubePlayerView youTubePlayerView = YouTubePlayerView.this;
            if (youTubePlayerView.f3919k && playerConstants$PlayerState != PlayerConstants$PlayerState.BUFFERING) {
                youTubePlayerView.f3918j.setVisibility(8);
                YouTubePlayerView.this.f3919k = false;
            }
            if (playerConstants$PlayerState == PlayerConstants$PlayerState.PLAYING && YouTubePlayerView.this.getThumbnailView().getAlpha() > 0) {
                YouTubePlayerView.this.getThumbnailView().animate().alpha(0.0f);
                ViewParent parent = YouTubePlayerView.this.getThumbnailView().getParent();
                Objects.requireNonNull(parent, "null cannot be cast to non-null type android.widget.FrameLayout");
                ((FrameLayout) parent).setForeground(null);
            } else if (playerConstants$PlayerState == PlayerConstants$PlayerState.BUFFERING) {
                YouTubePlayerView youTubePlayerView2 = YouTubePlayerView.this;
                youTubePlayerView2.f3919k = true;
                youTubePlayerView2.f3918j.setVisibility(0);
            } else if (playerConstants$PlayerState == PlayerConstants$PlayerState.ENDED) {
                YouTubePlayerView.this.f3918j.setVisibility(8);
                YouTubePlayerView.this.f3920l.edit().remove(YouTubePlayerView.this.getVideoId()).apply();
            }
        }
    }

    public static final class c extends i.p.a.a.a.c.a {
        public final i.p.a.a.a.d.a b;
        public final boolean c;
        public final String f3929d;

        public c(i.p.a.a.a.d.a aVar, boolean z, String str) {
            this.b = aVar;
            this.c = z;
            this.f3929d = str;
        }

        @Override
        public void f(i.p.a.a.a.a aVar) {
            h.e(aVar, "youTubePlayer");
            if (this.b.a == 0 && this.c) {
                aVar.play();
            }
            YouTubePlayerView youTubePlayerView = YouTubePlayerView.this;
            String str = this.f3929d;
            int i2 = YouTubePlayerView.f3916t;
            float m2 = youTubePlayerView.m(str);
            if (m2 > 0) {
                aVar.e(m2);
            }
            if (!this.c) {
                YouTubePlayerView.this.f3918j.setVisibility(8);
            }
            aVar.b(this);
        }
    }

    public YouTubePlayerView(Context context, AttributeSet attributeSet, int i2) {
        super(context, attributeSet, i2);
        h.e(context, "context");
        LegacyYouTubePlayerView legacyYouTubePlayerView = new LegacyYouTubePlayerView(context);
        this.f3917i = legacyYouTubePlayerView;
        ProgressBar progressBar = new ProgressBar(context);
        this.f3918j = progressBar;
        this.f3920l = context.getSharedPreferences("YouTubePlayerView", 0);
        d dVar = new d();
        this.f3921m = dVar;
        this.f3922n = new ArrayList<>();
        ThumbnailView thumbnailView = new ThumbnailView(context, null, 0, 6);
        this.f3923o = thumbnailView;
        this.f3924p = "";
        this.f3925q = PlayerConstants$PlayerState.UNKNOWN;
        addView(legacyYouTubePlayerView, new FrameLayout.LayoutParams(-1, -1));
        FrameLayout frameLayout = new FrameLayout(context);
        frameLayout.setForeground(new ColorDrawable(1291845632));
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
        layoutParams.gravity = 17;
        frameLayout.addView(thumbnailView, layoutParams);
        thumbnailView.setImageDrawable(new ColorDrawable(-16777216));
        frameLayout.setOnTouchListener(new a());
        addView(frameLayout, new FrameLayout.LayoutParams(-1, -1));
        FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(-2, -2);
        layoutParams2.gravity = 17;
        addView(progressBar, layoutParams2);
        legacyYouTubePlayerView.getYouTubePlayer$youtubeplayer_release().c(new b());
        legacyYouTubePlayerView.getYouTubePlayer$youtubeplayer_release().c(dVar);
        if (context instanceof j) {
            ((j) context).getLifecycle().a(this);
        }
        this.f3927s = new ArrayList();
    }

    @n(Lifecycle.Event.ON_RESUME)
    private final void onResume() {
        this.f3917i.onResume$youtubeplayer_release();
    }

    public final boolean c(i.p.a.a.a.c.c cVar) {
        h.e(cVar, "fullScreenListener");
        if (this.f3927s.contains(cVar)) {
            return false;
        }
        return this.f3927s.add(cVar);
    }

    public final boolean f(i.p.a.a.a.c.d dVar) {
        h.e(dVar, "youTubePlayerListener");
        return this.f3917i.getYouTubePlayer$youtubeplayer_release().c(dVar);
    }

    public final void g() {
        if (this.f3926r) {
            return;
        }
        this.f3926r = true;
        for (i.p.a.a.a.c.c cVar : this.f3927s) {
            cVar.c();
        }
    }

    public final PlayerConstants$PlayerState getLastState() {
        return this.f3925q;
    }

    public final LegacyYouTubePlayerView getLegacyTubePlayerView$youtubeplayer_release() {
        return this.f3917i;
    }

    public final ArrayList<n.i.a.a<e>> getOnClickMasks() {
        return this.f3922n;
    }

    public final ThumbnailView getThumbnailView() {
        return this.f3923o;
    }

    public final String getVideoId() {
        return this.f3924p;
    }

    public final i.p.a.a.a.a getYoutubePlayer() {
        return this.f3917i.getYouTubePlayer$youtubeplayer_release();
    }

    public final void k() {
        if (this.f3926r) {
            this.f3926r = false;
            for (i.p.a.a.a.c.c cVar : this.f3927s) {
                cVar.b();
            }
        }
    }

    public final void l(String str, boolean z) {
        h.e(str, "videoId");
        this.f3924p = str;
        a.b bVar = i.p.a.a.a.d.a.f13232e;
        final i.p.a.a.a.d.a aVar = i.p.a.a.a.d.a.c;
        if (!i.j.a.e.t.d.h3(str)) {
            aVar = null;
        }
        if (aVar == null) {
            aVar = i.p.a.a.a.d.a.f13231d;
        }
        if (i.j.a.e.t.d.h3(str)) {
            Objects.requireNonNull(aVar);
            h.e("videoId", "key");
            h.e(str, AppMeasurementSdk.ConditionalUserProperty.VALUE);
            aVar.b.put("videoId", str);
        } else {
            Objects.requireNonNull(aVar);
            h.e("id", "key");
            h.e(str, AppMeasurementSdk.ConditionalUserProperty.VALUE);
            aVar.b.put("id", str);
        }
        Objects.requireNonNull(aVar);
        h.e("autoplay", "key");
        aVar.b.put("autoplay", z);
        final LegacyYouTubePlayerView legacyYouTubePlayerView = this.f3917i;
        final c cVar = new c(aVar, z, str);
        Objects.requireNonNull(legacyYouTubePlayerView);
        h.e(cVar, "youTubePlayerListener");
        legacyYouTubePlayerView.getContext().registerReceiver(legacyYouTubePlayerView.f3874j, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
        legacyYouTubePlayerView.f3877m = new n.i.a.a<e>() {
            {
                super(0);
            }

            @Override
            public e invoke() {
                invoke2();
                return e.a;
            }

            public final void invoke2() {
                int i2;
                final WebViewYouTubePlayer youTubePlayer$youtubeplayer_release = LegacyYouTubePlayerView.this.getYouTubePlayer$youtubeplayer_release();
                l<i.p.a.a.a.a, e> lVar = new l<i.p.a.a.a.a, e>() {
                    {
                        super(1);
                    }

                    @Override
                    public e invoke(i.p.a.a.a.a aVar2) {
                        invoke2(aVar2);
                        return e.a;
                    }

                    public final void invoke2(i.p.a.a.a.a aVar2) {
                        h.e(aVar2, "it");
                        aVar2.c(cVar);
                    }
                };
                a aVar2 = aVar;
                Objects.requireNonNull(youTubePlayer$youtubeplayer_release);
                h.e(lVar, "initListener");
                youTubePlayer$youtubeplayer_release.f3893i = lVar;
                if (aVar2 == null) {
                    a.b bVar2 = a.f13232e;
                    aVar2 = a.c;
                }
                a aVar3 = aVar2;
                WebSettings settings = youTubePlayer$youtubeplayer_release.getSettings();
                h.d(settings, "settings");
                settings.setJavaScriptEnabled(true);
                WebSettings settings2 = youTubePlayer$youtubeplayer_release.getSettings();
                h.d(settings2, "settings");
                settings2.setMediaPlaybackRequiresUserGesture(false);
                WebSettings settings3 = youTubePlayer$youtubeplayer_release.getSettings();
                h.d(settings3, "settings");
                settings3.setCacheMode(2);
                youTubePlayer$youtubeplayer_release.addJavascriptInterface(new b(youTubePlayer$youtubeplayer_release), "YouTubePlayerBridge");
                Resources resources = youTubePlayer$youtubeplayer_release.getResources();
                Integer valueOf = Integer.valueOf(R$raw.ayp_youtube_player);
                valueOf.intValue();
                if (!(aVar3.a == 0)) {
                    valueOf = null;
                }
                if (valueOf != null) {
                    i2 = valueOf.intValue();
                } else {
                    i2 = R$raw.vimeo_player;
                }
                InputStream openRawResource = resources.openRawResource(i2);
                h.d(openRawResource, "resources.openRawResourc…   ?: R.raw.vimeo_player)");
                h.e(openRawResource, "inputStream");
                try {
                    try {
                        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(openRawResource, "utf-8"));
                        StringBuilder sb = new StringBuilder();
                        for (String readLine = bufferedReader.readLine(); readLine != null; readLine = bufferedReader.readLine()) {
                            sb.append(readLine);
                            sb.append("\n");
                        }
                        String sb2 = sb.toString();
                        h.d(sb2, "sb.toString()");
                        openRawResource.close();
                        String w2 = n.o.a.w(sb2, "<<injectedPlayerVars>>", aVar3.toString(), false, 4);
                        String optString = aVar3.b.optString("videoId");
                        h.d(optString, "playerOptions.optString(\"videoId\")");
                        youTubePlayer$youtubeplayer_release.loadDataWithBaseURL(aVar3.b.optString(AppMeasurementSdk.ConditionalUserProperty.ORIGIN), n.o.a.w(w2, "<<videoId>>", optString, false, 4), "text/html", "utf-8", null);
                        youTubePlayer$youtubeplayer_release.setWebChromeClient(new c());
                        if (aVar3.a == 1) {
                            youTubePlayer$youtubeplayer_release.setWebViewClient(new WebViewClient() {
                                @Override
                                public void onPageFinished(WebView webView, String str2) {
                                    h.e(webView, "webView");
                                    h.e(str2, "url");
                                    WebViewYouTubePlayer.this.loadUrl("javascript:initVimeoPlayer()");
                                }
                            });
                        }
                    } catch (Exception unused) {
                        throw new RuntimeException("Can't parse HTML file.");
                    }
                } catch (Throwable th) {
                    openRawResource.close();
                    throw th;
                }
            }
        };
    }

    public final float m(String str) {
        if (this.f3920l.contains(str)) {
            String string = this.f3920l.getString(str, "");
            if (!(string == null || n.o.a.o(string))) {
                return Float.parseFloat((String) n.o.a.A(string, new String[]{ShingleFilter.DEFAULT_FILLER_TOKEN}, false, 0, 6).get(0));
            }
        }
        return 0.0f;
    }

    public final void n() {
        int i2;
        d dVar = this.f3921m;
        float f2 = dVar.b;
        float f3 = 60;
        if (f2 > f3) {
            float f4 = dVar.a;
            if (f4 > f3 && f4 < f2 - f3 && this.f3925q != PlayerConstants$PlayerState.ENDED) {
                SharedPreferences.Editor edit = this.f3920l.edit();
                String str = this.f3924p;
                StringBuilder sb = new StringBuilder();
                sb.append(this.f3921m.a);
                sb.append('_');
                sb.append(System.currentTimeMillis());
                edit.putString(str, sb.toString()).apply();
                SharedPreferences sharedPreferences = this.f3920l;
                h.d(sharedPreferences, "sp");
                int size = sharedPreferences.getAll().size();
                int i3 = i.p.a.a.a.d.b.a;
                if (size > 5) {
                    ArrayMap arrayMap = new ArrayMap();
                    SharedPreferences sharedPreferences2 = this.f3920l;
                    h.d(sharedPreferences2, "sp");
                    Iterator<T> it = sharedPreferences2.getAll().keySet().iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            break;
                        }
                        String str2 = (String) it.next();
                        String string = this.f3920l.getString(str2, "");
                        h.c(string);
                        h.d(string, "sp.getString(it, \"\")!!");
                        arrayMap.put(Long.valueOf(Long.parseLong((String) n.o.a.A(string, new String[]{ShingleFilter.DEFAULT_FILLER_TOKEN}, false, 0, 6).get(1))), str2);
                    }
                    SharedPreferences sharedPreferences3 = this.f3920l;
                    h.d(sharedPreferences3, "sp");
                    int size2 = sharedPreferences3.getAll().size();
                    int i4 = i.p.a.a.a.d.b.a;
                    int i5 = size2 - 5;
                    for (i2 = 0; i2 < i5; i2++) {
                        SharedPreferences.Editor edit2 = this.f3920l.edit();
                        String str3 = (String) arrayMap.get(arrayMap.i(i2));
                        if (str3 == null) {
                            str3 = "";
                        }
                        edit2.remove(str3).apply();
                    }
                    return;
                }
                return;
            }
        }
        if (this.f3920l.contains(this.f3924p)) {
            this.f3920l.edit().remove(this.f3924p).apply();
        }
    }

    @n(Lifecycle.Event.ON_PAUSE)
    public final void onPause() {
        if (i.j.a.e.t.d.d3(this.f3924p)) {
            this.f3917i.onStop$youtubeplayer_release();
        }
    }

    @n(Lifecycle.Event.ON_STOP)
    public final void onStop() {
        this.f3917i.onStop$youtubeplayer_release();
        n();
    }

    @n(Lifecycle.Event.ON_DESTROY)
    public final void release() {
        this.f3917i.release();
    }

    public final void setLastState(PlayerConstants$PlayerState playerConstants$PlayerState) {
        h.e(playerConstants$PlayerState, "<set-?>");
        this.f3925q = playerConstants$PlayerState;
    }

    public final void setOnClickMasks(ArrayList<n.i.a.a<e>> arrayList) {
        h.e(arrayList, "<set-?>");
        this.f3922n = arrayList;
    }

    public final void setVideoId(String str) {
        h.e(str, "<set-?>");
        this.f3924p = str;
    }

    public YouTubePlayerView(Context context) {
        this(context, null, 0);
        h.e(context, "context");
    }

    public YouTubePlayerView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
        h.e(context, "context");
    }
}