File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
android/src/main/java/com/lmy/header Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 11package com .lmy .header ;
22
33import android .content .Context ;
4+ import android .graphics .drawable .BitmapDrawable ;
45import android .support .annotation .ColorInt ;
56import android .support .annotation .NonNull ;
67import android .view .View ;
2021public class AnyHeader extends ReactViewGroup implements RefreshHeader {
2122 private RefreshKernel mRefreshKernel ;
2223 private int mBackgroundColor ;
24+ private Integer mPrimaryColor ;
2325 private SpinnerStyle mSpinnerStyle = SpinnerStyle .Translate ;
2426
2527 public AnyHeader (Context context ) {
@@ -47,15 +49,24 @@ public SpinnerStyle getSpinnerStyle() {
4749 return this .mSpinnerStyle ;//指定为平移,不能null
4850 }
4951
52+ /**
53+ * 设置主题色
54+ * @param colors
55+ */
5056 @ Override
5157 public void setPrimaryColors (int ... colors ) {
52-
58+ if (colors .length >0 ) {
59+ if (!(getBackground () instanceof BitmapDrawable ) && mPrimaryColor == null ) {
60+ setPrimaryColor (colors [0 ]);
61+ mPrimaryColor = null ;
62+ }
63+ }
5364 }
5465
5566 public AnyHeader setPrimaryColor (@ ColorInt int primaryColor ) {
56- mBackgroundColor = primaryColor ;
67+ mBackgroundColor = mPrimaryColor = primaryColor ;
5768 if (mRefreshKernel != null ) {
58- mRefreshKernel .requestDrawBackgroundForHeader (primaryColor );
69+ mRefreshKernel .requestDrawBackgroundForHeader (mPrimaryColor );
5970 }
6071 return this ;
6172 }
You can’t perform that action at this time.
0 commit comments