what-the-bank/sources/io/flutter/plugin/editing/ImeSyncDeferringInsetsCallb...

122 lines
4.8 KiB
Java

package io.flutter.plugin.editing;
import android.graphics.Insets;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowInsetsAnimation;
import java.util.Iterator;
import java.util.List;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public class ImeSyncDeferringInsetsCallback {
private int deferredInsetTypes;
private WindowInsets lastWindowInsets;
private int overlayInsetTypes;
private View view;
private boolean animating = false;
private boolean needsSave = false;
private AnimationCallback animationCallback = new AnimationCallback(this);
private InsetsListener insetsListener = new InsetsListener();
WindowInsetsAnimation.Callback getAnimationCallback() {
return this.animationCallback;
}
View.OnApplyWindowInsetsListener getInsetsListener() {
return this.insetsListener;
}
/* JADX INFO: Access modifiers changed from: package-private */
public ImeSyncDeferringInsetsCallback(View view, int i, int i2) {
this.overlayInsetTypes = i;
this.deferredInsetTypes = i2;
this.view = view;
}
/* JADX INFO: Access modifiers changed from: package-private */
public void install() {
this.view.setWindowInsetsAnimationCallback(this.animationCallback);
this.view.setOnApplyWindowInsetsListener(this.insetsListener);
}
/* JADX INFO: Access modifiers changed from: package-private */
public void remove() {
this.view.setWindowInsetsAnimationCallback(null);
this.view.setOnApplyWindowInsetsListener(null);
}
/* loaded from: classes6.dex */
class AnimationCallback extends WindowInsetsAnimation.Callback {
final ImeSyncDeferringInsetsCallback this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
AnimationCallback(ImeSyncDeferringInsetsCallback imeSyncDeferringInsetsCallback) {
super(1);
this.this$0 = imeSyncDeferringInsetsCallback;
}
@Override // android.view.WindowInsetsAnimation.Callback
public void onPrepare(WindowInsetsAnimation windowInsetsAnimation) {
if ((windowInsetsAnimation.getTypeMask() & this.this$0.deferredInsetTypes) != 0) {
this.this$0.animating = true;
this.this$0.needsSave = true;
}
}
@Override // android.view.WindowInsetsAnimation.Callback
public WindowInsets onProgress(WindowInsets windowInsets, List<WindowInsetsAnimation> list) {
if (this.this$0.animating && !this.this$0.needsSave) {
Iterator<WindowInsetsAnimation> it = list.iterator();
boolean z = false;
while (it.hasNext()) {
if ((it.next().getTypeMask() & this.this$0.deferredInsetTypes) != 0) {
z = true;
}
}
if (!z) {
return windowInsets;
}
WindowInsets.Builder builder = new WindowInsets.Builder(this.this$0.lastWindowInsets);
builder.setInsets(this.this$0.deferredInsetTypes, Insets.of(0, 0, 0, Math.max(windowInsets.getInsets(this.this$0.deferredInsetTypes).bottom - windowInsets.getInsets(this.this$0.overlayInsetTypes).bottom, 0)));
this.this$0.view.onApplyWindowInsets(builder.build());
}
return windowInsets;
}
@Override // android.view.WindowInsetsAnimation.Callback
public void onEnd(WindowInsetsAnimation windowInsetsAnimation) {
if (!this.this$0.animating || (windowInsetsAnimation.getTypeMask() & this.this$0.deferredInsetTypes) == 0) {
return;
}
this.this$0.animating = false;
if (this.this$0.lastWindowInsets == null || this.this$0.view == null) {
return;
}
this.this$0.view.dispatchApplyWindowInsets(this.this$0.lastWindowInsets);
}
}
/* loaded from: classes6.dex */
class InsetsListener implements View.OnApplyWindowInsetsListener {
final ImeSyncDeferringInsetsCallback this$0;
private InsetsListener(ImeSyncDeferringInsetsCallback imeSyncDeferringInsetsCallback) {
this.this$0 = imeSyncDeferringInsetsCallback;
}
@Override // android.view.View.OnApplyWindowInsetsListener
public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
this.this$0.view = view;
if (this.this$0.needsSave) {
this.this$0.lastWindowInsets = windowInsets;
this.this$0.needsSave = false;
}
if (this.this$0.animating) {
return WindowInsets.CONSUMED;
}
return view.onApplyWindowInsets(windowInsets);
}
}
}