Rabbit-R1/switch port/java/sources/androidx/appcompat/widget/AppCompatPopupWindow.java

66 lines
2.4 KiB
Java
Raw Normal View History

2024-05-21 21:08:36 +00:00
package androidx.appcompat.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.PopupWindow;
import androidx.appcompat.R;
import androidx.core.widget.PopupWindowCompat;
/* loaded from: classes.dex */
class AppCompatPopupWindow extends PopupWindow {
private static final boolean COMPAT_OVERLAP_ANCHOR = false;
private boolean mOverlapAnchor;
public AppCompatPopupWindow(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
init(context, attributeSet, i, 0);
}
public AppCompatPopupWindow(Context context, AttributeSet attributeSet, int i, int i2) {
super(context, attributeSet, i, i2);
init(context, attributeSet, i, i2);
}
private void init(Context context, AttributeSet attributeSet, int i, int i2) {
TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(context, attributeSet, R.styleable.PopupWindow, i, i2);
if (obtainStyledAttributes.hasValue(R.styleable.PopupWindow_overlapAnchor)) {
setSupportOverlapAnchor(obtainStyledAttributes.getBoolean(R.styleable.PopupWindow_overlapAnchor, false));
}
setBackgroundDrawable(obtainStyledAttributes.getDrawable(R.styleable.PopupWindow_android_popupBackground));
obtainStyledAttributes.recycle();
}
@Override // android.widget.PopupWindow
public void showAsDropDown(View view, int i, int i2) {
if (COMPAT_OVERLAP_ANCHOR && this.mOverlapAnchor) {
i2 -= view.getHeight();
}
super.showAsDropDown(view, i, i2);
}
@Override // android.widget.PopupWindow
public void showAsDropDown(View view, int i, int i2, int i3) {
if (COMPAT_OVERLAP_ANCHOR && this.mOverlapAnchor) {
i2 -= view.getHeight();
}
super.showAsDropDown(view, i, i2, i3);
}
@Override // android.widget.PopupWindow
public void update(View view, int i, int i2, int i3, int i4) {
if (COMPAT_OVERLAP_ANCHOR && this.mOverlapAnchor) {
i2 -= view.getHeight();
}
super.update(view, i, i2, i3, i4);
}
private void setSupportOverlapAnchor(boolean z) {
if (COMPAT_OVERLAP_ANCHOR) {
this.mOverlapAnchor = z;
} else {
PopupWindowCompat.setOverlapAnchor(this, z);
}
}
}