package com.cooleshow.base.utils; import android.content.Context; import android.os.Build; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.Locale; import androidx.annotation.LayoutRes; /** *
* author: Blankj * blog : http://blankj.com * time : 2019/06/18 * desc : utils about view **/ public class ViewUtils { /** * Set the enabled state of this view. * * @param view The view. * @param enabled True to enabled, false otherwise. */ public static void setViewEnabled(View view, boolean enabled) { setViewEnabled(view, enabled, (View) null); } /** * Set the enabled state of this view. * * @param view The view. * @param enabled True to enabled, false otherwise. * @param excludes The excludes. */ public static void setViewEnabled(View view, boolean enabled, View... excludes) { if (view == null) return; if (excludes != null) { for (View exclude : excludes) { if (view == exclude) return; } } if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; int childCount = viewGroup.getChildCount(); for (int i = 0; i < childCount; i++) { setViewEnabled(viewGroup.getChildAt(i), enabled, excludes); } } view.setEnabled(enabled); } /** * @param runnable The runnable */ public static void runOnUiThread(final Runnable runnable) { UtilsBridge.runOnUiThread(runnable); } /** * @param runnable The runnable. * @param delayMillis The delay (in milliseconds) until the Runnable will be executed. */ public static void runOnUiThreadDelayed(final Runnable runnable, long delayMillis) { UtilsBridge.runOnUiThreadDelayed(runnable, delayMillis); } /** * Return whether horizontal layout direction of views are from Right to Left. * * @return {@code true}: yes