blob: 7ac3401a0d505935685d9392fac1c6bc823c0e8d (
plain)
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
|
package com.mapbox.mapboxsdk.testapp.adapter;
import android.graphics.Typeface;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.model.activity.Feature;
import com.mapbox.mapboxsdk.testapp.utils.FontCache;
import java.util.List;
/**
* Adapter used for FeatureOverviewActivity.
* <p>
* Adapts a Feature to a visual representation to be shown in a RecyclerView.
* </p>
*/
public class FeatureAdapter extends RecyclerView.Adapter<FeatureAdapter.ViewHolder> {
private List<Feature> features;
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView labelView;
public TextView descriptionView;
public ViewHolder(View view) {
super(view);
Typeface typeface = FontCache.get("Roboto-Regular.ttf", view.getContext());
labelView = (TextView) view.findViewById(R.id.nameView);
labelView.setTypeface(typeface);
descriptionView = (TextView) view.findViewById(R.id.descriptionView);
descriptionView.setTypeface(typeface);
}
}
public FeatureAdapter(List<Feature> features) {
this.features = features;
}
@Override
public FeatureAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_feature, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.labelView.setText(features.get(position).getLabel());
holder.descriptionView.setText(features.get(position).getDescription());
}
@Override
public int getItemCount() {
return features.size();
}
}
|