summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java
blob: fac7e34ce1048d0c875d61208a253b103cb2101b (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
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;

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 v) {
            super(v);
            Typeface typeface = FontCache.get("Roboto-Regular.ttf",v.getContext());
            labelView = (TextView) v.findViewById(R.id.nameView);
            labelView.setTypeface(typeface);
            descriptionView = (TextView) v.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 v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_feature, parent, false);
        return new ViewHolder(v);
    }

    @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();
    }
}