package xyz.netfly.ui.main;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import androidx.activity.result.d;
import androidx.fragment.app.a;
import androidx.fragment.app.d1;
import androidx.fragment.app.e0;
import gf.b;
import hf.c;
import ie.o;
import java.util.Objects;
import kotlinx.coroutines.y;
import mf.q;
import org.drive_hunter.R;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import pe.g;
import xyz.netfly.ui.dashboard.DashboardActivity;
import xyz.netfly.ui.live.tv.LiveActivity;
import xyz.netfly.ui.login.LoginActivity;
import xyz.netfly.ui.search.SearchTvActivity;
import xyz.stream.utils.e;
import xyz.stream.utils.event.CheckEvent;
import xyz.stream.utils.event.ParentalLockEvent;
import xyz.stream.view.BaseActivity;
import xyz.stream.view.BaseFragment;
import xyz.stream.view.BaseViewModel;
import xyz.stream.view.UiUtils;
import xyz.stream.view.listener.OnFragmentSendDataListener;

/* JADX INFO: loaded from: classes3.dex */
public class MainTvActivity extends BaseActivity<BaseViewModel, o> implements View.OnKeyListener, View.OnClickListener, View.OnFocusChangeListener, OnFragmentSendDataListener {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final /* synthetic */ int f35524e = 0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public String f35525b = "menu_dashboard";

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public String f35526c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public d f35527d;

    public static void M(DashboardActivity dashboardActivity, String str) {
        Intent intent = new Intent(dashboardActivity, (Class<?>) MainTvActivity.class);
        intent.putExtra("mainTvMenu", str);
        dashboardActivity.startActivity(intent);
    }

    public final void K() {
        d1 supportFragmentManager = getSupportFragmentManager();
        if (Objects.equals(this.f35526c, this.f35525b)) {
            BaseFragment baseFragment = (BaseFragment) supportFragmentManager.findFragmentByTag(this.f35525b);
            if (baseFragment == null) {
                return;
            }
            baseFragment.refreshData();
            return;
        }
        if (isFinishing() || isDestroyed()) {
            return;
        }
        String str = this.f35526c;
        if (str != null) {
            P(str, false);
        }
        String str2 = this.f35525b;
        this.f35526c = str2;
        if (Objects.equals(str2, "menu_sports") || Objects.equals(this.f35525b, "menu_18_plus")) {
            ((o) this.binding).f27276c.setPadding(0, 60, 0, 0);
        } else {
            ((o) this.binding).f27276c.setPadding(0, 0, 0, 0);
        }
        supportFragmentManager.getClass();
        a aVar = new a(supportFragmentManager);
        for (e0 e0Var : supportFragmentManager.f2368c.d()) {
            if (e0Var != null && e0Var.isAdded()) {
                aVar.k(e0Var);
            }
        }
        e0 aVar2 = (BaseFragment) supportFragmentManager.findFragmentByTag(this.f35525b);
        boolean zI = supportFragmentManager.I();
        if (aVar2 != null) {
            aVar.l(aVar2);
        } else {
            String str3 = this.f35525b;
            str3.getClass();
            switch (str3) {
                case "menu_help":
                    aVar2 = new df.a();
                    break;
                case "menu_iptv":
                    aVar2 = new g();
                    break;
                case "menu_kids":
                    aVar2 = new c();
                    break;
                case "menu_18_plus":
                    aVar2 = new b();
                    break;
                case "menu_movie":
                    aVar2 = new ff.d();
                    Bundle bundle = new Bundle();
                    bundle.putInt("categoryType", 2);
                    aVar2.setArguments(bundle);
                    break;
                case "menu_series":
                    aVar2 = new ff.d();
                    Bundle bundle2 = new Bundle();
                    bundle2.putInt("categoryType", 3);
                    aVar2.setArguments(bundle2);
                    break;
                case "menu_sports":
                    aVar2 = new q();
                    break;
            }
            if (aVar2 == null) {
                return;
            } else {
                aVar.add(((o) this.binding).f27276c.getId(), aVar2, this.f35525b);
            }
        }
        if (zI) {
            aVar.i(true);
        } else {
            aVar.i(false);
        }
        new Handler().postDelayed(new af.d(this, 0), 300L);
    }

    public final void L() {
        if (((o) this.binding).f27275b.getVisibility() == 0) {
            ((o) this.binding).f27275b.setVisibility(8);
            e.d().getClass();
            if (e.e().equals("ar")) {
                y.W(((o) this.binding).f27287n);
            } else {
                y.N(((o) this.binding).f27287n);
            }
        }
    }

    public final void N(View view) {
        L();
        boolean zH = e.h();
        if (view.getId() == ((o) this.binding).f27278e.getId()) {
            finish();
        } else if (view.getId() == ((o) this.binding).f27284k.getId()) {
            Intent intent = new Intent(this, (Class<?>) SearchTvActivity.class);
            intent.addFlags(268435456);
            startActivity(intent);
        } else if (view.getId() == ((o) this.binding).f27282i.getId()) {
            if (!zH) {
                this.f35526c = "menu_live";
                this.f35527d.launch(new Intent(this, (Class<?>) LoginActivity.class), null);
                return;
            }
            LiveActivity.T(this);
        } else if (view.getId() == ((o) this.binding).f27280g.getId()) {
            if (!zH) {
                this.f35526c = "menu_iptv";
                this.f35527d.launch(new Intent(this, (Class<?>) LoginActivity.class), null);
                return;
            }
            this.f35525b = "menu_iptv";
        } else if (view.getId() == ((o) this.binding).f27286m.getId()) {
            this.f35525b = "menu_sports";
        } else if (view.getId() == ((o) this.binding).f27283j.getId()) {
            this.f35525b = "menu_movie";
        } else if (view.getId() == ((o) this.binding).f27285l.getId()) {
            this.f35525b = "menu_series";
        } else if (view.getId() == ((o) this.binding).f27281h.getId()) {
            this.f35525b = "menu_kids";
        } else if (view.getId() == ((o) this.binding).f27277d.getId()) {
            this.f35525b = "menu_18_plus";
        } else if (view.getId() == ((o) this.binding).f27279f.getId()) {
            this.f35525b = "menu_help";
        }
        K();
    }

    public final void O() {
        BaseFragment baseFragment = (BaseFragment) getSupportFragmentManager().findFragmentByTag(this.f35525b);
        if (baseFragment == null) {
            return;
        }
        baseFragment.focus();
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    public final void P(String str, boolean z10) {
        str.getClass();
        byte b10 = -1;
        switch (str.hashCode()) {
            case -1527122399:
                if (str.equals("menu_help")) {
                    b10 = 0;
                }
                break;
            case -1527081783:
                if (str.equals("menu_iptv")) {
                    b10 = 1;
                }
                break;
            case -1527029427:
                if (str.equals("menu_kids")) {
                    b10 = 2;
                }
                break;
            case -1526999092:
                if (str.equals("menu_live")) {
                    b10 = 3;
                }
                break;
            case -783094318:
                if (str.equals("menu_18_plus")) {
                    b10 = 4;
                }
                break;
            case -91229104:
                if (str.equals("menu_movie")) {
                    b10 = 5;
                }
                break;
            case 147263412:
                if (str.equals("menu_dashboard")) {
                    b10 = 6;
                }
                break;
            case 1628787848:
                if (str.equals("menu_search")) {
                    b10 = 7;
                }
                break;
            case 1629285719:
                if (str.equals("menu_series")) {
                    b10 = 8;
                }
                break;
            case 1639364191:
                if (str.equals("menu_sports")) {
                    b10 = 9;
                }
                break;
        }
        Integer numValueOf = null;
        switch (b10) {
            case 0:
                ImageView imageView = ((o) this.binding).f27279f;
                if (z10) {
                    numValueOf = Integer.valueOf(R.color.white);
                } else if (Objects.equals(this.f35525b, "menu_help")) {
                    numValueOf = Integer.valueOf(R.color.main_color);
                }
                UiUtils.setSvgPicture(imageView, R.drawable.ic_main_help, numValueOf);
                break;
            case 1:
                ImageView imageView2 = ((o) this.binding).f27280g;
                if (z10) {
                    numValueOf = Integer.valueOf(R.color.white);
                } else if (Objects.equals(this.f35525b, "menu_iptv")) {
                    numValueOf = Integer.valueOf(R.color.main_color);
                }
                UiUtils.setSvgPicture(imageView2, R.drawable.ic_main_iptv, numValueOf);
                break;
            case 2:
                ImageView imageView3 = ((o) this.binding).f27281h;
                if (z10) {
                    numValueOf = Integer.valueOf(R.color.white);
                } else if (Objects.equals(this.f35525b, "menu_kids")) {
                    numValueOf = Integer.valueOf(R.color.main_color);
                }
                UiUtils.setSvgPicture(imageView3, R.drawable.ic_main_kid, numValueOf);
                break;
            case 3:
                ImageView imageView4 = ((o) this.binding).f27282i;
                if (z10) {
                    numValueOf = Integer.valueOf(R.color.white);
                } else if (Objects.equals(this.f35525b, "menu_live")) {
                    numValueOf = Integer.valueOf(R.color.main_color);
                }
                UiUtils.setSvgPicture(imageView4, R.drawable.ic_main_live, numValueOf);
                break;
            case 4:
                ImageView imageView5 = ((o) this.binding).f27277d;
                if (z10) {
                    numValueOf = Integer.valueOf(R.color.white);
                } else if (Objects.equals(this.f35525b, "menu_18_plus")) {
                    numValueOf = Integer.valueOf(R.color.main_color);
                }
                UiUtils.setSvgPicture(imageView5, R.drawable.ic_main_18, numValueOf);
                break;
            case 5:
                ImageView imageView6 = ((o) this.binding).f27283j;
                if (z10) {
                    numValueOf = Integer.valueOf(R.color.white);
                } else if (Objects.equals(this.f35525b, "menu_movie")) {
                    numValueOf = Integer.valueOf(R.color.main_color);
                }
                UiUtils.setSvgPicture(imageView6, R.drawable.ic_main_movie, numValueOf);
                break;
            case 6:
                ImageView imageView7 = ((o) this.binding).f27278e;
                if (z10) {
                    numValueOf = Integer.valueOf(R.color.white);
                } else if (Objects.equals(this.f35525b, "menu_dashboard")) {
                    numValueOf = Integer.valueOf(R.color.main_color);
                }
                UiUtils.setSvgPicture(imageView7, R.drawable.ic_main_dashboard, numValueOf);
                break;
            case 7:
                ImageView imageView8 = ((o) this.binding).f27284k;
                if (z10) {
                    numValueOf = Integer.valueOf(R.color.white);
                } else if (Objects.equals(this.f35525b, "menu_search")) {
                    numValueOf = Integer.valueOf(R.color.main_color);
                }
                UiUtils.setSvgPicture(imageView8, R.drawable.ic_main_search, numValueOf);
                break;
            case 8:
                ImageView imageView9 = ((o) this.binding).f27285l;
                if (z10) {
                    numValueOf = Integer.valueOf(R.color.white);
                } else if (Objects.equals(this.f35525b, "menu_series")) {
                    numValueOf = Integer.valueOf(R.color.main_color);
                }
                UiUtils.setSvgPicture(imageView9, R.drawable.ic_main_tv, numValueOf);
                break;
            case 9:
                ImageView imageView10 = ((o) this.binding).f27286m;
                if (z10) {
                    numValueOf = Integer.valueOf(R.color.white);
                } else if (Objects.equals(this.f35525b, "menu_sports")) {
                    numValueOf = Integer.valueOf(R.color.main_color);
                }
                UiUtils.setSvgPicture(imageView10, R.drawable.ic_main_sport, numValueOf);
                break;
        }
    }

    @Override // xyz.stream.view.BaseActivity
    public final v3.a getViewBinding() {
        return o.inflate(getLayoutInflater(), null, false);
    }

    @Override // xyz.stream.view.BaseActivity
    public final void initListener() {
        super.initListener();
        ((o) this.binding).f27278e.setOnKeyListener(this);
        ((o) this.binding).f27284k.setOnKeyListener(this);
        ((o) this.binding).f27282i.setOnKeyListener(this);
        ((o) this.binding).f27286m.setOnKeyListener(this);
        ((o) this.binding).f27283j.setOnKeyListener(this);
        ((o) this.binding).f27285l.setOnKeyListener(this);
        ((o) this.binding).f27281h.setOnKeyListener(this);
        ((o) this.binding).f27277d.setOnKeyListener(this);
        ((o) this.binding).f27280g.setOnKeyListener(this);
        ((o) this.binding).f27279f.setOnKeyListener(this);
        ((o) this.binding).f27278e.setOnClickListener(this);
        ((o) this.binding).f27284k.setOnClickListener(this);
        ((o) this.binding).f27282i.setOnClickListener(this);
        ((o) this.binding).f27286m.setOnClickListener(this);
        ((o) this.binding).f27283j.setOnClickListener(this);
        ((o) this.binding).f27285l.setOnClickListener(this);
        ((o) this.binding).f27281h.setOnClickListener(this);
        ((o) this.binding).f27277d.setOnClickListener(this);
        ((o) this.binding).f27280g.setOnClickListener(this);
        ((o) this.binding).f27279f.setOnClickListener(this);
        ((o) this.binding).f27278e.setOnFocusChangeListener(this);
        ((o) this.binding).f27284k.setOnFocusChangeListener(this);
        ((o) this.binding).f27282i.setOnFocusChangeListener(this);
        ((o) this.binding).f27286m.setOnFocusChangeListener(this);
        ((o) this.binding).f27283j.setOnFocusChangeListener(this);
        ((o) this.binding).f27285l.setOnFocusChangeListener(this);
        ((o) this.binding).f27281h.setOnFocusChangeListener(this);
        ((o) this.binding).f27277d.setOnFocusChangeListener(this);
        ((o) this.binding).f27280g.setOnFocusChangeListener(this);
        ((o) this.binding).f27279f.setOnFocusChangeListener(this);
    }

    @Override // xyz.stream.view.BaseActivity
    public final void initView() {
        if (e.d().f36116e) {
            ((o) this.binding).f27277d.setVisibility(0);
            ((o) this.binding).f27292s.setVisibility(0);
        } else {
            ((o) this.binding).f27277d.setVisibility(8);
            ((o) this.binding).f27292s.setVisibility(8);
        }
        this.f35525b = getIntent() != null ? getIntent().getStringExtra("mainTvMenu") : "menu_movie";
        K();
        P(this.f35525b, false);
        new Handler(Looper.getMainLooper()).postDelayed(new af.d(this, 11), 300L);
    }

    @Override // xyz.stream.view.listener.OnFragmentSendDataListener
    public final void onActivityFocus() {
        String str = this.f35525b;
        str.getClass();
        switch (str) {
            case "menu_help":
                ((o) this.binding).f27279f.post(new af.d(this, 10));
                break;
            case "menu_iptv":
                ((o) this.binding).f27280g.post(new af.d(this, 9));
                break;
            case "menu_kids":
                ((o) this.binding).f27281h.post(new af.d(this, 7));
                break;
            case "menu_live":
                ((o) this.binding).f27282i.post(new af.d(this, 3));
                break;
            case "menu_18_plus":
                ((o) this.binding).f27277d.post(new af.d(this, 8));
                break;
            case "menu_movie":
                ((o) this.binding).f27283j.post(new af.d(this, 5));
                break;
            case "menu_dashboard":
                ((o) this.binding).f27278e.post(new af.d(this, 1));
                break;
            case "menu_search":
                ((o) this.binding).f27284k.post(new af.d(this, 2));
                break;
            case "menu_series":
                ((o) this.binding).f27285l.post(new af.d(this, 6));
                break;
            case "menu_sports":
                ((o) this.binding).f27286m.post(new af.d(this, 4));
                break;
        }
    }

    @Override // xyz.stream.view.listener.OnFragmentSendDataListener
    public final void onBgChange(int i10) {
    }

    @Override // android.view.View.OnClickListener
    public void onClick(View view) {
        N(view);
    }

    @Override // android.view.View.OnFocusChangeListener
    public final void onFocusChange(View view, boolean z10) {
        if (z10 && ((o) this.binding).f27275b.getVisibility() == 8) {
            ((o) this.binding).f27275b.setVisibility(0);
            e.d().getClass();
            if (e.e().equals("ar")) {
                y.V(((o) this.binding).f27287n, null);
            } else {
                y.M(((o) this.binding).f27287n, null);
            }
        }
        switch (view.getId()) {
            case R.id.iv_18plus /* 2131362259 */:
                P("menu_18_plus", z10);
                break;
            case R.id.iv_dashboard /* 2131362278 */:
                P("menu_dashboard", z10);
                break;
            case R.id.iv_help /* 2131362293 */:
                P("menu_help", z10);
                break;
            case R.id.iv_iptv /* 2131362297 */:
                P("menu_iptv", z10);
                break;
            case R.id.iv_kids /* 2131362299 */:
                P("menu_kids", z10);
                break;
            case R.id.iv_live /* 2131362309 */:
                P("menu_live", z10);
                break;
            case R.id.iv_movie /* 2131362322 */:
                P("menu_movie", z10);
                break;
            case R.id.iv_search /* 2131362345 */:
                P("menu_search", z10);
                break;
            case R.id.iv_series /* 2131362352 */:
                P("menu_series", z10);
                break;
            case R.id.iv_sports /* 2131362361 */:
                P("menu_sports", z10);
                break;
        }
    }

    @Override // xyz.stream.view.BaseActivity
    public final void onInit() {
        super.onInit();
        this.f35527d = registerForActivityResult(new b.c(), new com.google.gson.internal.a(this, 20));
    }

    @Override // android.view.View.OnKeyListener
    public final boolean onKey(View view, int i10, KeyEvent keyEvent) {
        if (i10 == 19 && keyEvent.getAction() == 0 && view.getId() == ((o) this.binding).f27278e.getId()) {
            return true;
        }
        if (i10 == 20 && keyEvent.getAction() == 0 && view.getId() == ((o) this.binding).f27279f.getId()) {
            return true;
        }
        if (i10 == 23 && keyEvent.getAction() == 0) {
            N(view);
            return true;
        }
        if (!UiUtils.isDpadRight(i10) || keyEvent.getAction() != 0) {
            return false;
        }
        L();
        O();
        return true;
    }

    @Override // androidx.appcompat.app.AppCompatActivity, android.app.Activity, android.view.KeyEvent.Callback
    public final boolean onKeyDown(int i10, KeyEvent keyEvent) {
        if (i10 == 4 && keyEvent.getAction() == 0) {
            if (((o) this.binding).f27275b.getVisibility() == 0) {
                L();
                return true;
            }
            e0 e0VarFindFragmentByTag = getSupportFragmentManager().findFragmentByTag(this.f35525b);
            if ((e0VarFindFragmentByTag instanceof ff.d) && ((ff.d) e0VarFindFragmentByTag).scrollToTop()) {
                return true;
            }
        }
        return super.onKeyDown(i10, keyEvent);
    }

    @Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
    public void onMessageEvent(CheckEvent checkEvent) {
        UiUtils.dismissProgressDialog();
        fe.d.b().k(checkEvent);
        String str = this.f35526c;
        if (str != null && str.equals("menu_live")) {
            LiveActivity.T(this);
            this.f35526c = this.f35525b;
        }
    }

    @Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
    public void onMessageEvent(ParentalLockEvent parentalLockEvent) {
        if (e.d().f36116e) {
            ((o) this.binding).f27277d.setVisibility(0);
        } else {
            ((o) this.binding).f27277d.setVisibility(8);
            finish();
        }
    }
}
