Source code
package android.support.design.widget;
import android.graphics.Rect;
import android.os.Build.VERSION;
import android.view.View;
import android.view.ViewGroup;
class ViewGroupUtils {
private static final ViewGroupUtilsImpl IMPL;
private interface ViewGroupUtilsImpl {
void offsetDescendantRect(ViewGroup viewGroup, View view, Rect rect);
}
private static class ViewGroupUtilsImplBase implements ViewGroupUtilsImpl {
private ViewGroupUtilsImplBase() {
}
public void offsetDescendantRect(ViewGroup parent, View child, Rect rect) {
parent.offsetDescendantRectToMyCoords(child, rect);
}
}
private static class ViewGroupUtilsImplHoneycomb implements ViewGroupUtilsImpl {
private ViewGroupUtilsImplHoneycomb() {
}
public void offsetDescendantRect(ViewGroup parent, View child, Rect rect) {
ViewGroupUtilsHoneycomb.offsetDescendantRect(parent, child, rect);
}
}
ViewGroupUtils() {
}
static {
if (VERSION.SDK_INT >= 11) {
IMPL = new ViewGroupUtilsImplHoneycomb();
} else {
IMPL = new ViewGroupUtilsImplBase();
}
}
static void offsetDescendantRect(ViewGroup parent, View descendant, Rect rect) {
IMPL.offsetDescendantRect(parent, descendant, rect);
}
static void getDescendantRect(ViewGroup parent, View descendant, Rect out) {
out.set(0, 0, descendant.getWidth(), descendant.getHeight());
offsetDescendantRect(parent, descendant, out);
}
}