5package io.flutter.util;
9import android.content.ContextWrapper;
12import androidx.annotation.NonNull;
13import androidx.annotation.Nullable;
14import androidx.window.layout.WindowMetrics;
15import androidx.window.layout.WindowMetricsCalculator;
30 if (activity !=
null) {
31 WindowMetrics metrics =
32 WindowMetricsCalculator.getOrCreate().computeMaximumWindowMetrics(activity);
33 float width = metrics.getBounds().width();
34 float height = metrics.getBounds().height();
35 float density = context.getResources().getDisplayMetrics().density;
36 updater.updateDisplayMetrics(
width,
height, density);
47 public static Activity
getActivity(@Nullable Context context) {
48 if (context ==
null) {
51 if (context instanceof Activity) {
52 return (Activity) context;
54 if (context instanceof ContextWrapper) {
56 return getActivity(((ContextWrapper) context).getBaseContext());
82 for (
int i = 0;
i < viewTypes.length;
i++) {
83 final Class<? extends View> viewType = viewTypes[
i];
84 if (viewType.isInstance(view)) {
94 boolean run(@NonNull View view);
113 if (visitor.run(
root)) {
116 if (
root instanceof ViewGroup) {
117 final ViewGroup viewGroup = (ViewGroup)
root;
118 for (
int idx = 0; idx < viewGroup.getChildCount(); idx++) {
static boolean traverseHierarchy(@Nullable View root, @NonNull ViewVisitor visitor)
static Activity getActivity(@Nullable Context context)
static boolean childHasFocus(@Nullable View root)
static boolean hasChildViewOfType(@Nullable View root, Class<? extends View >[] viewTypes)
static void calculateMaximumDisplayMetrics( @Nullable Context context, @NonNull DisplayUpdater updater)
void updateDisplayMetrics(float width, float height, float density)
boolean run(@NonNull View view)