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.SuggestionCursor; 197a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwoodimport com.android.quicksearchbox.SuggestionPosition; 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> { 331e938ea2f5edefab446b9562b316bc5dc72adebbBryan Mawhinney 34fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 35fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Sets the listener to be notified of clicks on suggestions. 36fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 37fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void setSuggestionClickListener(SuggestionClickListener listener); 38185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert 39713194910648268c094fa81b81f40ce2f7e39333Bjorn Bringert /** 40fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Sets the listener to be notified of focus change events on suggestion views. 41ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert */ 42fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void setOnFocusChangeListener(OnFocusChangeListener l); 43ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert 44ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert /** 45fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Sets the current suggestions. 46713194910648268c094fa81b81f40ce2f7e39333Bjorn Bringert */ 47fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood void setSuggestions(Suggestions suggestions); 48185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert 49713194910648268c094fa81b81f40ce2f7e39333Bjorn Bringert /** 507a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood * Indicates if there's any suggestions in this adapter. 517a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood */ 527a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood boolean isEmpty(); 537a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood 547a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood /** 55fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Gets the current suggestions. 56713194910648268c094fa81b81f40ce2f7e39333Bjorn Bringert */ 57fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood Suggestions getSuggestions(); 58185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert 59fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 607a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood * Gets the cursor and position corresponding to the given suggestion ID. 617a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood * @param suggestionId Suggestion ID. 627a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood */ 637a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood SuggestionPosition getSuggestion(long suggestionId); 647a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood 657a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood /** 66fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Handles a regular click on a suggestion. 677a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood * 687a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood * @param suggestionId The ID of the suggestion clicked. If the suggestion list is flat, this 697a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood * will be the position within the list. 70fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 717a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood void onSuggestionClicked(long suggestionId); 727010c51b51c97fa43d7b24d2158ecbc1d064e0a6Bjorn Bringert 73fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 74fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Handles a click on the query refinement button. 757a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood * 767a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood * @param suggestionId The ID of the suggestion clicked. If the suggestion list is flat, this 777a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood * will be the position within the list. 78fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 797a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood void onSuggestionQueryRefineClicked(long suggestionId); 80185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert 81fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood /** 82fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Gets the adapter to be used by the UI view. 83fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood */ 84fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood A getListAdapter(); 855229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood 86185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert} 87