调整购买守护界面守护全年的文本颜色
This commit is contained in:
parent
b12547cd88
commit
f0231be306
@ -1,6 +1,12 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Shader;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -34,8 +40,9 @@ public class LiveNewGuardBuyItemsAdapter extends RecyclerView.Adapter<LiveNewGua
|
||||
public void setItems(List<GuardBuyBean> items) {
|
||||
this.items = items;
|
||||
}
|
||||
public void setOnItemSelectListener(OnItemSelectListener listener){
|
||||
this.itemSelect=listener;
|
||||
|
||||
public void setOnItemSelectListener(OnItemSelectListener listener) {
|
||||
this.itemSelect = listener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -75,10 +82,10 @@ public class LiveNewGuardBuyItemsAdapter extends RecyclerView.Adapter<LiveNewGua
|
||||
|
||||
buyButton.setOnClickListener(view -> {
|
||||
buyButton.setBackgroundResource(R.drawable.img_k_selected);
|
||||
changeItem((int)title.getTag());
|
||||
changeItem((int) title.getTag());
|
||||
notifyDataSetChanged();
|
||||
if(itemSelect!=null){
|
||||
itemSelect.onSelectId((int)title.getTag());
|
||||
if (itemSelect != null) {
|
||||
itemSelect.onSelectId((int) title.getTag());
|
||||
}
|
||||
|
||||
});
|
||||
@ -87,13 +94,32 @@ public class LiveNewGuardBuyItemsAdapter extends RecyclerView.Adapter<LiveNewGua
|
||||
private void setData(GuardBuyBean bean, int id) {
|
||||
String coin = bean.getCoin() + "";
|
||||
title.setText(bean.getName());
|
||||
if (getAbsoluteAdapterPosition() == 2) {//全年守护要渐变色
|
||||
int[] colors = {
|
||||
Color.parseColor("#E38100"),
|
||||
Color.parseColor("#F1B868"),
|
||||
Color.parseColor("#DA9505"),
|
||||
Color.parseColor("#FDB871"),
|
||||
Color.parseColor("#E57810")
|
||||
};
|
||||
float[] position = {
|
||||
0f,
|
||||
0.2f,
|
||||
0.4f,
|
||||
0.8f,
|
||||
1.0f
|
||||
};
|
||||
LinearGradient mLinearGradient = new LinearGradient(0, 0, title.getPaint().getTextSize() * title.getText().length(), 0, colors, position, Shader.TileMode.CLAMP);
|
||||
title.getPaint().setShader(mLinearGradient);
|
||||
title.invalidate();
|
||||
}
|
||||
title.setTag(id);
|
||||
String msgText = WordUtil.getString(R.string.buy_guard_back_coin);
|
||||
msg.setText(msgText + coin);
|
||||
this.coin.setText(coin);
|
||||
if(id==selectId){
|
||||
if (id == selectId) {
|
||||
buyButton.setBackgroundResource(R.drawable.img_k_selected);
|
||||
}else {
|
||||
} else {
|
||||
buyButton.setBackgroundResource(R.drawable.img_k_uncheck);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user