Runt
2022-08-13 b3a51f064c4dfb27f54cd9526803338d2e8dc296
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.runt.open.mvvm.ui.adapter;
 
import android.content.Context;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.runt.open.mvvm.BuildConfig;
import com.runt.open.mvvm.R;
import com.runt.open.mvvm.base.adapter.BaseAdapter;
import com.runt.open.mvvm.data.Results;
import com.runt.open.mvvm.databinding.ItemCoinReportBinding;
import com.runt.open.mvvm.ui.login.UserBean;
import com.runt.open.mvvm.util.HandleDate;
 
/**
 * 金币记录
 * @purpose Created by Runt (qingingrunt2010@qq.com) on 2020-10-29.
 */
public class CoinTransAdapter extends BaseAdapter<Results.CustomCoin, ItemCoinReportBinding> {
    @Override
    protected void onBindView(ItemCoinReportBinding binding, int position, Results.CustomCoin data) {
 
        Context context = binding.getRoot().getContext();
        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.default_head)//图片加载出来前,显示的图片
                .fallback(R.mipmap.default_head) //url为空的时候,显示的图片
                .error(R.mipmap.default_head);//图片加载失败后,显示的图片
        boolean isOut = data.fromUser != null && data.fromUser.getId().equals(UserBean.getUser().getId());
        String type = "";
        switch (data.type) {
            case 0:
                type = "赠送";
                break;
            case 1:
                type = "每日登录";
                break;
            case 2:
                type = "签到赠送";
                break;
            case 3:
                type = "广告赠送";
                break;
            case 4:
                type = "激励广告赠送";
                break;
            case 5:
                type = "转帐";
                break;
            case 6:
                type = "提现";
                break;
            case 7:
                type = "注册赠送";
                break;
 
        }
        if (isOut) {
            binding.txtName.setText((data.type == 5?"":"转账到-")+(data.toUser == null ? type : data.toUser.getUsername()));
            binding.txtCount.setText("-" + data.count);
            binding.txtCount.setTextColor(context.getResources().getColor(R.color.holo_red_light));
            Glide.with(binding.getRoot().getContext()).load(BuildConfig.HOST_IP_ADDR + (data.toUser == null ? "" : data.toUser.getHead())).apply(options).into(binding.imgHead);
        } else {
            binding.txtName.setText((data.fromUser == null ? type : data.fromUser.getUsername())+(data.type == 5?"-转账":""));
            binding.txtCount.setTextColor(context.getResources().getColor(R.color.green));
            binding.txtCount.setText("+" + data.count);
            Glide.with(binding.getRoot().getContext()).load(BuildConfig.HOST_IP_ADDR + (data.fromUser == null ? "" : data.fromUser.getHead())).apply(options).into(binding.imgHead);
        }
        binding.txtTime.setText(HandleDate.getTimeStateNew(HandleDate.getDateTimeToLong(data.cTime)));
    }
}