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 */ 16 17 package com.android.quicksearchbox; 18 19 import com.android.quicksearchbox.ShortcutRefresher.Listener; 20 21 /** 22 * Fires off tasks to validate shortcuts, and reports the results back to a 23 * {@link Listener}. 24 */ 25 public interface ShortcutRefresher { 26 27 public interface Listener { 28 /** 29 * Called by the ShortcutRefresher when a shortcut has been refreshed. 30 * 31 * @param source source of this shortcut. 32 * @param shortcutId the id of the shortcut. 33 * @param refreshed the updated shortcut, or {@code null} if the shortcut 34 * is no longer valid and should be deleted. 35 */ 36 void onShortcutRefreshed(Source source, String shortcutId, 37 SuggestionCursor refreshed); 38 } 39 40 /** 41 * Starts a task to refresh a single shortcut. 42 * 43 * @param shortcut The shortcut to be refreshed. 44 * @param listener Who to report back to. 45 */ 46 void refresh(Suggestion shortcut, Listener listener); 47 48 /** 49 * Returns true if the given shortcut requires refreshing. 50 */ 51 boolean shouldRefresh(Source source, String shortcutId); 52 53 /** 54 * Indicates that the shortcut no longer requires refreshing. 55 */ 56 public void markShortcutRefreshed(Source source, String shortcutId); 57 58 /** 59 * Resets internal state. This results in all shortcuts requiring refreshing. 60 */ 61 public void reset(); 62 63 /** 64 * Cancels any pending shortcut refresh requests. 65 */ 66 public void cancelPendingTasks(); 67 68 } 69