mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-18 20:07:19 +01:00
57 lines
2.2 KiB
Java
57 lines
2.2 KiB
Java
package com.google.android.material.internal;
|
|
|
|
import android.graphics.Matrix;
|
|
import android.graphics.Rect;
|
|
import android.graphics.RectF;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewParent;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.RestrictTo;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
/* loaded from: classes7.dex */
|
|
public class DescendantOffsetUtils {
|
|
private static final ThreadLocal<Matrix> matrix = new ThreadLocal<>();
|
|
private static final ThreadLocal<RectF> rectF = new ThreadLocal<>();
|
|
|
|
public static void getDescendantRect(@NonNull ViewGroup viewGroup, @NonNull View view, @NonNull Rect rect) {
|
|
rect.set(0, 0, view.getWidth(), view.getHeight());
|
|
offsetDescendantRect(viewGroup, view, rect);
|
|
}
|
|
|
|
private static void offsetDescendantMatrix(ViewParent viewParent, @NonNull View view, @NonNull Matrix matrix2) {
|
|
Object parent = view.getParent();
|
|
if ((parent instanceof View) && parent != viewParent) {
|
|
offsetDescendantMatrix(viewParent, (View) parent, matrix2);
|
|
matrix2.preTranslate(-r0.getScrollX(), -r0.getScrollY());
|
|
}
|
|
matrix2.preTranslate(view.getLeft(), view.getTop());
|
|
if (view.getMatrix().isIdentity()) {
|
|
return;
|
|
}
|
|
matrix2.preConcat(view.getMatrix());
|
|
}
|
|
|
|
public static void offsetDescendantRect(@NonNull ViewGroup viewGroup, @NonNull View view, @NonNull Rect rect) {
|
|
ThreadLocal<Matrix> threadLocal = matrix;
|
|
Matrix matrix2 = threadLocal.get();
|
|
if (matrix2 == null) {
|
|
matrix2 = new Matrix();
|
|
threadLocal.set(matrix2);
|
|
} else {
|
|
matrix2.reset();
|
|
}
|
|
offsetDescendantMatrix(viewGroup, view, matrix2);
|
|
ThreadLocal<RectF> threadLocal2 = rectF;
|
|
RectF rectF2 = threadLocal2.get();
|
|
if (rectF2 == null) {
|
|
rectF2 = new RectF();
|
|
threadLocal2.set(rectF2);
|
|
}
|
|
rectF2.set(rect);
|
|
matrix2.mapRect(rectF2);
|
|
rect.set((int) (rectF2.left + 0.5f), (int) (rectF2.top + 0.5f), (int) (rectF2.right + 0.5f), (int) (rectF2.bottom + 0.5f));
|
|
}
|
|
}
|