package androidx.recyclerview.widget;

/* loaded from: classes.dex */
public class c implements l {

    /* renamed from: a, reason: collision with root package name */
    final l f5306a;

    /* renamed from: b, reason: collision with root package name */
    int f5307b = 0;

    /* renamed from: c, reason: collision with root package name */
    int f5308c = -1;

    /* renamed from: d, reason: collision with root package name */
    int f5309d = -1;

    /* renamed from: e, reason: collision with root package name */
    Object f5310e = null;

    public c(l lVar) {
        this.f5306a = lVar;
    }

    @Override // androidx.recyclerview.widget.l
    public void a(int i10, int i11) {
        e();
        this.f5306a.a(i10, i11);
    }

    @Override // androidx.recyclerview.widget.l
    public void b(int i10, int i11) {
        int i12;
        if (this.f5307b == 1 && i10 >= (i12 = this.f5308c)) {
            int i13 = this.f5309d;
            if (i10 <= i12 + i13) {
                this.f5309d = i13 + i11;
                this.f5308c = Math.min(i10, i12);
                return;
            }
        }
        e();
        this.f5308c = i10;
        this.f5309d = i11;
        this.f5307b = 1;
    }

    @Override // androidx.recyclerview.widget.l
    public void c(int i10, int i11) {
        int i12;
        if (this.f5307b == 2 && (i12 = this.f5308c) >= i10 && i12 <= i10 + i11) {
            this.f5309d += i11;
            this.f5308c = i10;
        } else {
            e();
            this.f5308c = i10;
            this.f5309d = i11;
            this.f5307b = 2;
        }
    }

    @Override // androidx.recyclerview.widget.l
    public void d(int i10, int i11, Object obj) {
        int i12;
        if (this.f5307b == 3) {
            int i13 = this.f5308c;
            int i14 = this.f5309d;
            if (i10 <= i13 + i14 && (i12 = i10 + i11) >= i13 && this.f5310e == obj) {
                this.f5308c = Math.min(i10, i13);
                this.f5309d = Math.max(i14 + i13, i12) - this.f5308c;
                return;
            }
        }
        e();
        this.f5308c = i10;
        this.f5309d = i11;
        this.f5310e = obj;
        this.f5307b = 3;
    }

    public void e() {
        int i10 = this.f5307b;
        if (i10 == 0) {
            return;
        }
        if (i10 == 1) {
            this.f5306a.b(this.f5308c, this.f5309d);
        } else if (i10 == 2) {
            this.f5306a.c(this.f5308c, this.f5309d);
        } else if (i10 == 3) {
            this.f5306a.d(this.f5308c, this.f5309d, this.f5310e);
        }
        this.f5310e = null;
        this.f5307b = 0;
    }
}
