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