admin
2021-05-28 98cc34dbca6d6218ec5e72baffda2d3a1dd72a55
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.tejia.lijin.app.ui.recommend;
 
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
 
import com.tejia.lijin.app.util.JumpActivityUtil;
import com.wpc.library.util.common.StringUtils;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.tejia.lijin.app.R;
import com.tejia.lijin.app.entity.SpecialOffer;
import com.tejia.lijin.app.ui.invite.ShareBrowserActivity;
 
import java.util.Iterator;
import java.util.List;
 
/**
 * Created by weikou2015 on 2017/2/23.
 */
 
public class SpecialOfferAdapter extends BaseAdapter {
    private Context mContext;
 
    private List<SpecialOffer> mList;
 
    public SpecialOfferAdapter(Context context, List<SpecialOffer> list) {
        mContext = context;
        mList = list;
    }
 
    @Override
    public int getCount() {
        return mList == null ? 0 : mList.size();
    }
 
    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }
 
    @Override
    public long getItemId(int position) {
        return position;
    }
 
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.item_first_page_category, null);
        TextView tv_name = convertView.findViewById(R.id.tv_name);
        TextView tv_des = convertView.findViewById(R.id.tv_des);
        ImageView iv_category = convertView.findViewById(R.id.iv_category);
        tv_name.setText(mList.get(position).getName() + "");
        tv_des.setText(mList.get(position).getTag());
//        Glide.with(mContext).load(mList.get(position).getPicture()).into(iv_category);
        ImageLoader.getInstance().displayImage(mList.get(position).getPicture(), iv_category);
        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = null;
                if ((!StringUtils.isEmpty(mList.get(position).getJumpDetail().getActivity()))
                        && mList.get(position).getParams() != null) {
                    try {
                        intent = new Intent(mContext, Class.forName(JumpActivityUtil.filterActivityName(mList.get(position).getJumpDetail().getActivity())));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    if (mList.get(position).getParams() != null) {
                        @SuppressWarnings("unchecked")
                        Iterator<String> its = mList.get(position).getParams().keys();
                        while (its.hasNext()) {
                            String key = its.next();
                            String value = mList.get(position).getParams().optString(key);
                            intent.putExtra(key, value);
                        }
                    }
 
                    mContext.startActivity(intent);
                } else if (StringUtils.isEmpty(mList.get(position).getJumpDetail().getActivity())
                        && mList.get(position).getParams() != null) {
                    intent = new Intent(mContext, ShareBrowserActivity.class);
 
                    if (mList.get(position).getParams() != null) {
                        @SuppressWarnings("unchecked")
                        Iterator<String> its = mList.get(position).getParams().keys();
                        while (its.hasNext()) {
                            String key = its.next();
                            String value = mList.get(position).getParams().optString(key);
                            intent.putExtra(key, value);
                        }
                    }
                    mContext.startActivity(intent);
                }
            }
        });
        return convertView;
    }
}