ContactSuggestionView.java revision 5229b06f00d20aac76cd8519b37f2a579d61c54f
1/* 2 * Copyright (C) 2009 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.quicksearchbox.ui; 18 19import com.android.quicksearchbox.R; 20import com.android.quicksearchbox.Suggestion; 21 22import android.content.Context; 23import android.net.Uri; 24import android.util.AttributeSet; 25import android.view.View; 26 27/** 28 * View for contacts appearing in the suggestions list. 29 */ 30public class ContactSuggestionView extends DefaultSuggestionView { 31 32 public static final String VIEW_ID = "contact"; 33 34 private ContactBadge mQuickContact; 35 36 public ContactSuggestionView(Context context, AttributeSet attrs, int defStyle) { 37 super(context, attrs, defStyle); 38 } 39 40 public ContactSuggestionView(Context context, AttributeSet attrs) { 41 super(context, attrs); 42 } 43 44 public ContactSuggestionView(Context context) { 45 super(context); 46 } 47 48 @Override 49 protected void onFinishInflate() { 50 super.onFinishInflate(); 51 mQuickContact = (ContactBadge) findViewById(R.id.icon1); 52 } 53 54 @Override 55 public void bindAsSuggestion(Suggestion suggestion, String userQuery) { 56 super.bindAsSuggestion(suggestion, userQuery); 57 mQuickContact.assignContactUri(Uri.parse(suggestion.getSuggestionIntentDataString())); 58 mQuickContact.setExtraOnClickListener(new ContactBadgeClickListener()); 59 } 60 61 private class ContactBadgeClickListener implements View.OnClickListener { 62 public void onClick(View v) { 63 onSuggestionQuickContactClicked(); 64 } 65 } 66}