mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-15 18:37:17 +01:00
63 lines
2.4 KiB
Java
63 lines
2.4 KiB
Java
package androidx.appcompat.widget;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.graphics.Insets;
|
|
import android.graphics.Rect;
|
|
import android.view.View;
|
|
import android.view.WindowInsets;
|
|
import androidx.annotation.ChecksSdkIntAtLeast;
|
|
import androidx.annotation.DoNotInline;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.annotation.RestrictTo;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
/* loaded from: classes.dex */
|
|
public class ViewUtils {
|
|
|
|
@ChecksSdkIntAtLeast(api = 27)
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
static final boolean SDK_LEVEL_SUPPORTS_AUTOSIZE = true;
|
|
private static final String TAG = "ViewUtils";
|
|
private static Method sComputeFitSystemWindowsMethod;
|
|
private static boolean sInitComputeFitSystemWindowsMethod;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@RequiresApi(29)
|
|
public static class Api29Impl {
|
|
private Api29Impl() {
|
|
}
|
|
|
|
@DoNotInline
|
|
public static void computeFitSystemWindows(@NonNull View view, @NonNull Rect rect, @NonNull Rect rect2) {
|
|
Insets systemWindowInsets = view.computeSystemWindowInsets(new WindowInsets.Builder().setSystemWindowInsets(Insets.of(rect)).build(), rect2).getSystemWindowInsets();
|
|
rect.set(systemWindowInsets.left, systemWindowInsets.top, systemWindowInsets.right, systemWindowInsets.bottom);
|
|
}
|
|
}
|
|
|
|
private ViewUtils() {
|
|
}
|
|
|
|
public static void computeFitSystemWindows(@NonNull View view, @NonNull Rect rect, @NonNull Rect rect2) {
|
|
Api29Impl.computeFitSystemWindows(view, rect, rect2);
|
|
}
|
|
|
|
public static boolean isLayoutRtl(View view) {
|
|
return view.getLayoutDirection() == 1;
|
|
}
|
|
|
|
@SuppressLint({"BanUncheckedReflection"})
|
|
public static void makeOptionalFitsSystemWindows(View view) {
|
|
try {
|
|
Method method = view.getClass().getMethod("makeOptionalFitsSystemWindows", null);
|
|
if (!method.isAccessible()) {
|
|
method.setAccessible(true);
|
|
}
|
|
method.invoke(view, null);
|
|
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException unused) {
|
|
}
|
|
}
|
|
}
|