68 lines
2.4 KiB
Java
68 lines
2.4 KiB
Java
package com.gh.gamecenter.adapter;
|
|
|
|
import android.content.Context;
|
|
import android.text.Html;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
|
|
import com.gh.common.util.LibaoUtils;
|
|
import com.gh.common.util.StringUtils;
|
|
import com.gh.gamecenter.R;
|
|
import com.gh.gamecenter.adapter.viewholder.LiBaoCodeViewHolder;
|
|
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(mLayoutInflater.inflate(R.layout.libao_code_item, parent, false));
|
|
}
|
|
|
|
@Override
|
|
public void onBindViewHolder(LiBaoCodeViewHolder holder, int position) {
|
|
final UserDataLibaoEntity userDataLibaoEntity = mUserDataLibaoList.get(position);
|
|
if ("ling".equals(userDataLibaoEntity.getType()) || "linged".equals(userDataLibaoEntity.getType())) {
|
|
StringBuffer content = new StringBuffer();
|
|
if (mUserDataLibaoList.size() > 1) {
|
|
content.append(" " + (position + 1) + "   ");
|
|
}
|
|
content.append(StringUtils.buildString("已领取:", "<font color=\"#00B7FA\">", userDataLibaoEntity.getCode(), "</font>"));
|
|
holder.code.setText(Html.fromHtml(content.toString()));
|
|
} else {
|
|
StringBuffer content = new StringBuffer();
|
|
if (mUserDataLibaoList.size() > 1) {
|
|
content.append(" " + (position + 1) + "   ");
|
|
}
|
|
content.append(StringUtils.buildString("已淘号:", "<font color=\"#ffb13c\">", userDataLibaoEntity.getCode(), "</font>"));
|
|
holder.code.setText(Html.fromHtml(content.toString()));
|
|
}
|
|
|
|
holder.copy.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
LibaoUtils.copyLink(userDataLibaoEntity.getCode(), mContext);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override
|
|
public int getItemCount() {
|
|
return mUserDataLibaoList.size();
|
|
}
|
|
}
|