1 /* 2 * Copyright (C) 2009 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.util.NowOrLater; 20 21 import android.content.ContentResolver; 22 import android.graphics.drawable.Drawable; 23 import android.net.Uri; 24 25 /** 26 * Interface for icon loaders. 27 * 28 */ 29 public interface IconLoader { 30 31 /** 32 * Gets a drawable given an ID. 33 * 34 * The ID could be just the string value of a resource id 35 * (e.g., "2130837524"), in which case we will try to retrieve a drawable from 36 * the provider's resources. If the ID is not an integer, it is 37 * treated as a Uri and opened with 38 * {@link ContentResolver#openOutputStream(android.net.Uri, String)}. 39 * 40 * All resources and URIs are read using the suggestion provider's context. 41 * 42 * @return a {@link NowOrLater} for retrieving the icon. If the ID is not formatted as expected, 43 * or no drawable can be found for the provided value, the value from this will be null. 44 * 45 * @param drawableId a string like "2130837524", 46 * "android.resource://com.android.alarmclock/2130837524", 47 * or "content://contacts/photos/253". 48 */ getIcon(String drawableId)49 NowOrLater<Drawable> getIcon(String drawableId); 50 51 /** 52 * Converts a drawable ID to a Uri that can be used from other packages. 53 */ getIconUri(String drawableId)54 Uri getIconUri(String drawableId); 55 56 } 57