Michael Chan | 47f3f70 | 2009-07-23 16:01:07 -0700 | [diff] [blame] | 1 | /* |
Dmitri Plotnikov | ee21220 | 2010-08-27 17:58:19 -0700 | [diff] [blame] | 2 | * Copyright (C) 2010 The Android Open Source Project |
Michael Chan | 47f3f70 | 2009-07-23 16:01:07 -0700 | [diff] [blame] | 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.calendar; |
| 18 | |
Dmitri Plotnikov | ee21220 | 2010-08-27 17:58:19 -0700 | [diff] [blame] | 19 | import com.android.common.contacts.BaseEmailAddressAdapter; |
Mindy Pereira | 18cabd2 | 2011-06-09 18:31:23 -0700 | [diff] [blame] | 20 | import com.android.ex.chips.AccountSpecifier; |
Dmitri Plotnikov | ee21220 | 2010-08-27 17:58:19 -0700 | [diff] [blame] | 21 | |
Michael Chan | 47f3f70 | 2009-07-23 16:01:07 -0700 | [diff] [blame] | 22 | import android.content.Context; |
Dmitri Plotnikov | ee21220 | 2010-08-27 17:58:19 -0700 | [diff] [blame] | 23 | import android.text.TextUtils; |
| 24 | import android.view.LayoutInflater; |
Michael Chan | 47f3f70 | 2009-07-23 16:01:07 -0700 | [diff] [blame] | 25 | import android.view.View; |
Dmitri Plotnikov | ee21220 | 2010-08-27 17:58:19 -0700 | [diff] [blame] | 26 | import android.view.ViewGroup; |
Michael Chan | 47f3f70 | 2009-07-23 16:01:07 -0700 | [diff] [blame] | 27 | import android.widget.TextView; |
| 28 | |
Dmitri Plotnikov | ee21220 | 2010-08-27 17:58:19 -0700 | [diff] [blame] | 29 | /** |
| 30 | * An adaptation of {@link BaseEmailAddressAdapter} for the Email app. The main |
| 31 | * purpose of the class is to bind the generic implementation to the resources |
| 32 | * defined locally: strings and layouts. |
| 33 | */ |
Mindy Pereira | 18cabd2 | 2011-06-09 18:31:23 -0700 | [diff] [blame] | 34 | public class EmailAddressAdapter extends BaseEmailAddressAdapter implements AccountSpecifier { |
Michael Chan | 368530b | 2009-09-16 17:34:28 -0700 | [diff] [blame] | 35 | |
Dmitri Plotnikov | ee21220 | 2010-08-27 17:58:19 -0700 | [diff] [blame] | 36 | private LayoutInflater mInflater; |
Michael Chan | 368530b | 2009-09-16 17:34:28 -0700 | [diff] [blame] | 37 | |
Dmitri Plotnikov | ee21220 | 2010-08-27 17:58:19 -0700 | [diff] [blame] | 38 | public EmailAddressAdapter(Context context) { |
| 39 | super(context); |
| 40 | mInflater = LayoutInflater.from(context); |
| 41 | } |
Michael Chan | 368530b | 2009-09-16 17:34:28 -0700 | [diff] [blame] | 42 | |
Dmitri Plotnikov | ee21220 | 2010-08-27 17:58:19 -0700 | [diff] [blame] | 43 | @Override |
| 44 | protected View inflateItemView(ViewGroup parent) { |
| 45 | return mInflater.inflate(R.layout.email_autocomplete_item, parent, false); |
| 46 | } |
Michael Chan | 368530b | 2009-09-16 17:34:28 -0700 | [diff] [blame] | 47 | |
Dmitri Plotnikov | ee21220 | 2010-08-27 17:58:19 -0700 | [diff] [blame] | 48 | @Override |
| 49 | protected View inflateItemViewLoading(ViewGroup parent) { |
| 50 | return mInflater.inflate(R.layout.email_autocomplete_item_loading, parent, false); |
| 51 | } |
Michael Chan | 47f3f70 | 2009-07-23 16:01:07 -0700 | [diff] [blame] | 52 | |
Dmitri Plotnikov | ee21220 | 2010-08-27 17:58:19 -0700 | [diff] [blame] | 53 | @Override |
| 54 | protected void bindView(View view, String directoryType, String directoryName, |
| 55 | String displayName, String emailAddress) { |
| 56 | TextView text1 = (TextView)view.findViewById(R.id.text1); |
| 57 | TextView text2 = (TextView)view.findViewById(R.id.text2); |
| 58 | text1.setText(displayName); |
| 59 | text2.setText(emailAddress); |
| 60 | } |
Michael Chan | 47f3f70 | 2009-07-23 16:01:07 -0700 | [diff] [blame] | 61 | |
Dmitri Plotnikov | ee21220 | 2010-08-27 17:58:19 -0700 | [diff] [blame] | 62 | @Override |
| 63 | protected void bindViewLoading(View view, String directoryType, String directoryName) { |
| 64 | TextView text1 = (TextView)view.findViewById(R.id.text1); |
| 65 | String text = getContext().getString(R.string.directory_searching_fmt, |
| 66 | TextUtils.isEmpty(directoryName) ? directoryType : directoryName); |
| 67 | text1.setText(text); |
| 68 | } |
Michael Chan | 47f3f70 | 2009-07-23 16:01:07 -0700 | [diff] [blame] | 69 | } |