package com.bytedance.adsdk.ugeno.ajl.fm;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import com.bytedance.adsdk.ugeno.ajl.yz;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public abstract class fm extends LinearLayout {
    private int ajl;
    private String duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private int f6305ef;
    protected Context fm;
    private int jnr;
    private float ku;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    protected int f6306lb;
    protected int ro;
    private float vt;
    private int wsy;
    private boolean wu;
    private List<View> yz;

    public fm(Context context) {
        super(context);
        this.jnr = -65536;
        this.ajl = -16776961;
        this.wsy = 5;
        this.ro = 40;
        this.f6306lb = 20;
        this.duv = "row";
        this.fm = context;
        this.yz = new ArrayList();
        setOrientation(0);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void yz() {
        FrameLayout frameLayout = (FrameLayout) getParent();
        if (frameLayout == null) {
            return;
        }
        float width = frameLayout.getWidth();
        float height = frameLayout.getHeight();
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams();
        float width2 = getWidth();
        layoutParams.topMargin = (int) (((int) ((height * r5) / 100.0f)) - ((getHeight() * this.ku) / 100.0f));
        layoutParams.leftMargin = (int) (((int) ((width * r0) / 100.0f)) - ((width2 * this.vt) / 100.0f));
        setLayoutParams(layoutParams);
    }

    public int getSize() {
        return this.yz.size();
    }

    public void lb() {
        this.yz.clear();
        removeAllViews();
    }

    public abstract Drawable ro(int i10);

    public void ro() {
        View view = new View(getContext());
        view.setClickable(false);
        if (this instanceof ro) {
            this.f6306lb = this.ro;
        }
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(this.ro, this.f6306lb);
        if (getOrientation() == 1) {
            int i10 = this.wsy;
            layoutParams.topMargin = i10;
            layoutParams.bottomMargin = i10;
        } else {
            int i11 = this.wsy;
            layoutParams.leftMargin = i11;
            layoutParams.rightMargin = i11;
        }
        addView(view, layoutParams);
        view.setBackground(ro(this.ajl));
        this.yz.add(view);
    }

    public void setIndicatorDirection(String str) {
        this.duv = str;
        if (TextUtils.equals(str, "column")) {
            setOrientation(1);
        } else {
            setOrientation(0);
        }
    }

    public void setIndicatorHeight(int i10) {
        this.f6306lb = i10;
    }

    public void setIndicatorWidth(int i10) {
        this.ro = i10;
    }

    public void setIndicatorX(float f10) {
        this.vt = f10;
    }

    public void setIndicatorY(float f10) {
        this.ku = f10;
    }

    public void setLoop(boolean z10) {
        this.wu = z10;
    }

    public void setSelectedColor(int i10) {
        this.jnr = i10;
    }

    public void setUnSelectedColor(int i10) {
        this.ajl = i10;
    }

    public void fm(int i10, int i11) {
        Iterator<View> it = this.yz.iterator();
        while (it.hasNext()) {
            it.next().setBackground(ro(this.ajl));
        }
        if (i10 < 0 || i10 >= this.yz.size()) {
            i10 = 0;
        }
        if (this.yz.size() > 0) {
            this.yz.get(i10).setBackground(ro(this.jnr));
            this.f6305ef = i11;
        }
    }

    public void fm() {
        post(new Runnable() { // from class: com.bytedance.adsdk.ugeno.ajl.fm.fm.1
            @Override // java.lang.Runnable
            public void run() {
                fm.this.yz();
            }
        });
    }

    public void fm(int i10) {
        if (this instanceof ro) {
            this.f6306lb = this.ro;
        }
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(this.ro, this.f6306lb);
        if (getOrientation() == 1) {
            int i11 = this.wsy;
            layoutParams.topMargin = i11;
            layoutParams.bottomMargin = i11;
        } else {
            int i12 = this.wsy;
            layoutParams.leftMargin = i12;
            layoutParams.rightMargin = i12;
        }
        LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(this.ro, this.f6306lb);
        if (getOrientation() == 1) {
            int i13 = this.wsy;
            layoutParams2.topMargin = i13;
            layoutParams2.bottomMargin = i13;
        } else {
            int i14 = this.wsy;
            layoutParams2.leftMargin = i14;
            layoutParams2.rightMargin = i14;
        }
        int iFm = yz.fm(this.wu, this.f6305ef, this.yz.size());
        int iFm2 = yz.fm(this.wu, i10, this.yz.size());
        if (this.yz.size() == 0) {
            iFm2 = 0;
        }
        if (!this.yz.isEmpty() && yz.fm(iFm, this.yz) && yz.fm(iFm2, this.yz)) {
            this.yz.get(iFm).setBackground(ro(this.ajl));
            this.yz.get(iFm).setLayoutParams(layoutParams2);
            this.yz.get(iFm2).setBackground(ro(this.jnr));
            this.yz.get(iFm2).setLayoutParams(layoutParams);
            this.f6305ef = i10;
        }
    }
}
