Skip to content

Commit

Permalink
add skin support for CompoundButton
Browse files Browse the repository at this point in the history
  • Loading branch information
cgspine committed Apr 6, 2020
1 parent 7c1bdae commit 4eae96c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ImageView;

import com.qmuiteam.qmui.QMUILog;
import com.qmuiteam.qmui.skin.QMUISkinHelper;

import org.jetbrains.annotations.NotNull;
Expand All @@ -31,7 +31,9 @@ protected void handle(@NotNull View view, @NotNull String name, Drawable drawabl

if (view instanceof ImageView) {
((ImageView) view).setImageDrawable(drawable);
}else{
} else if (view instanceof CompoundButton) {
((CompoundButton) view).setButtonDrawable(drawable);
} else {
QMUISkinHelper.warnRuleNotSupport(view, name);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@

import android.content.res.ColorStateList;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ImageView;

import com.qmuiteam.qmui.skin.QMUISkinHelper;
import com.qmuiteam.qmui.util.QMUIViewHelper;
import com.qmuiteam.qmui.widget.QMUILoadingView;
import com.qmuiteam.qmui.widget.pullRefreshLayout.QMUIPullRefreshLayout;

import androidx.core.widget.CompoundButtonCompat;
import androidx.core.widget.ImageViewCompat;

import org.jetbrains.annotations.NotNull;
Expand All @@ -41,6 +43,8 @@ protected void handle(@NotNull View view, @NotNull String name, ColorStateList c
((QMUIPullRefreshLayout.RefreshView)view).setColorSchemeColors(colorStateList.getDefaultColor());
}else if (view instanceof ImageView) {
ImageViewCompat.setImageTintList((ImageView) view, colorStateList);
}else if(view instanceof CompoundButton){
CompoundButtonCompat.setButtonTintList((CompoundButton)view, colorStateList);
}else{
QMUISkinHelper.warnRuleNotSupport(view, name);
}
Expand Down

0 comments on commit 4eae96c

Please sign in to comment.