package com.scwang.smartrefresh.header;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.SparseArray;
import com.scwang.smartrefresh.header.fungame.FunGameView;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
import ඓ.㿎.K.ῲ.䀟.C1436;

public class FunGameBattleCityHeader extends FunGameView {

    /* renamed from: Ϸ  reason: contains not printable characters */
    public int f3011;

    /* renamed from: В  reason: contains not printable characters */
    public SparseArray<Queue<RectF>> f3012;

    /* renamed from: ѷ  reason: contains not printable characters */
    public int f3013;

    /* renamed from: ࠋ  reason: contains not printable characters */
    public int f3014;

    /* renamed from: ಯ  reason: contains not printable characters */
    public Point f3015;

    /* renamed from: ผ  reason: contains not printable characters */
    public int f3016;

    /* renamed from: ጒ  reason: contains not printable characters */
    public Random f3017;

    /* renamed from: Ꮝ  reason: contains not printable characters */
    public boolean f3018;

    /* renamed from: ᶲ  reason: contains not printable characters */
    public int f3019;

    /* renamed from: ピ  reason: contains not printable characters */
    public int f3020;

    /* renamed from: 㒁  reason: contains not printable characters */
    public int f3021;

    /* renamed from: 㓚  reason: contains not printable characters */
    public int f3022;

    /* renamed from: 㮝  reason: contains not printable characters */
    public Queue<Point> f3023;

    /* renamed from: 㱶  reason: contains not printable characters */
    public int f3024;

    /* renamed from: 㷛  reason: contains not printable characters */
    public int f3025;

    /* renamed from: 㹎  reason: contains not printable characters */
    public float f3026;

    public FunGameBattleCityHeader(Context context) {
        this(context, null);
    }

    @Override // com.scwang.smartrefresh.header.fungame.FunGameView
    /* renamed from: ᨨ  reason: contains not printable characters */
    public void m1701() {
        this.f3187 = 0;
        this.f3183 = this.f3169;
        this.f3019 = C1436.m3649(1.0f);
        this.f3014 = C1436.m3649(4.0f);
        this.f3022 = 8;
        this.f3011 = 0;
        this.f3018 = true;
        this.f3021 = this.f3184 + this.f3013 + 60;
        this.f3025 = 360;
        this.f3012 = new SparseArray<>();
        for (int i = 0; i < 3; i++) {
            this.f3012.put(i, new LinkedList());
        }
        this.f3023 = new LinkedList();
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public final int m1702(int i) {
        int i2 = i / (this.f3154 / 3);
        if (i2 >= 3) {
            i2 = 2;
        }
        if (i2 < 0) {
            return 0;
        }
        return i2;
    }

    /* renamed from: K  reason: contains not printable characters */
    public final boolean m1705(int i, float f, float f2) {
        RectF peek = this.f3012.get(i).peek();
        return peek != null && peek.contains(f, f2);
    }

    @Override // com.scwang.smartrefresh.header.fungame.FunGameView
    /* renamed from: 㿎  reason: contains not printable characters */
    public void m1706() {
        this.f3017 = new Random();
        this.f3184 = this.f3154 / 3;
        this.f3013 = (int) Math.floor((double) ((((float) this.f3184) * 0.33333334f) + 0.5f));
        this.f3026 = (((float) this.f3013) - (this.f3169 * 2.0f)) * 0.5f;
        m1701();
    }

    public FunGameBattleCityHeader(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public FunGameBattleCityHeader(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.f3019 = 1;
        this.f3014 = 4;
        this.f3018 = true;
    }

    @Override // com.scwang.smartrefresh.header.fungame.FunGameView
    /* renamed from: K  reason: contains not printable characters */
    public void m1703(Canvas canvas, int i, int i2) {
        boolean z;
        this.f3177.setColor(this.f3175);
        boolean r1 = m1705(m1702((int) this.f3183), (float) (i - this.f3184), this.f3183);
        int r2 = m1702((int) (this.f3183 + ((float) this.f3184)));
        int i3 = this.f3184;
        boolean r22 = m1705(r2, (float) (i - i3), this.f3183 + ((float) i3));
        if (r1 || r22) {
            this.f3187 = 2;
        }
        int i4 = this.f3184;
        float f = this.f3183;
        float f2 = this.f3169;
        float f3 = (float) i;
        canvas.drawRect((float) (i - i4), f + f2, f3, f + ((float) i4) + f2, this.f3177);
        int i5 = this.f3184;
        int i6 = i - i5;
        int i7 = this.f3013;
        float f4 = this.f3183 + (((float) (i5 - i7)) * 0.5f);
        canvas.drawRect((float) (i6 - i7), f4, (float) i6, f4 + ((float) i7), this.f3177);
        int i8 = this.f3187;
        if (i8 == 1 || i8 == 3) {
            this.f3177.setColor(this.f3180);
            this.f3016 += this.f3019;
            if (this.f3016 / this.f3021 == 1 || this.f3018) {
                this.f3016 = 0;
                this.f3018 = false;
            }
            int nextInt = this.f3017.nextInt(3);
            int i9 = 0;
            boolean z2 = false;
            for (int i10 = 3; i9 < i10; i10 = 3) {
                Queue<RectF> queue = this.f3012.get(i9);
                if (this.f3016 == 0 && i9 == nextInt) {
                    int i11 = this.f3184;
                    int i12 = this.f3013;
                    float f5 = (float) (-(i11 + i12));
                    float f6 = ((float) (i9 * i11)) + this.f3169;
                    queue.offer(new RectF(f5, f6, (((float) i12) * 2.5f) + f5, ((float) i11) + f6));
                }
                Iterator<RectF> it2 = queue.iterator();
                while (true) {
                    if (!it2.hasNext()) {
                        break;
                    }
                    RectF next = it2.next();
                    if (next.left >= f3) {
                        int i13 = this.f3020 + 1;
                        this.f3020 = i13;
                        if (i13 >= 8) {
                            this.f3187 = 2;
                            z2 = true;
                            break;
                        }
                        z2 = true;
                    } else {
                        m1704(canvas, next);
                    }
                }
                if (this.f3187 == 2) {
                    break;
                }
                if (z2) {
                    queue.poll();
                    z2 = false;
                }
                i9++;
            }
            invalidate();
            this.f3177.setColor(this.f3181);
            this.f3024 += this.f3014;
            if (this.f3024 / this.f3025 == 1) {
                this.f3024 = 0;
            }
            if (this.f3024 == 0) {
                Point point = new Point();
                int i14 = this.f3184;
                point.x = (i - i14) - this.f3013;
                point.y = (int) ((((float) i14) * 0.5f) + this.f3183);
                this.f3023.offer(point);
            }
            boolean z3 = false;
            for (Point point2 : this.f3023) {
                int r6 = m1702(point2.y);
                RectF peek = this.f3012.get(r6).peek();
                if (peek == null || !peek.contains((float) point2.x, (float) point2.y)) {
                    z = false;
                } else {
                    int i15 = this.f3011 + 1;
                    this.f3011 = i15;
                    int i16 = this.f3022;
                    if (i15 == i16) {
                        this.f3022 = i16 + 8;
                        this.f3019 = C1436.m3649(1.0f) + this.f3019;
                        this.f3014 = C1436.m3649(1.0f) + this.f3014;
                        this.f3011 = 0;
                        int i17 = this.f3021;
                        if (i17 > 12) {
                            this.f3021 = i17 - 12;
                        }
                        int i18 = this.f3025;
                        if (i18 > 30) {
                            this.f3025 = i18 - 30;
                        }
                    }
                    this.f3012.get(r6).poll();
                    z = true;
                }
                if (z) {
                    this.f3015 = point2;
                } else {
                    if (((float) point2.x) + this.f3026 <= 0.0f) {
                        z3 = true;
                    }
                    point2.x -= this.f3014;
                    canvas.drawCircle((float) point2.x, (float) point2.y, this.f3026, this.f3177);
                }
            }
            if (z3) {
                this.f3023.poll();
            }
            this.f3023.remove(this.f3015);
            this.f3015 = null;
        }
        if (isInEditMode()) {
            int i19 = this.f3184;
            m1704(canvas, new RectF((float) i19, 0.0f, (float) (i19 * 2), (float) i19));
            int i20 = this.f3184;
            m1704(canvas, new RectF(0.0f, (float) i20, (float) i20, (float) (i20 * 2)));
            int i21 = this.f3184;
            m1704(canvas, new RectF((float) (i21 * 3), (float) (i21 * 2), (float) (i21 * 4), (float) (i21 * 3)));
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m1704(Canvas canvas, RectF rectF) {
        float f = rectF.left;
        int i = this.f3019;
        rectF.set(f + ((float) i), rectF.top, rectF.right + ((float) i), rectF.bottom);
        canvas.drawRect(rectF, this.f3177);
        float f2 = rectF.top;
        int i2 = this.f3184;
        int i3 = this.f3013;
        float f3 = (((float) (i2 - i3)) * 0.5f) + f2;
        float f4 = rectF.right;
        canvas.drawRect(f4, f3, f4 + ((float) i3), f3 + ((float) i3), this.f3177);
    }
}
