导航菜单

页面标题

页面副标题

Your TV v2.0.2 - MainActivity.java 源代码

正在查看: Your TV v2.0.2 应用的 MainActivity.java JAVA 源代码文件

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


package com.horsenma.yourtv;

import E.a;
import G.k;
import G0.A3;
import G0.B;
import G0.C;
import G0.C0034a;
import G0.C0035a0;
import G0.C0041b0;
import G0.C0044b3;
import G0.C0046c;
import G0.C0053d0;
import G0.C0054d1;
import G0.C0076h0;
import G0.C0088j2;
import G0.C0091k0;
import G0.C0101m0;
import G0.C0131s1;
import G0.C0138t3;
import G0.C0147v2;
import G0.C0167z2;
import G0.C3;
import G0.E;
import G0.G1;
import G0.K1;
import G0.L1;
import G0.L2;
import G0.N1;
import G0.Q;
import G0.RunnableC0040b;
import G0.RunnableC0106n0;
import G0.S;
import G0.X;
import G0.Z;
import G0.h4;
import G0.k4;
import G0.w4;
import I0.f;
import I0.i;
import M0.h;
import N0.v;
import android.R;
import android.app.Dialog;
import android.app.UiModeManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager;
import android.os.Process;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;
import androidx.fragment.app.C0200a;
import androidx.fragment.app.H;
import androidx.fragment.app.h0;
import androidx.lifecycle.V;
import androidx.lifecycle.d0;
import androidx.media3.exoplayer.ExoPlayer;
import androidx.media3.ui.PlayerView;
import androidx.recyclerview.widget.RecyclerView;
import b.AbstractC0294a;
import b.b;
import com.google.gson.Gson;
import com.horsenma.yourtv.MainActivity;
import com.horsenma.yourtv.data.TV;
import com.horsenma.yourtv.databinding.ChannelBinding;
import com.horsenma.yourtv.databinding.PlayerBinding;
import com.horsenma.yourtv.databinding.SettingsWebBinding;
import e1.g;
import j0.EnumC0403b;
import j0.EnumC0404c;
import j0.d;
import j0.e;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;
import k.AbstractActivityC0423j;
import kotlin.jvm.internal.j;
import kotlin.jvm.internal.s;
import kotlinx.coroutines.BuildersKt__Builders_commonKt;
import kotlinx.coroutines.CoroutineScopeKt;
import kotlinx.coroutines.Dispatchers;
import org.json.JSONObject;
import v0.t;

public final class MainActivity extends AbstractActivityC0423j {

    public static final int f3855j0 = 0;

    public int f3856A;

    public final Handler f3867L;

    public final long f3868M;

    public final long f3869N;

    public GestureDetector f3870O;

    public C0147v2 f3871P;

    public C0138t3 f3872Q;

    public final h f3873R;

    public int f3874S;

    public long f3875T;

    public final long f3876U;

    public final long f3877V;

    public final int f3878W;

    public long f3879X;

    public final long f3880Y;

    public final RunnableC0106n0 f3881Z;

    public final RunnableC0106n0 f3882a0;

    public final RunnableC0106n0 f3883b0;

    public C0054d1 f3884c0;

    public boolean f3885d0;

    public PowerManager.WakeLock f3886e0;

    public long f3887f0;

    public final long f3888g0;

    public final RunnableC0106n0 f3889h0;

    public final RunnableC0106n0 f3890i0;

    public final String f3891z = "MainActivity";

    public G1 f3857B = new G1();

    public final C f3858C = new C();

    public final S f3859D = new S();

    public final Q f3860E = new Q();

    public final C0046c f3861F = new C0046c();

    public final C0044b3 f3862G = new C0044b3();

    public final C0131s1 f3863H = new C0131s1();

    public final C0088j2 f3864I = new C0088j2();

    public final K1 f3865J = new K1();

    public final L2 f3866K = new L2();

    public MainActivity() {
        Looper myLooper = Looper.myLooper();
        j.b(myLooper);
        this.f3867L = new Handler(myLooper);
        this.f3868M = 10000L;
        this.f3869N = 60000L;
        this.f3873R = new h(new C0035a0(this, 1));
        this.f3876U = 300L;
        this.f3877V = 500L;
        this.f3878W = 4;
        this.f3880Y = ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS;
        this.f3881Z = new RunnableC0106n0(this, 0);
        this.f3882a0 = new RunnableC0106n0(this, 1);
        this.f3883b0 = new RunnableC0106n0(this, 2);
        this.f3888g0 = ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS;
        this.f3889h0 = new RunnableC0106n0(this, 3);
        this.f3890i0 = new RunnableC0106n0(this, 4);
    }

    public final void A() {
        int i2 = v().f1068h.i();
        i j2 = (N1.e() && v().f1068h.f1563c && v().f1068h.k(0) != null) ? v().f1068h.j(true) : v().f1068h.j(false);
        if (j2 != null) {
            j2.v(false);
        }
        v().f1068h.p();
        f g2 = v().f1068h.g();
        if (g2 != null) {
            g2.m(g2.h());
        }
        int i3 = v().f1068h.i();
        if (i3 != i2) {
            this.f3863H.m(i3);
        }
    }

    public final void B(String TAG) {
        i f2;
        j.e(TAG, "TAG");
        int i2 = this.f3856A + 1;
        this.f3856A = i2;
        if (i2 == 2) {
            this.f3870O = new GestureDetector(this, new C0041b0(this, this));
            h0 p2 = p();
            p2.getClass();
            C0200a c0200a = new C0200a(p2);
            c0200a.i(this.f3863H);
            c0200a.i(this.f3864I);
            c0200a.i(this.f3866K);
            c0200a.d();
            v().f1068h.f1568h.e(this, new C0091k0(0, new Z(this, 0)));
            v().f1073n.e(this, new C0091k0(0, new Z(this, 1)));
            k4.f1216b.e(this, new C0091k0(0, new X(1, this, TAG)));
            this.f3871P = new C0147v2(this, v());
            if (!this.f3857B.isAdded() || this.f3857B.isHidden() || (f2 = v().f1068h.f()) == null) {
                return;
            }
            this.f3857B.l(f2);
        }
    }

    public final void C() {
        Handler handler = this.f3867L;
        RunnableC0106n0 runnableC0106n0 = this.f3890i0;
        handler.removeCallbacks(runnableC0106n0);
        handler.postDelayed(runnableC0106n0, this.f3869N);
    }

    public final void D(H fragment) {
        j.e(fragment, "fragment");
        if (this.f3885d0) {
            h0 p2 = p();
            p2.getClass();
            C0200a c0200a = new C0200a(p2);
            if (!fragment.isAdded()) {
                c0200a.g(2131362069, fragment, null, 1);
            } else if (!fragment.isHidden()) {
                return;
            }
            c0200a.k(fragment);
            try {
                c0200a.f();
            } catch (IllegalStateException unused) {
                c0200a.d();
            }
            View view = fragment.getView();
            if (view != null) {
                view.setVisibility(0);
            }
        }
    }

    public final void E() {
        C0131s1 c0131s1 = this.f3863H;
        if (!c0131s1.isAdded() || c0131s1.isHidden()) {
            C0088j2 c0088j2 = this.f3864I;
            if (!c0088j2.isAdded() || c0088j2.isHidden()) {
                i f2 = v().f1068h.f();
                if (f2 != null) {
                    List list = (List) f2.f1587k.d();
                    if (list == null) {
                        list = v.f1679a;
                    }
                    if (list.isEmpty()) {
                        b.Q(2131820639);
                        return;
                    }
                }
                D(this.f3865J);
            }
        }
    }

    public final void F() {
        BuildersKt__Builders_commonKt.launch$default(V.e(this), Dispatchers.getMain(), null, new C0101m0(this, null), 2, null);
    }

    public final void G() {
        SharedPreferences sharedPreferences = N1.f803c;
        if (sharedPreferences == null) {
            j.i("sp");
            throw null;
        }
        boolean z2 = sharedPreferences.getBoolean("time", true);
        C0044b3 c0044b3 = this.f3862G;
        if (z2) {
            D(c0044b3);
        } else {
            w(c0044b3);
        }
    }

    public final void H(String str) {
        SettingsWebBinding inflate = SettingsWebBinding.inflate(getLayoutInflater());
        j.d(inflate, "inflate(...)");
        WebView web = inflate.web;
        j.d(web, "web");
        web.getSettings().setJavaScriptEnabled(true);
        web.setFocusableInTouchMode(true);
        web.setFocusable(true);
        web.loadUrl(str);
        PopupWindow popupWindow = new PopupWindow(inflate.getRoot(), -1, -1);
        popupWindow.setInputMethodMode(1);
        popupWindow.setFocusable(true);
        popupWindow.setTouchable(true);
        popupWindow.setClippingEnabled(false);
        popupWindow.showAtLocation(getWindow().getDecorView(), 17, 0, 0);
        web.requestFocus();
        inflate.close.setOnClickListener(new B(popupWindow, 1));
    }

    public final void I() {
        long currentTimeMillis = System.currentTimeMillis();
        if (currentTimeMillis - this.f3887f0 < this.f3888g0) {
            return;
        }
        this.f3887f0 = currentTimeMillis;
        i f2 = v().f1068h.f();
        if (f2 == null) {
            if (v().f1067g.isEmpty()) {
                b.Q(2131820739);
                return;
            }
            ?? r02 = v().f1067g;
            SharedPreferences sharedPreferences = N1.f803c;
            if (sharedPreferences == null) {
                j.i("sp");
                throw null;
            }
            f2 = (i) r02.get(AbstractC0294a.k(sharedPreferences.getInt("channel", 0), v().f1067g.size() - 1));
            v().f1068h.n(f2);
        }
        List s2 = f2.m().s();
        ArrayList arrayList = new ArrayList();
        for (Object obj : s2) {
            if (!g.p0(((H0.j) obj).b())) {
                arrayList.add(obj);
            }
        }
        if (arrayList.isEmpty()) {
            b.Q(2131820733);
            return;
        }
        if (arrayList.size() <= 1) {
            b.Q(2131820740);
            return;
        }
        f2.r();
        f2.f();
        this.f3857B.s(f2);
        Toast makeText = Toast.makeText(this, A.g.j("线路 ", f2.n() + 1, " / ", arrayList.size()), 1);
        View view = makeText.getView();
        TextView textView = view != null ? (TextView) view.findViewById(R.id.message) : null;
        if (textView != null) {
            textView.setTextSize(30.0f);
        }
        makeText.setGravity(17, 0, 0);
        makeText.show();
        this.f3867L.postDelayed(new a(makeText, 4), 5000L);
    }

    public final void J(boolean z2) {
        getWindow().clearFlags(16);
        getWindow().addFlags(128);
        B0.b bVar = new B0.b(getWindow(), getWindow().getDecorView());
        Object systemService = getSystemService("uimode");
        UiModeManager uiModeManager = systemService instanceof UiModeManager ? (UiModeManager) systemService : null;
        boolean z3 = uiModeManager != null && uiModeManager.getCurrentModeType() == 4;
        final Handler handler = new Handler(Looper.getMainLooper());
        final t tVar = new t(4, this, bVar);
        int i2 = Build.VERSION.SDK_INT;
        if (i2 < 26) {
            getWindow().setFlags(1024, 1024);
            getWindow().setNavigationBarColor(com.tencent.smtt.sdk.WebView.NIGHT_MODE_COLOR);
            final int i3 = 0;
            getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
                @Override
                public final void onSystemUiVisibilityChange(int i4) {
                    v0.t tVar2 = tVar;
                    Handler handler2 = handler;
                    switch (i3) {
                        case 0:
                            int i5 = MainActivity.f3855j0;
                            if ((i4 & 4) == 0) {
                                handler2.removeCallbacks(tVar2);
                                handler2.postDelayed(tVar2, androidx.media3.common.C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS);
                                break;
                            }
                            break;
                        default:
                            int i6 = MainActivity.f3855j0;
                            if ((i4 & 4) == 0) {
                                handler2.removeCallbacks(tVar2);
                                handler2.postDelayed(tVar2, 5000L);
                                break;
                            }
                            break;
                    }
                }
            });
            return;
        }
        Window window = getWindow();
        boolean z4 = !z2;
        if (i2 >= 35) {
            I.b.d(window, z4);
        } else if (i2 >= 30) {
            I.b.c(window, z4);
        } else {
            View decorView = window.getDecorView();
            int systemUiVisibility = decorView.getSystemUiVisibility();
            decorView.setSystemUiVisibility(!z2 ? systemUiVisibility & (-1793) : systemUiVisibility | 1792);
        }
        WindowManager.LayoutParams attributes = getWindow().getAttributes();
        android.support.v4.media.session.b bVar2 = (android.support.v4.media.session.b) bVar.f80b;
        bVar2.J();
        bVar2.V();
        if (i2 >= 28) {
            attributes.layoutInDisplayCutoutMode = (!z2 || z3) ? 0 : 1;
        }
        getWindow().setNavigationBarColor(com.tencent.smtt.sdk.WebView.NIGHT_MODE_COLOR);
        final int i4 = 1;
        getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public final void onSystemUiVisibilityChange(int i42) {
                v0.t tVar2 = tVar;
                Handler handler2 = handler;
                switch (i4) {
                    case 0:
                        int i5 = MainActivity.f3855j0;
                        if ((i42 & 4) == 0) {
                            handler2.removeCallbacks(tVar2);
                            handler2.postDelayed(tVar2, androidx.media3.common.C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS);
                            break;
                        }
                        break;
                    default:
                        int i6 = MainActivity.f3855j0;
                        if ((i42 & 4) == 0) {
                            handler2.removeCallbacks(tVar2);
                            handler2.postDelayed(tVar2, 5000L);
                            break;
                        }
                        break;
                }
            }
        });
        getWindow().setAttributes(attributes);
    }

    @Override
    public final void attachBaseContext(Context base) {
        j.e(base, "base");
        super.attachBaseContext(base);
    }

    @Override
    public final void onCreate(Bundle bundle) {
        L2 l2;
        C0088j2 c0088j2;
        SharedPreferences sharedPreferences;
        List list;
        List list2;
        List list3;
        L2 l22 = this.f3866K;
        C0088j2 c0088j22 = this.f3864I;
        C0131s1 c0131s1 = this.f3863H;
        C0046c c0046c = this.f3861F;
        Q q2 = this.f3860E;
        S s2 = this.f3859D;
        super.onCreate(bundle);
        J(N1.h());
        setContentView(2131558428);
        if (N1.f()) {
            Object systemService = getSystemService("power");
            j.c(systemService, "null cannot be cast to non-null type android.os.PowerManager");
            PowerManager.WakeLock newWakeLock = ((PowerManager) systemService).newWakeLock(1, "YourTV:PlaybackLock");
            this.f3886e0 = newWakeLock;
            if (newWakeLock != null) {
                newWakeLock.acquire();
            }
        }
        C3 c3 = C3.f575a;
        Context applicationContext = getApplicationContext();
        j.d(applicationContext, "getApplicationContext(...)");
        C3.f576b = applicationContext.getApplicationContext();
        try {
            String a2 = e.a(e.f4940a);
            j.d(a2, "getOrCreate(...)");
            C3.f578d = d.a(a2, applicationContext, EnumC0403b.f4930b, EnumC0404c.f4933b);
        } catch (Exception e2) {
            e2.getMessage();
            C3.f578d = applicationContext.getSharedPreferences("UserDataCache", 0);
        }
        try {
            InputStream openRawResource = applicationContext.getResources().openRawResource(2131755019);
            j.d(openRawResource, "openRawResource(...)");
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(openRawResource, e1.a.f4716a), 8192);
            try {
                String I2 = AbstractC0294a.I(bufferedReader);
                bufferedReader.close();
                g.G0(50, I2);
                C0167z2.f1523a.getClass();
                String a3 = C0167z2.a(I2);
                if (a3 != null) {
                    String input = g.I0(a3).toString();
                    Pattern compile = Pattern.compile("[\\p{Cntrl}\\s]+");
                    j.d(compile, "compile(...)");
                    j.e(input, "input");
                    String replaceAll = compile.matcher(input).replaceAll(" ");
                    j.d(replaceAll, "replaceAll(...)");
                    g.G0(100, replaceAll);
                    try {
                        new JSONObject(replaceAll);
                        JSONObject jSONObject = new JSONObject(replaceAll);
                        String string = jSONObject.getString("api_token");
                        j.d(string, "getString(...)");
                        String string2 = jSONObject.getString("account_id");
                        j.d(string2, "getString(...)");
                        String string3 = jSONObject.getString("database_id");
                        j.d(string3, "getString(...)");
                        String optString = jSONObject.optString("worker_api_key", "");
                        j.d(optString, "optString(...)");
                        String string4 = jSONObject.getString("endpoint");
                        j.d(string4, "getString(...)");
                        String w02 = g.w0(string4, "/yourtvm3u");
                        String string5 = jSONObject.getString("Access Key ID");
                        j.d(string5, "getString(...)");
                        String string6 = jSONObject.getString("Secret Access Key");
                        j.d(string6, "getString(...)");
                        C3.f583i = new C0034a(string, string2, string3, optString, w02, string5, string6);
                    } catch (Exception e3) {
                        e3.getMessage();
                    }
                }
            } finally {
            }
        } catch (Exception e4) {
            e4.getMessage();
        }
        try {
            sharedPreferences = C3.f578d;
        } catch (Exception e5) {
            e5.getMessage();
            C3.f579e = null;
            C3.f580f = null;
            C3.f581g = null;
        }
        if (sharedPreferences == null) {
            j.i("prefs");
            throw null;
        }
        String string7 = sharedPreferences.getString("remote_users", null);
        Gson gson = C3.f577c;
        if (string7 != null) {
            Object fromJson = gson.fromJson(string7, (Class<Object>) L1[].class);
            j.d(fromJson, "fromJson(...)");
            list = N0.j.j0((Object[]) fromJson);
        } else {
            list = null;
        }
        C3.f579e = list;
        SharedPreferences sharedPreferences2 = C3.f578d;
        if (sharedPreferences2 == null) {
            j.i("prefs");
            throw null;
        }
        String string8 = sharedPreferences2.getString("warning_messages", null);
        if (string8 != null) {
            Object fromJson2 = gson.fromJson(string8, (Class<Object>) String[].class);
            j.d(fromJson2, "fromJson(...)");
            list2 = N0.j.j0((Object[]) fromJson2);
        } else {
            list2 = null;
        }
        C3.f580f = list2;
        SharedPreferences sharedPreferences3 = C3.f578d;
        if (sharedPreferences3 == null) {
            j.i("prefs");
            throw null;
        }
        String string9 = sharedPreferences3.getString("file_mappings", null);
        if (string9 != null) {
            Object fromJson3 = gson.fromJson(string9, (Class<Object>) E[].class);
            j.d(fromJson3, "fromJson(...)");
            list3 = N0.j.j0((Object[]) fromJson3);
        } else {
            list3 = null;
        }
        C3.f581g = list3;
        List list4 = C3.f579e;
        if (list4 != null) {
            list4.size();
        }
        List list5 = C3.f580f;
        if (list5 != null) {
            list5.size();
        }
        List list6 = C3.f581g;
        if (list6 != null) {
            list6.size();
        }
        Context context = C3.f576b;
        if (context == null) {
            j.i("context");
            throw null;
        }
        SharedPreferences sharedPreferences4 = context.getSharedPreferences("VerificationPrefs", 0);
        SharedPreferences.Editor edit = sharedPreferences4.edit();
        Locale locale = Locale.US;
        String format = new SimpleDateFormat("yyyyMMdd", locale).format(new Date());
        String string10 = sharedPreferences4.getString("last_used_date", null);
        int i2 = sharedPreferences4.getInt("consecutive_days", 0);
        if (string10 == null) {
            edit.putString("last_used_date", format);
            edit.putInt("consecutive_days", 1);
            edit.apply();
        } else {
            try {
                long time = (new SimpleDateFormat("yyyyMMdd", locale).parse(format).getTime() - new SimpleDateFormat("yyyyMMdd", locale).parse(string10).getTime()) / 86400000;
                if (time != 0) {
                    if (time == 1) {
                        edit.putInt("consecutive_days", i2 + 1);
                        edit.putString("last_used_date", format);
                        edit.apply();
                    } else {
                        edit.putInt("consecutive_days", 1);
                        edit.putString("last_used_date", format);
                        edit.apply();
                    }
                }
            } catch (Exception e6) {
                e6.getMessage();
                edit.putInt("consecutive_days", 1);
                edit.putString("last_used_date", format);
                edit.apply();
            }
        }
        BuildersKt__Builders_commonKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getIO()), null, null, new A3(2, null), 3, null);
        this.f3884c0 = (C0054d1) new d0(this).a(C0054d1.class);
        if (bundle == null) {
            C3 c32 = C3.f575a;
            new h4(this, v());
        }
        this.f3872Q = new C0138t3(this, getPackageManager().getPackageInfo(getPackageName(), 0).versionCode);
        new Dialog(this);
        new C0053d0(this);
        if (bundle == null) {
            this.f3857B = new G1();
            try {
                h0 p2 = p();
                p2.getClass();
                C0200a c0200a = new C0200a(p2);
                c0200a.g(2131362069, this.f3857B, "PlayerFragment", 1);
                c0200a.g(2131362069, s2, "LoadingFragment", 1);
                c0200a.g(2131362069, q2, null, 1);
                c0200a.g(2131362069, c0046c, null, 1);
                c0200a.g(2131362069, c0131s1, null, 1);
                c0088j2 = c0088j22;
                try {
                    c0200a.g(2131362069, c0088j2, null, 1);
                    l2 = l22;
                    try {
                        c0200a.g(2131362069, l2, null, 1);
                        c0200a.i(s2);
                        c0200a.i(q2);
                        c0200a.i(c0046c);
                        c0200a.i(c0131s1);
                        c0200a.i(c0088j2);
                        c0200a.i(l2);
                        c0200a.f();
                        this.f3857B.isAdded();
                        this.f3857B.isVisible();
                    } catch (IllegalStateException e7) {
                        e = e7;
                        e.getMessage();
                        h0 p3 = p();
                        p3.getClass();
                        C0200a c0200a2 = new C0200a(p3);
                        c0200a2.g(2131362069, this.f3857B, "PlayerFragment", 1);
                        c0200a2.g(2131362069, s2, "LoadingFragment", 1);
                        c0200a2.g(2131362069, q2, null, 1);
                        c0200a2.g(2131362069, c0046c, null, 1);
                        c0200a2.g(2131362069, c0131s1, null, 1);
                        c0200a2.g(2131362069, c0088j2, null, 1);
                        c0200a2.g(2131362069, l2, null, 1);
                        c0200a2.i(s2);
                        c0200a2.i(q2);
                        c0200a2.i(c0046c);
                        c0200a2.i(c0131s1);
                        c0200a2.i(c0088j2);
                        c0200a2.i(l2);
                        c0200a2.d();
                        YourTVApplication yourTVApplication = YourTVApplication.f3892p;
                        android.support.v4.media.session.b.E().f3905n = new C0035a0(this, 0);
                        this.f3870O = new GestureDetector(this, new C0041b0(this, this));
                        v().f1063c.e(this, new C0091k0(0, new Z(this, 2)));
                        BuildersKt__Builders_commonKt.launch$default(V.e(this), Dispatchers.getMain(), null, new C0076h0(this, bundle, null), 2, null);
                    }
                } catch (IllegalStateException e8) {
                    e = e8;
                    l2 = l22;
                }
            } catch (IllegalStateException e9) {
                e = e9;
                l2 = l22;
                c0088j2 = c0088j22;
            }
        }
        YourTVApplication yourTVApplication2 = YourTVApplication.f3892p;
        android.support.v4.media.session.b.E().f3905n = new C0035a0(this, 0);
        this.f3870O = new GestureDetector(this, new C0041b0(this, this));
        v().f1063c.e(this, new C0091k0(0, new Z(this, 2)));
        BuildersKt__Builders_commonKt.launch$default(V.e(this), Dispatchers.getMain(), null, new C0076h0(this, bundle, null), 2, null);
    }

    @Override
    public final void onDestroy() {
        super.onDestroy();
        PowerManager.WakeLock wakeLock = this.f3886e0;
        if (wakeLock != null) {
            wakeLock.release();
        }
        C0147v2 c0147v2 = this.f3871P;
        if (c0147v2 != null) {
            c0147v2.stop();
        }
        this.f3867L.removeCallbacksAndMessages(null);
        C0138t3 c0138t3 = this.f3872Q;
        if (c0138t3 != null) {
            c0138t3.f1412e.edit().remove("pending_apk_path").apply();
        } else {
            j.i("updateManager");
            throw null;
        }
    }

    @Override
    public final boolean onKeyDown(int i2, KeyEvent keyEvent) {
        ExoPlayer exoPlayer;
        TV m2;
        Object obj;
        TV m3;
        Handler handler;
        View findFocus;
        View view;
        View findFocus2;
        RecyclerView recyclerView;
        L2 l2 = this.f3866K;
        if (l2.isAdded() && l2.isVisible()) {
            if (i2 != 4) {
                if (i2 != 66) {
                    if (i2 != 111) {
                        switch (i2) {
                            case 19:
                            case 20:
                                View view2 = l2.getView();
                                RecyclerView recyclerView2 = view2 != null ? (RecyclerView) view2.findViewById(2131362158) : null;
                                if (recyclerView2 != null && (findFocus2 = recyclerView2.findFocus()) != null) {
                                    recyclerView2 = findFocus2;
                                }
                                if (recyclerView2 != null) {
                                    view = recyclerView2.focusSearch(i2 == 19 ? 33 : 130);
                                } else {
                                    view = null;
                                }
                                if (view != null) {
                                    view.requestFocus();
                                    return true;
                                }
                                break;
                            case 21:
                            case 22:
                                break;
                            case 23:
                                break;
                            default:
                                View view3 = l2.getView();
                                if (view3 != null && (recyclerView = (RecyclerView) view3.findViewById(2131362158)) != null) {
                                    recyclerView.dispatchKeyEvent(new KeyEvent(0, i2));
                                    return true;
                                }
                                break;
                        }
                    }
                }
                View view4 = l2.getView();
                if (view4 != null && (findFocus = view4.findFocus()) != null) {
                    findFocus.performClick();
                    return true;
                }
            }
            l2.i();
            return true;
        }
        s sVar = new s();
        H D2 = p().D("PlayerFragment");
        G1 g12 = D2 instanceof G1 ? (G1) D2 : null;
        sVar.f5165a = g12;
        if (g12 != null) {
            g12.isAdded();
        }
        G1 g13 = (G1) sVar.f5165a;
        if (g13 != null) {
            g13.isVisible();
        }
        x();
        if (sVar.f5165a == null && this.f3857B.isAdded()) {
            sVar.f5165a = this.f3857B;
        } else if (sVar.f5165a == null) {
            try {
                h0 p2 = p();
                p2.getClass();
                C0200a c0200a = new C0200a(p2);
                c0200a.g(2131362069, this.f3857B, "PlayerFragment", 2);
                c0200a.f();
                sVar.f5165a = this.f3857B;
            } catch (IllegalStateException e2) {
                e2.getMessage();
                return false;
            }
        }
        H h2 = this.f3863H;
        if (i2 != 0) {
            H h3 = this.f3865J;
            C0046c c0046c = this.f3861F;
            H h4 = this.f3864I;
            if (i2 != 4) {
                Handler handler2 = this.f3867L;
                if (i2 != 66) {
                    if (i2 != 82) {
                        if (i2 != 111) {
                            if (i2 != 174 && i2 != 176 && i2 != 259) {
                                if (i2 != 166) {
                                    if (i2 != 167) {
                                        switch (i2) {
                                            case 7:
                                            case 8:
                                            case 9:
                                            case 10:
                                            case 11:
                                            case 12:
                                            case 13:
                                            case 14:
                                            case 15:
                                            case 16:
                                                int i3 = i2 - 7;
                                                if (h2.isHidden() && !h4.isVisible()) {
                                                    C0054d1 c0054d1 = c0046c.f1025f;
                                                    if (c0054d1 == null) {
                                                        j.i("viewModel");
                                                        throw null;
                                                    }
                                                    i f2 = c0054d1.f1068h.f();
                                                    j.b(f2);
                                                    TV m4 = f2.m();
                                                    if (m4.i() > 10 && m4.i() == c0046c.f1023d - 1) {
                                                        c0046c.f1023d = 0;
                                                        c0046c.f1024e = 0;
                                                    }
                                                    int i4 = c0046c.f1024e;
                                                    if (i4 <= 2) {
                                                        c0046c.f1024e = i4 + 1;
                                                        int i5 = c0046c.f1023d;
                                                        StringBuilder sb = new StringBuilder();
                                                        sb.append(i5);
                                                        sb.append(i3);
                                                        c0046c.f1023d = Integer.parseInt(sb.toString());
                                                        Handler handler3 = c0046c.f1021b;
                                                        handler3.removeCallbacks(c0046c.f1026g);
                                                        RunnableC0040b runnableC0040b = c0046c.f1027h;
                                                        handler3.removeCallbacks(runnableC0040b);
                                                        ChannelBinding channelBinding = c0046c.f1020a;
                                                        j.b(channelBinding);
                                                        channelBinding.content.setText(String.valueOf(c0046c.f1023d));
                                                        View view5 = c0046c.getView();
                                                        if (view5 != null) {
                                                            view5.setVisibility(0);
                                                        }
                                                        if (c0046c.f1024e < 3) {
                                                            handler3.postDelayed(runnableC0040b, c0046c.f1022c);
                                                            return true;
                                                        }
                                                        handler3.postDelayed(runnableC0040b, 0L);
                                                        return true;
                                                    }
                                                }
                                                break;
                                            default:
                                                switch (i2) {
                                                    case 19:
                                                        if ((!h2.isAdded() || h2.isHidden()) && (!h4.isAdded() || h4.isHidden())) {
                                                            Object obj2 = sVar.f5165a;
                                                            if (obj2 != null && ((G1) obj2).isVisible()) {
                                                                t();
                                                                return true;
                                                            }
                                                        }
                                                        break;
                                                    case 21:
                                                        if (!h4.isAdded() || h4.isHidden()) {
                                                            E();
                                                            return true;
                                                        }
                                                        break;
                                                    case 22:
                                                        if ((!h2.isAdded() || h2.isHidden()) && ((!h4.isAdded() || h4.isHidden()) && (!h3.isAdded() || h3.isHidden()))) {
                                                            long currentTimeMillis = System.currentTimeMillis();
                                                            long j2 = currentTimeMillis - this.f3875T;
                                                            RunnableC0106n0 runnableC0106n0 = this.f3881Z;
                                                            if (j2 <= 400) {
                                                                int i6 = this.f3874S + 1;
                                                                this.f3874S = i6;
                                                                if (i6 >= 4) {
                                                                    F();
                                                                    this.f3874S = 0;
                                                                    handler2.removeCallbacks(runnableC0106n0);
                                                                    return true;
                                                                }
                                                                handler = handler2;
                                                            } else {
                                                                handler = handler2;
                                                                this.f3874S = 1;
                                                            }
                                                            this.f3875T = currentTimeMillis;
                                                            handler.removeCallbacks(runnableC0106n0);
                                                            handler.postDelayed(runnableC0106n0, 600L);
                                                            return true;
                                                        }
                                                        break;
                                                }
                                        }
                                    }
                                    if ((!h2.isAdded() || h2.isHidden()) && (!h4.isAdded() || h4.isHidden())) {
                                        if ((!h3.isAdded() || h3.isHidden()) && ((!h2.isAdded() || h2.isHidden()) && (!h4.isAdded() || h4.isHidden()))) {
                                            if (N1.c()) {
                                                A();
                                                return true;
                                            }
                                            z();
                                            return true;
                                        }
                                    }
                                } else if ((!h2.isAdded() || h2.isHidden()) && (!h4.isAdded() || h4.isHidden())) {
                                    t();
                                    return true;
                                }
                                return false;
                            }
                        }
                    }
                }
                if (c0046c.isAdded() && c0046c.isVisible()) {
                    c0046c.f1021b.postDelayed(c0046c.f1027h, 0L);
                    return true;
                }
                long currentTimeMillis2 = System.currentTimeMillis();
                long j3 = currentTimeMillis2 - this.f3875T;
                RunnableC0106n0 runnableC0106n02 = this.f3882a0;
                if (j3 <= 400) {
                    int i7 = this.f3874S + 1;
                    this.f3874S = i7;
                    if (i7 == 2 && (obj = sVar.f5165a) != null && ((G1) obj).isAdded() && ((G1) sVar.f5165a).isVisible() && !x() && N1.l()) {
                        G1 g14 = (G1) sVar.f5165a;
                        if (!g14.f651e) {
                            i iVar = g14.f650d;
                            if (((iVar == null || (m3 = iVar.m()) == null) ? null : m3.d()) == H0.b.IPTV && ((h2.isHidden() || !h2.isAdded()) && ((h4.isHidden() || !h4.isAdded()) && (l2.isHidden() || !l2.isAdded())))) {
                                handler2.postDelayed(new k(2, this, sVar), 400L);
                            }
                        }
                    }
                    if (this.f3874S >= 4) {
                        D(l2);
                        this.f3874S = 0;
                        handler2.removeCallbacks(runnableC0106n02);
                        return true;
                    }
                } else {
                    this.f3874S = 1;
                }
                this.f3875T = currentTimeMillis2;
                G1 g15 = (G1) sVar.f5165a;
                boolean z2 = g15.f639E;
                boolean z3 = g15.f636B;
                if (!z2 || !z3) {
                    handler2.removeCallbacks(runnableC0106n02);
                    handler2.postDelayed(runnableC0106n02, 600L);
                    return true;
                }
                i iVar2 = g15.f650d;
                if (((iVar2 == null || (m2 = iVar2.m()) == null) ? null : m2.d()) == H0.b.IPTV && (exoPlayer = g15.f649c) != null) {
                    long duration = exoPlayer.getDuration();
                    if (duration > 0 && duration != androidx.media3.common.C.TIME_UNSET) {
                        if (i2 != 166 && i2 != 167) {
                            long j4 = g15.f638D;
                            switch (i2) {
                                case 21:
                                    ExoPlayer exoPlayer2 = g15.f649c;
                                    j.b(exoPlayer2);
                                    long currentPosition = exoPlayer2.getCurrentPosition() - j4;
                                    long j5 = currentPosition < 0 ? 0L : currentPosition;
                                    ExoPlayer exoPlayer3 = g15.f649c;
                                    j.b(exoPlayer3);
                                    exoPlayer3.seekTo(j5);
                                    g15.q();
                                    return true;
                                case 22:
                                    ExoPlayer exoPlayer4 = g15.f649c;
                                    j.b(exoPlayer4);
                                    long currentPosition2 = exoPlayer4.getCurrentPosition() + j4;
                                    if (currentPosition2 <= duration) {
                                        duration = currentPosition2;
                                    }
                                    ExoPlayer exoPlayer5 = g15.f649c;
                                    j.b(exoPlayer5);
                                    exoPlayer5.seekTo(duration);
                                    g15.q();
                                    return true;
                            }
                        }
                        g15.i();
                        g15.f639E = false;
                        PlayerBinding playerBinding = g15.f648b;
                        j.b(playerBinding);
                        playerBinding.playerView.requestFocus();
                        return true;
                    }
                }
                return false;
            }
            H h5 = this.f3858C;
            if (!h5.isAdded() || h5.isHidden()) {
                if (h2.isAdded() && !h2.isHidden()) {
                    w(h2);
                    return true;
                }
                if (h4.isAdded() && !h4.isHidden()) {
                    w(h4);
                    G();
                    return true;
                }
                if (h3.isAdded() && !h3.isHidden()) {
                    w(h3);
                    return true;
                }
                if (c0046c.isAdded() && c0046c.isVisible()) {
                    c0046c.f1023d = 0;
                    c0046c.f1024e = 0;
                    c0046c.f1021b.postDelayed(c0046c.f1026g, 0L);
                    return true;
                }
                if (l2.isAdded() && l2.isVisible()) {
                    l2.i();
                    return true;
                }
                G1 g16 = (G1) sVar.f5165a;
                if (g16.f636B) {
                    g16.i();
                    PlayerBinding playerBinding2 = ((G1) sVar.f5165a).f648b;
                    PlayerView playerView = playerBinding2 != null ? playerBinding2.playerView : null;
                    if (playerView != null) {
                        playerView.requestFocus();
                    }
                    ((G1) sVar.f5165a).f639E = false;
                    return true;
                }
                long currentTimeMillis3 = System.currentTimeMillis();
                if (currentTimeMillis3 - this.f3879X < this.f3880Y) {
                    finishAffinity();
                    return true;
                }
                this.f3879X = currentTimeMillis3;
                b.Q(2131820751);
                return true;
            }
            w(h5);
            H C2 = p().C(2131362069);
            H h6 = C2 instanceof G1 ? (G1) C2 : null;
            if (h6 != null) {
                D(h6);
            }
        }
        if (!h2.isAdded() || h2.isHidden()) {
            long currentTimeMillis4 = System.currentTimeMillis();
            if (currentTimeMillis4 - this.f3875T <= this.f3876U) {
                int i8 = this.f3874S + 1;
                this.f3874S = i8;
                if (i8 >= this.f3878W) {
                    F();
                    this.f3874S = 0;
                    return true;
                }
            } else {
                this.f3874S = 1;
            }
            this.f3875T = currentTimeMillis4;
            return true;
        }
        return false;
        return true;
    }

    @Override
    public final void onPause() {
        super.onPause();
        this.f3885d0 = false;
    }

    @Override
    public final void onPictureInPictureModeChanged(boolean z2, Configuration newConfig) {
        j.e(newConfig, "newConfig");
        super.onPictureInPictureModeChanged(z2, newConfig);
        int i2 = Build.VERSION.SDK_INT;
        C0046c c0046c = this.f3861F;
        if (i2 >= 26 && z2) {
            w(this.f3863H);
            w(this.f3864I);
            w(this.f3865J);
            w(c0046c);
            w(this.f3860E);
            w(this.f3862G);
            w(this.f3858C);
            w(this.f3859D);
            w(this.f3866K);
            if (this.f3857B.isAdded()) {
                this.f3857B.g();
            }
            D(this.f3857B);
            return;
        }
        D(this.f3857B);
        if (this.f3857B.isAdded()) {
            G1 g12 = this.f3857B;
            if (i2 < 26) {
                g12.getClass();
            } else if (g12.f648b != null) {
                boolean z3 = false;
                g12.f651e = false;
                if (g12.j() && N1.m()) {
                    z3 = true;
                }
                g12.o(z3);
                g12.k();
                PlayerBinding playerBinding = g12.f648b;
                j.b(playerBinding);
                Button btnSource = playerBinding.btnSource;
                j.d(btnSource, "btnSource");
                btnSource.getVisibility();
            }
        }
        View findViewById = findViewById(2131362069);
        if (findViewById != null) {
            findViewById.requestFocus();
        }
        G();
        if (!N1.b() || v().f1068h.f() == null) {
            return;
        }
        i f2 = v().f1068h.f();
        j.b(f2);
        c0046c.g(f2);
    }

    @Override
    public final void onResume() {
        super.onResume();
        this.f3885d0 = true;
        G();
    }

    @Override
    public final void onStop() {
        TV m2;
        boolean isInPictureInPictureMode;
        super.onStop();
        if (this.f3857B.isAdded()) {
            Object systemService = getSystemService("power");
            j.c(systemService, "null cannot be cast to non-null type android.os.PowerManager");
            PowerManager powerManager = (PowerManager) systemService;
            if (N1.f()) {
                if (!powerManager.isInteractive() || Build.VERSION.SDK_INT < 26) {
                    return;
                }
                isInPictureInPictureMode = isInPictureInPictureMode();
                if (!isInPictureInPictureMode) {
                    return;
                }
            }
            i iVar = this.f3857B.f650d;
            if (((iVar == null || (m2 = iVar.m()) == null) ? null : m2.d()) == H0.b.WEBVIEW) {
                H C2 = p().C(2131362267);
                if (C2 != null && (C2 instanceof w4)) {
                    ((w4) C2).n();
                }
            } else {
                ExoPlayer exoPlayer = this.f3857B.f649c;
                if (exoPlayer != null) {
                    exoPlayer.stop();
                }
                ExoPlayer exoPlayer2 = this.f3857B.f649c;
                if (exoPlayer2 != null) {
                    exoPlayer2.release();
                }
                this.f3857B.f649c = null;
            }
            Process.killProcess(Process.myPid());
        }
    }

    @Override
    public final boolean onTouchEvent(MotionEvent motionEvent) {
        if (motionEvent != null && this.f3863H.isVisible()) {
            return super.onTouchEvent(motionEvent);
        }
        if (motionEvent == null) {
            return super.onTouchEvent(motionEvent);
        }
        View view = this.f3857B.getView();
        View findViewById = view != null ? view.findViewById(2131361891) : null;
        if (findViewById != null && findViewById.getVisibility() == 0) {
            Rect rect = new Rect();
            findViewById.getGlobalVisibleRect(rect);
            if (rect.contains((int) motionEvent.getRawX(), (int) motionEvent.getRawY())) {
                return false;
            }
        }
        GestureDetector gestureDetector = this.f3870O;
        if (gestureDetector != null) {
            gestureDetector.onTouchEvent(motionEvent);
            return true;
        }
        j.i("gestureDetector");
        throw null;
    }

    @Override
    public final void onUserLeaveHint() {
        if (Build.VERSION.SDK_INT < 26 || !x() || !this.f3857B.isAdded() || this.f3857B.isHidden()) {
            super.onUserLeaveHint();
        } else {
            this.f3857B.g();
        }
    }

    public final void t() {
        K1 k1 = this.f3865J;
        if (!k1.isAdded() || k1.isHidden()) {
            C0131s1 c0131s1 = this.f3863H;
            if (!c0131s1.isAdded() || c0131s1.isHidden()) {
                C0088j2 c0088j2 = this.f3864I;
                if (!c0088j2.isAdded() || c0088j2.isHidden()) {
                    if (N1.c()) {
                        z();
                    } else {
                        A();
                    }
                }
            }
        }
    }

    public final SharedPreferences u() {
        return (SharedPreferences) this.f3873R.a();
    }

    public final C0054d1 v() {
        C0054d1 c0054d1 = this.f3884c0;
        if (c0054d1 != null) {
            return c0054d1;
        }
        j.i("viewModel");
        throw null;
    }

    public final void w(H h2) {
        if (this.f3885d0 && h2.isAdded() && !h2.isHidden()) {
            h0 p2 = p();
            p2.getClass();
            C0200a c0200a = new C0200a(p2);
            c0200a.i(h2);
            try {
                c0200a.f();
            } catch (IllegalStateException unused) {
                c0200a.d();
            }
        }
    }

    public final boolean x() {
        PackageManager packageManager = getPackageManager();
        Object systemService = getSystemService("uimode");
        UiModeManager uiModeManager = systemService instanceof UiModeManager ? (UiModeManager) systemService : null;
        return packageManager.hasSystemFeature("android.hardware.touchscreen") && !(uiModeManager != null && uiModeManager.getCurrentModeType() == 4);
    }

    public final void y() {
        Handler handler = this.f3867L;
        RunnableC0106n0 runnableC0106n0 = this.f3889h0;
        handler.removeCallbacks(runnableC0106n0);
        handler.postDelayed(runnableC0106n0, this.f3868M);
    }

    public final void z() {
        int i2 = v().f1068h.i();
        i h2 = (N1.e() && v().f1068h.f1563c && v().f1068h.k(0) != null) ? v().f1068h.h(true) : v().f1068h.h(false);
        if (h2 != null) {
            h2.v(false);
        }
        v().f1068h.p();
        f g2 = v().f1068h.g();
        if (g2 != null) {
            g2.m(g2.h());
        }
        int i3 = v().f1068h.i();
        if (i3 != i2) {
            this.f3863H.m(i3);
        }
    }
}