package c0;

import android.os.Build;
import android.text.Editable;
import android.text.SpanWatcher;
import android.text.Spannable;
import android.text.TextWatcher;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: loaded from: classes.dex */
public final class q implements TextWatcher, SpanWatcher {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final Object f9322q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final AtomicInteger f9323r = new AtomicInteger(0);

    public q(Object obj) {
        this.f9322q = obj;
    }

    @Override // android.text.TextWatcher
    public final void afterTextChanged(Editable editable) {
        ((TextWatcher) this.f9322q).afterTextChanged(editable);
    }

    @Override // android.text.TextWatcher
    public final void beforeTextChanged(CharSequence charSequence, int i, int i5, int i8) {
        ((TextWatcher) this.f9322q).beforeTextChanged(charSequence, i, i5, i8);
    }

    @Override // android.text.SpanWatcher
    public final void onSpanAdded(Spannable spannable, Object obj, int i, int i5) {
        if (this.f9323r.get() <= 0 || !(obj instanceof s)) {
            ((SpanWatcher) this.f9322q).onSpanAdded(spannable, obj, i, i5);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:14:0x001c A[PHI: r11
      0x001c: PHI (r11v1 int) = (r11v0 int), (r11v3 int) binds: [B:8:0x0011, B:12:0x0017] A[DONT_GENERATE, DONT_INLINE]] */
    @Override // android.text.SpanWatcher
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onSpanChanged(Spannable spannable, Object obj, int i, int i5, int i8, int i9) {
        int i10;
        int i11;
        if (this.f9323r.get() <= 0 || !(obj instanceof s)) {
            if (Build.VERSION.SDK_INT >= 28) {
                i10 = i;
                i11 = i8;
            } else {
                if (i > i5) {
                    i = 0;
                }
                if (i8 > i9) {
                    i10 = i;
                    i11 = 0;
                }
            }
            ((SpanWatcher) this.f9322q).onSpanChanged(spannable, obj, i10, i5, i11, i9);
        }
    }

    @Override // android.text.SpanWatcher
    public final void onSpanRemoved(Spannable spannable, Object obj, int i, int i5) {
        if (this.f9323r.get() <= 0 || !(obj instanceof s)) {
            ((SpanWatcher) this.f9322q).onSpanRemoved(spannable, obj, i, i5);
        }
    }

    @Override // android.text.TextWatcher
    public final void onTextChanged(CharSequence charSequence, int i, int i5, int i8) {
        ((TextWatcher) this.f9322q).onTextChanged(charSequence, i, i5, i8);
    }
}
