SuggestionsAdapter.java revision fd4a4cbc1143a734d357897531daa7105db6459b
1185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert/* 2fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Copyright (C) 2010 The Android Open Source Project 3185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * 4185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License"); 5185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * you may not use this file except in compliance with the License. 6185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * You may obtain a copy of the License at 7185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * 8185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0 9185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * 10185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * Unless required by applicable law or agreed to in writing, software 11185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS, 12185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * See the License for the specific language governing permissions and 14185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * limitations under the License. 15185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert */ 16185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringertpackage com.android.quicksearchbox.ui; 17185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert 185229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwoodimport com.android.quicksearchbox.Promoter; 195229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwoodimport com.android.quicksearchbox.SuggestionCursor; 205229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwoodimport com.android.quicksearchbox.Suggestions; 215229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood 2266ee1cc883f77fee930587503ecdcd8d18f12b23Mathew Inwoodimport android.view.View.OnFocusChangeListener; 23fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwoodimport android.widget.ExpandableListAdapter; 24fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwoodimport android.widget.ListAdapter; 25b83882b9efa37ec0f20a0f1c85cf5ccc93194aeeBjorn Bringert 26185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert/** 27fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Interface for suggestions adapters. 28fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * 29fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * @param <A> the adapter class used by the UI, probably either {@link ListAdapter} or 30fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * {@link ExpandableListAdapter}. 31185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert */ 32fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwoodpublic interface SuggestionsAdapter<A> { 33fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 34fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Request a notification when the structure of the adapter changes, usually due to the number 35fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * of view types it can provide changing. 36fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 37fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void setSuggestionAdapterChangeListener(SuggestionsAdapterChangeListener l); 381e938ea2f5edefab446b9562b316bc5dc72adebbBryan Mawhinney 39fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 40fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Sets the maximum number of promoted suggestions to be provided by this adapter. 41fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 42fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void setMaxPromoted(int maxPromoted); 435229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood 44fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 45fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Sets the suggestion promoter. 46fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 47fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void setPromoter(Promoter promoter); 48185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert 49fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 50fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Sets the listener to be notified of clicks on suggestions. 51fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 52fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void setSuggestionClickListener(SuggestionClickListener listener); 53185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert 54713194910648268c094fa81b81f40ce2f7e39333Bjorn Bringert /** 55fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Sets the listener to be notified of focus change events on suggestion views. 56ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert */ 57fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void setOnFocusChangeListener(OnFocusChangeListener l); 58ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert 59ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert /** 60fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Sets the current suggestions. 61713194910648268c094fa81b81f40ce2f7e39333Bjorn Bringert */ 62fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void setSuggestions(Suggestions suggestions); 63185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert 64713194910648268c094fa81b81f40ce2f7e39333Bjorn Bringert /** 65fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Gets the current suggestions. 66713194910648268c094fa81b81f40ce2f7e39333Bjorn Bringert */ 67fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood Suggestions getSuggestions(); 68185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert 69fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 70fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Gets the current list of promoted suggestions. 71fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 72fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood SuggestionCursor getCurrentPromotedSuggestions(); 737010c51b51c97fa43d7b24d2158ecbc1d064e0a6Bjorn Bringert 74fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 75fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Handles a regular click on a suggestion. 76fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 77fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void onSuggestionClicked(int position); 787010c51b51c97fa43d7b24d2158ecbc1d064e0a6Bjorn Bringert 79fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 80fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Handles a click on a quick contact badge. 81fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 82fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void onSuggestionQuickContactClicked(int position); 837010c51b51c97fa43d7b24d2158ecbc1d064e0a6Bjorn Bringert 84fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 85fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Handles a request to remove a suggestion from history. 86fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 87fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void onSuggestionRemoveFromHistoryClicked(int position); 8866ee1cc883f77fee930587503ecdcd8d18f12b23Mathew Inwood 89fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 90fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Handles a click on the query refinement button. 91fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 92fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void onSuggestionQueryRefineClicked(int position); 93185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert 94fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 95fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Gets the adapter to be used by the UI view. 96fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 97fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood A getListAdapter(); 985229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood 99fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void setIcon1Enabled(boolean enabled); 1005229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood 1015229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood /** 1025229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood * Callback interface used to notify the view when the adapter has changed (i.e. the number and 1035229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood * type of views returned has changed). 1045229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood */ 1055229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood public interface SuggestionsAdapterChangeListener { 1065229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood void onSuggestionAdapterChanged(); 1075229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood } 1085229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood 109185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert} 110