52 lines
1.7 KiB
Java
52 lines
1.7 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;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class DescendantOffsetUtils {
|
|
private static final ThreadLocal<Matrix> a = new ThreadLocal<>();
|
|
private static final ThreadLocal<RectF> b = new ThreadLocal<>();
|
|
|
|
public static void a(ViewGroup viewGroup, View view, Rect rect) {
|
|
rect.set(0, 0, view.getWidth(), view.getHeight());
|
|
b(viewGroup, view, rect);
|
|
}
|
|
|
|
public static void b(ViewGroup viewGroup, View view, Rect rect) {
|
|
Matrix matrix = a.get();
|
|
if (matrix == null) {
|
|
matrix = new Matrix();
|
|
a.set(matrix);
|
|
} else {
|
|
matrix.reset();
|
|
}
|
|
a(viewGroup, view, matrix);
|
|
RectF rectF = b.get();
|
|
if (rectF == null) {
|
|
rectF = new RectF();
|
|
b.set(rectF);
|
|
}
|
|
rectF.set(rect);
|
|
matrix.mapRect(rectF);
|
|
rect.set((int) (rectF.left + 0.5f), (int) (rectF.top + 0.5f), (int) (rectF.right + 0.5f), (int) (rectF.bottom + 0.5f));
|
|
}
|
|
|
|
private static void a(ViewParent viewParent, View view, Matrix matrix) {
|
|
Object parent = view.getParent();
|
|
if ((parent instanceof View) && parent != viewParent) {
|
|
a(viewParent, (View) parent, matrix);
|
|
matrix.preTranslate(-r0.getScrollX(), -r0.getScrollY());
|
|
}
|
|
matrix.preTranslate(view.getLeft(), view.getTop());
|
|
if (view.getMatrix().isIdentity()) {
|
|
return;
|
|
}
|
|
matrix.preConcat(view.getMatrix());
|
|
}
|
|
}
|