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