RecipientAdapter.java revision f828f924217b72b41a6921bfc943065fd5719bca
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.email;
18
19import android.accounts.Account;
20import android.content.Context;
21
22import com.android.ex.chips.BaseRecipientAdapter;
23import com.android.ex.chips.RecipientEditTextView;
24
25public class RecipientAdapter extends BaseRecipientAdapter {
26    public RecipientAdapter(Context context, RecipientEditTextView list) {
27        super(context);
28    }
29
30    /**
31     * Set the account when known. Causes the search to prioritize contacts from
32     * that account.
33     */
34    @Override
35    public void setAccount(Account account) {
36        if (account != null) {
37            // TODO: figure out how to infer the contacts account
38            // type from the email account
39            super.setAccount(new android.accounts.Account(account.name, "unknown"));
40        }
41    }
42
43    @Override
44    protected int getDefaultPhotoResource() {
45        return R.drawable.ic_contact_picture;
46    }
47
48    @Override
49    protected int getItemLayout() {
50        return R.layout.chips_recipient_dropdown_item;
51    }
52}
53