package com.google.android.gms.vision; import android.util.SparseArray; import com.google.android.gms.vision.Detector; /* loaded from: classes2.dex */ public abstract class FocusingProcessor implements Detector.Processor { private Tracker zzak; private int zzan; private Detector zzr; private int zzal = 3; private boolean zzam = false; private int zzao = 0; public FocusingProcessor(Detector detector, Tracker tracker) { this.zzr = detector; this.zzak = tracker; } public abstract int selectFocus(Detector.Detections detections); @Override // com.google.android.gms.vision.Detector.Processor public void release() { this.zzak.onDone(); } @Override // com.google.android.gms.vision.Detector.Processor public void receiveDetections(Detector.Detections detections) { SparseArray detectedItems = detections.getDetectedItems(); if (detectedItems.size() == 0) { if (this.zzao == this.zzal) { this.zzak.onDone(); this.zzam = false; } else { this.zzak.onMissing(detections); } this.zzao++; return; } this.zzao = 0; if (this.zzam) { T t = detectedItems.get(this.zzan); if (t != null) { this.zzak.onUpdate(detections, t); return; } else { this.zzak.onDone(); this.zzam = false; } } int selectFocus = selectFocus(detections); T t2 = detectedItems.get(selectFocus); if (t2 == null) { return; } this.zzam = true; this.zzan = selectFocus; this.zzr.setFocus(selectFocus); this.zzak.onNewItem(this.zzan, t2); this.zzak.onUpdate(detections, t2); } public final void zza(int i) { if (i >= 0) { this.zzal = i; return; } StringBuilder sb = new StringBuilder(28); sb.append("Invalid max gap: "); sb.append(i); throw new IllegalArgumentException(sb.toString()); } }