forked from PhilJay/MPAndroidChart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyAdapter.java
More file actions
72 lines (51 loc) · 2 KB
/
MyAdapter.java
File metadata and controls
72 lines (51 loc) · 2 KB
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
package com.xxmassdeveloper.mpchartexample.notimportant;
import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.xxmassdeveloper.mpchartexample.R;
import java.util.List;
/**
* Created by Philipp Jahoda on 07/12/15.
*/
public class MyAdapter extends ArrayAdapter<ContentItem> {
private Typeface mTypeFaceLight;
private Typeface mTypeFaceRegular;
public MyAdapter(Context context, List<ContentItem> objects) {
super(context, 0, objects);
mTypeFaceLight = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf");
mTypeFaceRegular = Typeface.createFromAsset(context.getAssets(), "OpenSans-Regular.ttf");
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ContentItem c = getItem(position);
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, null);
holder.tvName = (TextView) convertView.findViewById(R.id.tvName);
holder.tvDesc = (TextView) convertView.findViewById(R.id.tvDesc);
holder.tvNew = (TextView) convertView.findViewById(R.id.tvNew);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.tvNew.setTypeface(mTypeFaceRegular);
holder.tvName.setTypeface(mTypeFaceLight);
holder.tvDesc.setTypeface(mTypeFaceLight);
holder.tvName.setText(c.name);
holder.tvDesc.setText(c.desc);
if(c.isNew)
holder.tvNew.setVisibility(View.VISIBLE);
else
holder.tvNew.setVisibility(View.GONE);
return convertView;
}
private class ViewHolder {
TextView tvName, tvDesc;
TextView tvNew;
}
}