65 lines
2.4 KiB
Java
65 lines
2.4 KiB
Java
package com.gh.gamecenter.adapter;
|
|
|
|
import android.content.Context;
|
|
import android.text.Html;
|
|
import android.view.ViewGroup;
|
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
import com.gh.common.util.LibaoUtils;
|
|
import com.gh.gamecenter.R;
|
|
import com.gh.gamecenter.adapter.viewholder.LiBaoCodeViewHolder;
|
|
import com.gh.gamecenter.databinding.LibaoCodeItemBinding;
|
|
import com.gh.gamecenter.entity.UserDataLibaoEntity;
|
|
import com.lightgame.adapter.BaseRecyclerAdapter;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* Created by khy on 2017/3/23.
|
|
*/
|
|
public class LiBaoCodeAdapter extends BaseRecyclerAdapter<LiBaoCodeViewHolder> {
|
|
|
|
private List<UserDataLibaoEntity> mUserDataLibaoList;
|
|
|
|
public LiBaoCodeAdapter(Context context, List<UserDataLibaoEntity> userDataLibaoList) {
|
|
super(context);
|
|
|
|
mUserDataLibaoList = userDataLibaoList;
|
|
}
|
|
|
|
|
|
@Override
|
|
public LiBaoCodeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
|
return new LiBaoCodeViewHolder(LibaoCodeItemBinding.inflate(mLayoutInflater, parent, false));
|
|
}
|
|
|
|
@Override
|
|
public void onBindViewHolder(LiBaoCodeViewHolder holder, int position) {
|
|
final UserDataLibaoEntity userDataLibaoEntity = mUserDataLibaoList.get(position);
|
|
holder.binding.libaoCodeTv.setTextColor(ContextCompat.getColor(mContext,R.color.text_subtitle));
|
|
if ("ling".equals(userDataLibaoEntity.getType()) || "linged".equals(userDataLibaoEntity.getType())) {
|
|
StringBuilder content = new StringBuilder();
|
|
if (mUserDataLibaoList.size() > 1) {
|
|
content.append(" ").append(position + 1).append("   ");
|
|
}
|
|
content.append(mContext.getString(R.string.linged_code, userDataLibaoEntity.getCode()));
|
|
holder.binding.libaoCodeTv.setText(Html.fromHtml(content.toString()));
|
|
} else {
|
|
StringBuilder content = new StringBuilder();
|
|
if (mUserDataLibaoList.size() > 1) {
|
|
content.append(" ").append(position + 1).append("   ");
|
|
}
|
|
content.append(mContext.getString(R.string.taoed_code, userDataLibaoEntity.getCode()));
|
|
holder.binding.libaoCodeTv.setText(Html.fromHtml(content.toString()));
|
|
}
|
|
|
|
holder.binding.libaoCopyBtn.setOnClickListener(v -> LibaoUtils.copyLink(userDataLibaoEntity.getCode(), mContext));
|
|
}
|
|
|
|
@Override
|
|
public int getItemCount() {
|
|
return mUserDataLibaoList.size();
|
|
}
|
|
}
|