blob: f08746ef6f98c270715d659a001d74ef2345412a [file] [log] [blame]
Mindy Pereira01382d72011-07-15 16:52:32 -07001/*
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;
Jin Cao4db8ccc2014-07-30 10:11:07 -070020import android.graphics.drawable.StateListDrawable;
Mindy Pereira01382d72011-07-15 16:52:32 -070021import android.view.View;
22import android.view.ViewGroup;
23import android.widget.ArrayAdapter;
Kevin Linb10d1c62014-01-24 12:45:00 -080024
25import com.android.ex.chips.DropdownChipLayouter.AdapterType;
Mindy Pereira01382d72011-07-15 16:52:32 -070026
27class SingleRecipientArrayAdapter extends ArrayAdapter<RecipientEntry> {
Kevin Linb10d1c62014-01-24 12:45:00 -080028 private final DropdownChipLayouter mDropdownChipLayouter;
Jin Cao4db8ccc2014-07-30 10:11:07 -070029 private final StateListDrawable mDeleteDrawable;
Mindy Pereira01382d72011-07-15 16:52:32 -070030
Kevin Linb10d1c62014-01-24 12:45:00 -080031 public SingleRecipientArrayAdapter(Context context, RecipientEntry entry,
Jin Cao4db8ccc2014-07-30 10:11:07 -070032 DropdownChipLayouter dropdownChipLayouter) {
33 this(context, entry, dropdownChipLayouter, null);
34 }
35
36 public SingleRecipientArrayAdapter(Context context, RecipientEntry entry,
37 DropdownChipLayouter dropdownChipLayouter, StateListDrawable deleteDrawable) {
Jin Cao4ddcdae2014-07-28 19:03:56 -070038 super(context,
39 dropdownChipLayouter.getAlternateItemLayoutResId(AdapterType.SINGLE_RECIPIENT),
40 new RecipientEntry[] { entry });
Kevin Linb10d1c62014-01-24 12:45:00 -080041
42 mDropdownChipLayouter = dropdownChipLayouter;
Jin Cao4db8ccc2014-07-30 10:11:07 -070043 mDeleteDrawable = deleteDrawable;
Mindy Pereira01382d72011-07-15 16:52:32 -070044 }
45
46 @Override
47 public View getView(int position, View convertView, ViewGroup parent) {
Kevin Linb10d1c62014-01-24 12:45:00 -080048 return mDropdownChipLayouter.bindView(convertView, parent, getItem(position), position,
Jin Cao4db8ccc2014-07-30 10:11:07 -070049 AdapterType.SINGLE_RECIPIENT, null, mDeleteDrawable);
Mindy Pereira01382d72011-07-15 16:52:32 -070050 }
51}