Rabbit-R1/switch port/java/sources/androidx/viewpager2/widget/CompositeOnPageChangeCallback.java
2024-05-21 17:08:36 -04:00

67 lines
2.6 KiB
Java

package androidx.viewpager2.widget;
import androidx.viewpager2.widget.ViewPager2;
import java.util.ArrayList;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes2.dex */
final class CompositeOnPageChangeCallback extends ViewPager2.OnPageChangeCallback {
private final List<ViewPager2.OnPageChangeCallback> mCallbacks;
/* JADX INFO: Access modifiers changed from: package-private */
public CompositeOnPageChangeCallback(int i) {
this.mCallbacks = new ArrayList(i);
}
/* JADX INFO: Access modifiers changed from: package-private */
public void addOnPageChangeCallback(ViewPager2.OnPageChangeCallback onPageChangeCallback) {
this.mCallbacks.add(onPageChangeCallback);
}
/* JADX INFO: Access modifiers changed from: package-private */
public void removeOnPageChangeCallback(ViewPager2.OnPageChangeCallback onPageChangeCallback) {
this.mCallbacks.remove(onPageChangeCallback);
}
@Override // androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback
public void onPageScrolled(int i, float f, int i2) {
try {
Iterator<ViewPager2.OnPageChangeCallback> it = this.mCallbacks.iterator();
while (it.hasNext()) {
it.next().onPageScrolled(i, f, i2);
}
} catch (ConcurrentModificationException e) {
throwCallbackListModifiedWhileInUse(e);
}
}
@Override // androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback
public void onPageSelected(int i) {
try {
Iterator<ViewPager2.OnPageChangeCallback> it = this.mCallbacks.iterator();
while (it.hasNext()) {
it.next().onPageSelected(i);
}
} catch (ConcurrentModificationException e) {
throwCallbackListModifiedWhileInUse(e);
}
}
@Override // androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback
public void onPageScrollStateChanged(int i) {
try {
Iterator<ViewPager2.OnPageChangeCallback> it = this.mCallbacks.iterator();
while (it.hasNext()) {
it.next().onPageScrollStateChanged(i);
}
} catch (ConcurrentModificationException e) {
throwCallbackListModifiedWhileInUse(e);
}
}
private void throwCallbackListModifiedWhileInUse(ConcurrentModificationException concurrentModificationException) {
throw new IllegalStateException("Adding and removing callbacks during dispatch to callbacks is not supported", concurrentModificationException);
}
}