SuggestionsAdapter.java revision fd4a4cbc1143a734d357897531daa7105db6459b
1/* 2 * Copyright (C) 2010 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 */ 16package com.android.quicksearchbox.ui; 17 18import com.android.quicksearchbox.Promoter; 19import com.android.quicksearchbox.SuggestionCursor; 20import com.android.quicksearchbox.Suggestions; 21 22import android.view.View.OnFocusChangeListener; 23import android.widget.ExpandableListAdapter; 24import android.widget.ListAdapter; 25 26/** 27 * Interface for suggestions adapters. 28 * 29 * @param <A> the adapter class used by the UI, probably either {@link ListAdapter} or 30 * {@link ExpandableListAdapter}. 31 */ 32public interface SuggestionsAdapter<A> { 33 /** 34 * Request a notification when the structure of the adapter changes, usually due to the number 35 * of view types it can provide changing. 36 */ 37 void setSuggestionAdapterChangeListener(SuggestionsAdapterChangeListener l); 38 39 /** 40 * Sets the maximum number of promoted suggestions to be provided by this adapter. 41 */ 42 void setMaxPromoted(int maxPromoted); 43 44 /** 45 * Sets the suggestion promoter. 46 */ 47 void setPromoter(Promoter promoter); 48 49 /** 50 * Sets the listener to be notified of clicks on suggestions. 51 */ 52 void setSuggestionClickListener(SuggestionClickListener listener); 53 54 /** 55 * Sets the listener to be notified of focus change events on suggestion views. 56 */ 57 void setOnFocusChangeListener(OnFocusChangeListener l); 58 59 /** 60 * Sets the current suggestions. 61 */ 62 void setSuggestions(Suggestions suggestions); 63 64 /** 65 * Gets the current suggestions. 66 */ 67 Suggestions getSuggestions(); 68 69 /** 70 * Gets the current list of promoted suggestions. 71 */ 72 SuggestionCursor getCurrentPromotedSuggestions(); 73 74 /** 75 * Handles a regular click on a suggestion. 76 */ 77 void onSuggestionClicked(int position); 78 79 /** 80 * Handles a click on a quick contact badge. 81 */ 82 void onSuggestionQuickContactClicked(int position); 83 84 /** 85 * Handles a request to remove a suggestion from history. 86 */ 87 void onSuggestionRemoveFromHistoryClicked(int position); 88 89 /** 90 * Handles a click on the query refinement button. 91 */ 92 void onSuggestionQueryRefineClicked(int position); 93 94 /** 95 * Gets the adapter to be used by the UI view. 96 */ 97 A getListAdapter(); 98 99 void setIcon1Enabled(boolean enabled); 100 101 /** 102 * Callback interface used to notify the view when the adapter has changed (i.e. the number and 103 * type of views returned has changed). 104 */ 105 public interface SuggestionsAdapterChangeListener { 106 void onSuggestionAdapterChanged(); 107 } 108 109} 110