package com.bytedance.adsdk.ugeno;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.adsdk.ugeno.core.duv;
import com.bytedance.adsdk.ugeno.wsy.wu;
import com.bytedance.adsdk.ugeno.yz.ajl;
import com.bytedance.adsdk.ugeno.yz.ef;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes.dex */
public class ro extends com.bytedance.adsdk.ugeno.ro.fm<com.bytedance.adsdk.ugeno.ajl.ro> implements com.bytedance.adsdk.ugeno.ajl.lb {
    private boolean anz;
    private float bp;
    private int cyr;
    private boolean eo;
    private float ex;
    private int eys;

    /* JADX INFO: renamed from: ff, reason: collision with root package name */
    private boolean f6368ff;
    private JSONArray hou;
    private int iat;

    /* JADX INFO: renamed from: kc, reason: collision with root package name */
    private float f6369kc;
    private String ky;

    /* JADX INFO: renamed from: le, reason: collision with root package name */
    private int f6370le;
    private float lsa;
    private int nn;
    private float oy;
    private boolean po;
    private String pyj;
    private float qlg;
    private int rbn;
    private boolean ucr;
    private float ug;
    private float vj;
    private float vod;
    private String wjb;
    private float xp;
    private boolean xw;
    private boolean zes;
    private float zzm;

    public ro(Context context) {
        super(context);
        this.cyr = 0;
        this.ucr = true;
        this.po = true;
        this.vod = 500.0f;
        this.lsa = -1.0f;
        this.ex = 2000.0f;
        this.wjb = "slide";
        this.ky = "dot";
        this.oy = 8.0f;
        this.f6369kc = 8.0f;
        this.ug = 50.0f;
        this.bp = 90.0f;
        this.f6368ff = false;
        this.f6370le = Color.parseColor("#666666");
        this.rbn = Color.parseColor("#ffffff");
        this.pyj = "row";
        this.xp = 1.0f;
        this.vj = 0.0f;
        this.zzm = 0.0f;
        this.qlg = 0.0f;
        this.nn = 0;
        this.eys = 0;
        this.xw = true;
        this.eo = false;
        this.zes = true;
        float fFm = wu.fm(this.ro, 8.0f);
        this.oy = fFm;
        this.f6369kc = fFm;
    }

    private int mj() {
        if (this.nn == 1) {
            List<com.bytedance.adsdk.ugeno.ro.lb<View>> list = ((com.bytedance.adsdk.ugeno.ro.fm) this).fm;
            if (list != null) {
                return list.size();
            }
            return 0;
        }
        JSONArray jSONArray = this.hou;
        if (jSONArray != null) {
            return jSONArray.length();
        }
        return 0;
    }

    private void mpp() {
        List<com.bytedance.adsdk.ugeno.ro.lb<View>> list = ((com.bytedance.adsdk.ugeno.ro.fm) this).fm;
        if (list == null || list.isEmpty()) {
            return;
        }
        com.bytedance.adsdk.ugeno.ro.lb<View> lbVar = ((com.bytedance.adsdk.ugeno.ro.fm) this).fm.get(0);
        if (this.hou == null) {
            return;
        }
        for (int i10 = 0; i10 < this.hou.length(); i10++) {
            duv duvVar = new duv(this.ro);
            fm(duvVar);
            duvVar.fm(this.jn);
            try {
                JSONObject jSONObjectOptJSONObject = this.hou.optJSONObject(i10);
                if (jSONObjectOptJSONObject != null) {
                    if (jSONObjectOptJSONObject.has("$chunk")) {
                        this.yz.put("$item", jSONObjectOptJSONObject.optJSONArray("$chunk"));
                    } else {
                        this.yz.put("$item", jSONObjectOptJSONObject);
                    }
                    ((com.bytedance.adsdk.ugeno.ajl.ro) this.jnr).fm(duvVar.fm(lbVar.ol(), this.yz, (JSONObject) null));
                }
            } catch (Throwable unused) {
            }
        }
    }

    private void vvj() {
        for (int i10 = 0; i10 < ((com.bytedance.adsdk.ugeno.ro.fm) this).fm.size(); i10++) {
            com.bytedance.adsdk.ugeno.ro.lb<View> lbVar = ((com.bytedance.adsdk.ugeno.ro.fm) this).fm.get(i10);
            if (lbVar != null) {
                duv duvVar = new duv(this.ro);
                fm(duvVar);
                duvVar.fm(this.jn);
                ((com.bytedance.adsdk.ugeno.ajl.ro) this.jnr).fm(duvVar.fm(lbVar.ol(), this.yz, (JSONObject) null));
            }
        }
    }

    private void wsy(int i10) {
        if (this.hm == null) {
            return;
        }
        if (this.iat == 0 && i10 == mj() - 1) {
            this.hm.fm("SwiperView://reloop", 1);
        }
        if (this.iat == mj() - 1 && i10 == 0) {
            this.hm.fm("SwiperView://reloop", 0);
        }
    }

    private void wu(int i10) {
        ef efVar = this.hm;
        if (efVar == null) {
            return;
        }
        efVar.fm("SwiperView://slide", Integer.valueOf(this.iat), Integer.valueOf(i10), Integer.valueOf(!this.anz ? 1 : 0));
    }

    @Override // com.bytedance.adsdk.ugeno.ajl.lb
    public void fm(boolean z10, int i10) {
        if (i10 != 0) {
            if (i10 != 1) {
                return;
            }
            this.anz = true;
        } else {
            if (!z10) {
                this.zes = true;
            }
            this.anz = false;
        }
    }

    public void lb() {
        ((com.bytedance.adsdk.ugeno.ajl.ro) this.jnr).onz(((com.bytedance.adsdk.ugeno.ajl.ro) this.jnr).getCurrentItem() + 1);
    }

    public void yz() {
        ((com.bytedance.adsdk.ugeno.ajl.ro) this.jnr).onz(((com.bytedance.adsdk.ugeno.ajl.ro) this.jnr).getCurrentItem() - 1);
    }

    @Override // com.bytedance.adsdk.ugeno.ro.fm, com.bytedance.adsdk.ugeno.ro.lb
    public void ro() {
        super.ro();
        ((com.bytedance.adsdk.ugeno.ajl.ro) this.jnr).lb((int) this.vod).jnr(this.eo).fm(this.ky).fm(this.oy).ro(this.f6369kc).lb(this.ug).yz(this.bp).ro(this.pyj).fm(this.cyr).ro().yz(this.ucr).fm(this.po).ro((int) this.vod).yz((int) this.ex).jnr((int) this.lsa).ro(this.xw).lb(this.f6368ff).wsy(this.f6370le).ajl(this.rbn).ef((int) this.zzm).vt((int) this.qlg).wu((int) this.vj).jnr(this.xp).lb(this.wjb).onz(this.eys);
        ((com.bytedance.adsdk.ugeno.ajl.ro) this.jnr).setOnPageChangeListener(this);
        if (this.nn == 1) {
            vvj();
        } else {
            mpp();
        }
        ((com.bytedance.adsdk.ugeno.ajl.ro) this.jnr).lb();
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb
    public View fm() {
        com.bytedance.adsdk.ugeno.ajl.ro roVar = new com.bytedance.adsdk.ugeno.ajl.ro(this.ro);
        this.jnr = roVar;
        roVar.fm((yz) this);
        return this.jnr;
    }

    @Override // com.bytedance.adsdk.ugeno.ro.fm
    public void fm(com.bytedance.adsdk.ugeno.ro.lb lbVar) {
        if (lbVar == null) {
            return;
        }
        ((com.bytedance.adsdk.ugeno.ro.fm) this).fm.add(lbVar);
    }

    @Override // com.bytedance.adsdk.ugeno.ro.fm
    public void fm(com.bytedance.adsdk.ugeno.ro.lb lbVar, ViewGroup.LayoutParams layoutParams) {
        if (lbVar == null) {
            return;
        }
        ((com.bytedance.adsdk.ugeno.ro.fm) this).fm.add(lbVar);
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb
    public void fm(String str, String str2) {
        super.fm(str, str2);
        if (TextUtils.isEmpty(str)) {
        }
        str.getClass();
        switch (str) {
            case "startDelay":
                this.lsa = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, -1.0f);
                break;
            case "startIndex":
                this.eys = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0);
                break;
            case "indicatorColor":
                this.f6370le = com.bytedance.adsdk.ugeno.wsy.fm.fm(str2, this.f6370le);
                break;
            case "indicatorStyle":
                this.ky = str2;
                break;
            case "indicatorWidth":
                this.oy = wu.fm(this.ro, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 8.0f));
                break;
            case "indicatorHeight":
                this.f6369kc = wu.fm(this.ro, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 8.0f));
                break;
            case "nextMargin":
                this.qlg = wu.fm(this.ro, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f));
                break;
            case "driveMode":
                this.nn = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0);
                break;
            case "effect":
                this.wjb = str2;
                break;
            case "direction":
                if (!TextUtils.equals(str2, "vertical")) {
                    this.cyr = 0;
                    break;
                } else {
                    this.cyr = 1;
                    break;
                }
                break;
            case "disableOnInteraction":
                this.eo = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, false);
                break;
            case "indicator":
                this.f6368ff = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, false);
                break;
            case "indicatorX":
                this.ug = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 50.0f);
                break;
            case "indicatorY":
                this.bp = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 90.0f);
                break;
            case "previousMargin":
                this.zzm = wu.fm(this.ro, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f));
                break;
            case "loop":
                this.ucr = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, true);
                break;
            case "delay":
                this.ex = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 2000.0f);
                break;
            case "speed":
                this.vod = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 500.0f);
                break;
            case "indicatorDirection":
                this.pyj = str2;
                break;
            case "allowTouchMove":
                this.xw = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, true);
                break;
            case "pageCount":
                this.xp = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 1.0f);
                break;
            case "pageMargin":
                this.vj = wu.fm(this.ro, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f));
                break;
            case "indicatorSelectedColor":
                this.rbn = com.bytedance.adsdk.ugeno.wsy.fm.fm(str2, this.rbn);
                break;
            case "autoplay":
                this.po = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, true);
                break;
            case "dataList":
                this.hou = com.bytedance.adsdk.ugeno.wsy.ro.fm(str2, (JSONArray) null);
                break;
        }
    }

    public void fm(int i10) {
        if (((com.bytedance.adsdk.ugeno.ajl.ro) this.jnr).getCurrentItem() != i10) {
            ((com.bytedance.adsdk.ugeno.ajl.ro) this.jnr).onz(i10);
        }
    }

    @Override // com.bytedance.adsdk.ugeno.ajl.lb
    public void fm(boolean z10, int i10, float f10, int i11) {
        fm(z10, i10, f10);
    }

    @Override // com.bytedance.adsdk.ugeno.ajl.lb
    public void fm(boolean z10, int i10, int i11, boolean z11, boolean z12) {
        if (this.iat != i10) {
            wsy(i10);
            wu(i10);
            this.iat = i10;
        }
    }

    private void fm(boolean z10, int i10, float f10) {
        if (this.hm != null && !z10 && i10 == mj() - 1 && f10 == 0.0f && this.zes) {
            this.hm.fm("SwiperView://finish", new Object[0]);
            this.zes = false;
        }
    }

    private void fm(duv duvVar) {
        if (this.eo) {
            duvVar.fm(new com.bytedance.adsdk.ugeno.core.jnr() { // from class: com.bytedance.adsdk.ugeno.ro.1
                @Override // com.bytedance.adsdk.ugeno.core.jnr
                public void fm(com.bytedance.adsdk.ugeno.ro.lb lbVar, String str, List<ajl.fm> list) {
                    if ((TextUtils.equals(str, "tap") || TextUtils.equals(str, "slide") || TextUtils.equals(str, "touchStart") || TextUtils.equals(str, "touchEnd")) && ((com.bytedance.adsdk.ugeno.ro.lb) ro.this).jnr != null) {
                        ((com.bytedance.adsdk.ugeno.ajl.ro) ((com.bytedance.adsdk.ugeno.ro.lb) ro.this).jnr).ajl();
                    }
                }
            });
        }
    }
}
