Optimize Utils

androidx
Zhanty 5 years ago
parent 287c94a567
commit 8bb6b52250
  1. 1
      lib_base/src/main/java/com/android/base/utils/android/TintUtils.java
  2. 20
      lib_base/src/main/java/com/android/base/utils/android/compat/SystemBarCompat.java
  3. 2
      lib_base/src/main/res/values/base_ids.xml

@ -33,6 +33,7 @@ import android.support.v4.graphics.drawable.DrawableCompat;
* bbbTv.setCompoundDrawablesWithIntrinsicBounds(null, bbbTint, null, null); * bbbTv.setCompoundDrawablesWithIntrinsicBounds(null, bbbTint, null, null);
* </pre> * </pre>
*/ */
@SuppressWarnings("unused,WeakerAccess")
public class TintUtils { public class TintUtils {
private TintUtils() { private TintUtils() {

@ -22,6 +22,8 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import com.android.base.R;
import timber.log.Timber; import timber.log.Timber;
/** /**
@ -172,13 +174,17 @@ public class SystemBarCompat {
*/ */
@SuppressWarnings("WeakerAccess,unused") @SuppressWarnings("WeakerAccess,unused")
public static View setupStatusBarView(Context context, ViewGroup rootView, @ColorInt int color) { public static View setupStatusBarView(Context context, ViewGroup rootView, @ColorInt int color) {
View mStatusBarTintView = new View(context); View statusBarTintView = rootView.findViewById(R.id.base_status_view_id);
mStatusBarTintView.setBackgroundColor(color); if (statusBarTintView == null) {
FrameLayout.LayoutParams mStatusBarParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, getStatusBarHeight(context)); statusBarTintView = new View(context);
mStatusBarParams.gravity = Gravity.TOP; statusBarTintView.setId(R.id.base_status_view_id);
mStatusBarTintView.setLayoutParams(mStatusBarParams); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, getStatusBarHeight(context));
rootView.addView(mStatusBarTintView, 0); layoutParams.gravity = Gravity.TOP;
return mStatusBarTintView; statusBarTintView.setLayoutParams(layoutParams);
rootView.addView(statusBarTintView, 0);
}
statusBarTintView.setBackgroundColor(color);
return statusBarTintView;
} }
/** /**

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<item name="base_status_view_id" type="id"/>
<item name="base_item_tag_view_id" type="id"/> <item name="base_item_tag_view_id" type="id"/>
<item name="base_tag_multi_state_view" type="id"/> <item name="base_tag_multi_state_view" type="id"/>

Loading…
Cancel
Save