Mindy Pereira | 01382d7 | 2011-07-15 16:52:32 -0700 | [diff] [blame] | 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 | |
| 17 | package com.android.ex.chips; |
| 18 | |
| 19 | import android.content.Context; |
Jin Cao | 4db8ccc | 2014-07-30 10:11:07 -0700 | [diff] [blame] | 20 | import android.graphics.drawable.StateListDrawable; |
Mindy Pereira | 01382d7 | 2011-07-15 16:52:32 -0700 | [diff] [blame] | 21 | import android.view.View; |
| 22 | import android.view.ViewGroup; |
| 23 | import android.widget.ArrayAdapter; |
Kevin Lin | b10d1c6 | 2014-01-24 12:45:00 -0800 | [diff] [blame] | 24 | |
| 25 | import com.android.ex.chips.DropdownChipLayouter.AdapterType; |
Mindy Pereira | 01382d7 | 2011-07-15 16:52:32 -0700 | [diff] [blame] | 26 | |
| 27 | class SingleRecipientArrayAdapter extends ArrayAdapter<RecipientEntry> { |
Kevin Lin | b10d1c6 | 2014-01-24 12:45:00 -0800 | [diff] [blame] | 28 | private final DropdownChipLayouter mDropdownChipLayouter; |
Jin Cao | 4db8ccc | 2014-07-30 10:11:07 -0700 | [diff] [blame] | 29 | private final StateListDrawable mDeleteDrawable; |
Mindy Pereira | 01382d7 | 2011-07-15 16:52:32 -0700 | [diff] [blame] | 30 | |
Kevin Lin | b10d1c6 | 2014-01-24 12:45:00 -0800 | [diff] [blame] | 31 | public SingleRecipientArrayAdapter(Context context, RecipientEntry entry, |
Jin Cao | 4db8ccc | 2014-07-30 10:11:07 -0700 | [diff] [blame] | 32 | DropdownChipLayouter dropdownChipLayouter) { |
| 33 | this(context, entry, dropdownChipLayouter, null); |
| 34 | } |
| 35 | |
| 36 | public SingleRecipientArrayAdapter(Context context, RecipientEntry entry, |
| 37 | DropdownChipLayouter dropdownChipLayouter, StateListDrawable deleteDrawable) { |
Jin Cao | 4ddcdae | 2014-07-28 19:03:56 -0700 | [diff] [blame] | 38 | super(context, |
| 39 | dropdownChipLayouter.getAlternateItemLayoutResId(AdapterType.SINGLE_RECIPIENT), |
| 40 | new RecipientEntry[] { entry }); |
Kevin Lin | b10d1c6 | 2014-01-24 12:45:00 -0800 | [diff] [blame] | 41 | |
| 42 | mDropdownChipLayouter = dropdownChipLayouter; |
Jin Cao | 4db8ccc | 2014-07-30 10:11:07 -0700 | [diff] [blame] | 43 | mDeleteDrawable = deleteDrawable; |
Mindy Pereira | 01382d7 | 2011-07-15 16:52:32 -0700 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public View getView(int position, View convertView, ViewGroup parent) { |
Kevin Lin | b10d1c6 | 2014-01-24 12:45:00 -0800 | [diff] [blame] | 48 | return mDropdownChipLayouter.bindView(convertView, parent, getItem(position), position, |
Jin Cao | 4db8ccc | 2014-07-30 10:11:07 -0700 | [diff] [blame] | 49 | AdapterType.SINGLE_RECIPIENT, null, mDeleteDrawable); |
Mindy Pereira | 01382d7 | 2011-07-15 16:52:32 -0700 | [diff] [blame] | 50 | } |
| 51 | } |