1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.ex.chips;
18
19import android.content.Context;
20import android.graphics.drawable.StateListDrawable;
21import android.view.View;
22import android.view.ViewGroup;
23import android.widget.ArrayAdapter;
24
25import com.android.ex.chips.DropdownChipLayouter.AdapterType;
26
27class SingleRecipientArrayAdapter extends ArrayAdapter<RecipientEntry> {
28    private final DropdownChipLayouter mDropdownChipLayouter;
29    private final StateListDrawable mDeleteDrawable;
30
31    public SingleRecipientArrayAdapter(Context context, RecipientEntry entry,
32        DropdownChipLayouter dropdownChipLayouter) {
33        this(context, entry, dropdownChipLayouter, null);
34    }
35
36    public SingleRecipientArrayAdapter(Context context, RecipientEntry entry,
37            DropdownChipLayouter dropdownChipLayouter, StateListDrawable deleteDrawable) {
38        super(context,
39                dropdownChipLayouter.getAlternateItemLayoutResId(AdapterType.SINGLE_RECIPIENT),
40                new RecipientEntry[] { entry });
41
42        mDropdownChipLayouter = dropdownChipLayouter;
43        mDeleteDrawable = deleteDrawable;
44    }
45
46    @Override
47    public View getView(int position, View convertView, ViewGroup parent) {
48        return mDropdownChipLayouter.bindView(convertView, parent, getItem(position), position,
49                AdapterType.SINGLE_RECIPIENT, null, mDeleteDrawable);
50    }
51}
52