blob: 1f8519bbb2156ac53aed7f7270794f91a8055d21 [file] [log] [blame]
Michael Chan47f3f702009-07-23 16:01:07 -07001/*
Dmitri Plotnikovee212202010-08-27 17:58:19 -07002 * Copyright (C) 2010 The Android Open Source Project
Michael Chan47f3f702009-07-23 16:01:07 -07003 *
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.calendar;
18
Dmitri Plotnikovee212202010-08-27 17:58:19 -070019import com.android.common.contacts.BaseEmailAddressAdapter;
Mindy Pereira18cabd22011-06-09 18:31:23 -070020import com.android.ex.chips.AccountSpecifier;
Dmitri Plotnikovee212202010-08-27 17:58:19 -070021
Michael Chan47f3f702009-07-23 16:01:07 -070022import android.content.Context;
Dmitri Plotnikovee212202010-08-27 17:58:19 -070023import android.text.TextUtils;
24import android.view.LayoutInflater;
Michael Chan47f3f702009-07-23 16:01:07 -070025import android.view.View;
Dmitri Plotnikovee212202010-08-27 17:58:19 -070026import android.view.ViewGroup;
Michael Chan47f3f702009-07-23 16:01:07 -070027import android.widget.TextView;
28
Dmitri Plotnikovee212202010-08-27 17:58:19 -070029/**
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 Pereira18cabd22011-06-09 18:31:23 -070034public class EmailAddressAdapter extends BaseEmailAddressAdapter implements AccountSpecifier {
Michael Chan368530b2009-09-16 17:34:28 -070035
Dmitri Plotnikovee212202010-08-27 17:58:19 -070036 private LayoutInflater mInflater;
Michael Chan368530b2009-09-16 17:34:28 -070037
Dmitri Plotnikovee212202010-08-27 17:58:19 -070038 public EmailAddressAdapter(Context context) {
39 super(context);
40 mInflater = LayoutInflater.from(context);
41 }
Michael Chan368530b2009-09-16 17:34:28 -070042
Dmitri Plotnikovee212202010-08-27 17:58:19 -070043 @Override
44 protected View inflateItemView(ViewGroup parent) {
45 return mInflater.inflate(R.layout.email_autocomplete_item, parent, false);
46 }
Michael Chan368530b2009-09-16 17:34:28 -070047
Dmitri Plotnikovee212202010-08-27 17:58:19 -070048 @Override
49 protected View inflateItemViewLoading(ViewGroup parent) {
50 return mInflater.inflate(R.layout.email_autocomplete_item_loading, parent, false);
51 }
Michael Chan47f3f702009-07-23 16:01:07 -070052
Dmitri Plotnikovee212202010-08-27 17:58:19 -070053 @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 Chan47f3f702009-07-23 16:01:07 -070061
Dmitri Plotnikovee212202010-08-27 17:58:19 -070062 @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 Chan47f3f702009-07-23 16:01:07 -070069}