sheQuAdapter = new SheQuAdapter(R.layout.shequ_item, resultList);
sheQuAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() { @Override public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) { switch (view.getId()) { case R.id.shequ_fayan: int is_essence = resultList.get(position).getIs_essence(); is_essence++; resultList.get(position).setIs_essence(is_essence); sheQuAdapter.notifyDataSetChanged(); ImageView img = view.findViewById(R.id.shequ_fayan); img.setBackgroundResource(R.drawable.service_online); window.showAtLocation(getActivity().findViewById(R.id.shequ), Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 0); break; case R.id.shequ_dianzan: int iscollect = resultList.get(position).getIscollect(); iscollect++; resultList.get(position).setIscollect(iscollect); sheQuAdapter.notifyDataSetChanged(); ImageView img2 = view.findViewById(R.id.shequ_dianzan); img2.setBackgroundResource(R.drawable.find_thumbs_up_true); break; case R.id.shequ_bixin: int isgive = resultList.get(position).getIsgive(); isgive++; resultList.get(position).setIsgive(isgive); sheQuAdapter.notifyDataSetChanged(); ImageView img1 = view.findViewById(R.id.shequ_bixin); img1.setBackgroundResource(R.drawable.find_like_img); break; case R.id.dashang: if (AlipayUtil.hasInstalledAlipayClient(getActivity())){ AlipayUtil.startAlipayClient(getActivity(),"FKX051943BERN1XTWGS664"); // 第二步获取到的字符串 }else{ Toast.makeText(getActivity(), "未检测到支付宝,无法实现打赏功能", Toast.LENGTH_SHORT); } break; } } }); }
public class SheQuAdapter extends BaseQuickAdapter<SheQu.ResultListBean, BaseViewHolder> { public SheQuAdapter(int layoutResId, @Nullable List<SheQu.ResultListBean> data) { super(layoutResId, data); } @Override protected void convert(BaseViewHolder helper, SheQu.ResultListBean item) { Glide.with(mContext).load(item.getIcon()).apply(RequestOptions.bitmapTransform(new CircleCrop())).into((ImageView) helper.getView(R.id.shequ_dainji_img)); helper.setText(R.id.shequ_dianji_text, item.getNickname()) .setText(R.id.shequ_text2, item.getDescription()) .setText(R.id.shequ_text3, item.getCrtime()) .addOnClickListener(R.id.shequ_fayan) .addOnClickListener(R.id.shequ_dianzan) .addOnClickListener(R.id.shequ_bixin) .addOnClickListener(R.id.dashang) .setText(R.id.fayan_text,String.valueOf(item.getIs_essence())) .setText(R.id.dianzan_text,String.valueOf(item.getIscollect())) .setText(R.id.bixin_text,String.valueOf(item.getIsgive())); } }