79 lines
2.4 KiB
Java
79 lines
2.4 KiB
Java
package androidx.core.widget;
|
|
|
|
import android.os.Build;
|
|
import android.util.Log;
|
|
import android.view.View;
|
|
import android.widget.PopupWindow;
|
|
import androidx.core.view.GravityCompat;
|
|
import androidx.core.view.ViewCompat;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Method;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class PopupWindowCompat {
|
|
private static Method a;
|
|
private static boolean b;
|
|
private static Field c;
|
|
private static boolean d;
|
|
|
|
public static void a(PopupWindow popupWindow, View view, int i, int i2, int i3) {
|
|
if (Build.VERSION.SDK_INT >= 19) {
|
|
popupWindow.showAsDropDown(view, i, i2, i3);
|
|
return;
|
|
}
|
|
if ((GravityCompat.a(i3, ViewCompat.k(view)) & 7) == 5) {
|
|
i -= popupWindow.getWidth() - view.getWidth();
|
|
}
|
|
popupWindow.showAsDropDown(view, i, i2);
|
|
}
|
|
|
|
public static void a(PopupWindow popupWindow, boolean z) {
|
|
int i = Build.VERSION.SDK_INT;
|
|
if (i >= 23) {
|
|
popupWindow.setOverlapAnchor(z);
|
|
return;
|
|
}
|
|
if (i >= 21) {
|
|
if (!d) {
|
|
try {
|
|
c = PopupWindow.class.getDeclaredField("mOverlapAnchor");
|
|
c.setAccessible(true);
|
|
} catch (NoSuchFieldException e) {
|
|
Log.i("PopupWindowCompatApi21", "Could not fetch mOverlapAnchor field from PopupWindow", e);
|
|
}
|
|
d = true;
|
|
}
|
|
Field field = c;
|
|
if (field != null) {
|
|
try {
|
|
field.set(popupWindow, Boolean.valueOf(z));
|
|
} catch (IllegalAccessException e2) {
|
|
Log.i("PopupWindowCompatApi21", "Could not set overlap anchor field in PopupWindow", e2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void a(PopupWindow popupWindow, int i) {
|
|
if (Build.VERSION.SDK_INT >= 23) {
|
|
popupWindow.setWindowLayoutType(i);
|
|
return;
|
|
}
|
|
if (!b) {
|
|
try {
|
|
a = PopupWindow.class.getDeclaredMethod("setWindowLayoutType", Integer.TYPE);
|
|
a.setAccessible(true);
|
|
} catch (Exception unused) {
|
|
}
|
|
b = true;
|
|
}
|
|
Method method = a;
|
|
if (method != null) {
|
|
try {
|
|
method.invoke(popupWindow, Integer.valueOf(i));
|
|
} catch (Exception unused2) {
|
|
}
|
|
}
|
|
}
|
|
}
|