public void render(@Nullable final SearchSuggestionRVItem item,
@Nullable final OnClickListener listener) {
if (!hasContext() || item == null) {
return;
}
mItem = item;
if (listener != null) {
mListener = listener;
}
mSuggestionField.setText(item.getSuggestion());
if (mSuggestionField instanceof TintableBackgroundView) {
// "AppCompatTextView" and "com.android.support:appcompat-v7" are used, tint all states
ViewCompat.setBackgroundTintList(mSuggestionField,
new ColorStateList(STATES, new int[]{
AbstractColorUtils.getColor(getContext(), item.getPlaceholder()),
AbstractColorUtils.getColor(getContext(), R.color.tenor_sdk_primary_color)}));
return;
}
// "com.android.support:appcompat-v7" is likely not being used, and thus "TextView" is used
Drawable background = mSuggestionField.getBackground();
if (background instanceof TintAwareDrawable) {
// tint all states of the given drawable
DrawableCompat.setTintList(background,
new ColorStateList(STATES, new int[]{
AbstractColorUtils.getColor(getContext(), item.getPlaceholder()),
AbstractColorUtils.getColor(getContext(), R.color.tenor_sdk_primary_color)}));
return;
}
// last option, tint only the background individually
AbstractDrawableUtils.setDrawableTint(getContext(), background, item.getPlaceholder());
}
SearchSuggestionVH.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:tenor-android-demo-search
作者:
评论列表
文章目录