88 lines
2.6 KiB
Java
88 lines
2.6 KiB
Java
|
package io.flutter.util;
|
||
|
|
||
|
import android.app.Activity;
|
||
|
import android.content.Context;
|
||
|
import android.content.ContextWrapper;
|
||
|
import android.view.View;
|
||
|
import android.view.ViewGroup;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public final class ViewUtils {
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public interface ViewVisitor {
|
||
|
boolean run(View view);
|
||
|
}
|
||
|
|
||
|
public static Activity getActivity(Context context) {
|
||
|
if (context == null) {
|
||
|
return null;
|
||
|
}
|
||
|
if (context instanceof Activity) {
|
||
|
return (Activity) context;
|
||
|
}
|
||
|
if (context instanceof ContextWrapper) {
|
||
|
return getActivity(((ContextWrapper) context).getBaseContext());
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public static int generateViewId(int i) {
|
||
|
return View.generateViewId();
|
||
|
}
|
||
|
|
||
|
public static boolean childHasFocus(View view) {
|
||
|
return traverseHierarchy(view, new ViewVisitor() { // from class: io.flutter.util.ViewUtils$$ExternalSyntheticLambda0
|
||
|
@Override // io.flutter.util.ViewUtils.ViewVisitor
|
||
|
public final boolean run(View view2) {
|
||
|
boolean hasFocus;
|
||
|
hasFocus = view2.hasFocus();
|
||
|
return hasFocus;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
public static boolean hasChildViewOfType(View view, final Class<? extends View>[] clsArr) {
|
||
|
return traverseHierarchy(view, new ViewVisitor(clsArr) { // from class: io.flutter.util.ViewUtils$$ExternalSyntheticLambda1
|
||
|
public final Class[] f$0;
|
||
|
|
||
|
{
|
||
|
this.f$0 = clsArr;
|
||
|
}
|
||
|
|
||
|
@Override // io.flutter.util.ViewUtils.ViewVisitor
|
||
|
public final boolean run(View view2) {
|
||
|
return ViewUtils.lambda$hasChildViewOfType$1(this.f$0, view2);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static /* synthetic */ boolean lambda$hasChildViewOfType$1(Class[] clsArr, View view) {
|
||
|
for (Class cls : clsArr) {
|
||
|
if (cls.isInstance(view)) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public static boolean traverseHierarchy(View view, ViewVisitor viewVisitor) {
|
||
|
if (view == null) {
|
||
|
return false;
|
||
|
}
|
||
|
if (viewVisitor.run(view)) {
|
||
|
return true;
|
||
|
}
|
||
|
if (view instanceof ViewGroup) {
|
||
|
ViewGroup viewGroup = (ViewGroup) view;
|
||
|
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||
|
if (traverseHierarchy(viewGroup.getChildAt(i), viewVisitor)) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
}
|