示例#1
0
 private android.graphics.drawable.Drawable checkIconCache(string resourceUri)
 {
     android.graphics.drawable.Drawable.ConstantState cached = mOutsideDrawablesCache.
                                                               get(resourceUri);
     if (cached == null)
     {
         return(null);
     }
     return(cached.newDrawable());
 }
示例#2
0
        /// <summary>Gets the activity or application icon for an activity.</summary>
        /// <remarks>
        /// Gets the activity or application icon for an activity.
        /// Uses the local icon cache for fast repeated lookups.
        /// </remarks>
        /// <param name="component">Name of an activity.</param>
        /// <returns>
        /// A drawable, or
        /// <code>null</code>
        /// if neither the activity nor the application
        /// has an icon set.
        /// </returns>
        private android.graphics.drawable.Drawable getActivityIconWithCache(android.content.ComponentName
                                                                            component)
        {
            // First check the icon cache
            string componentIconKey = component.flattenToShortString();

            // Using containsKey() since we also store null values.
            if (mOutsideDrawablesCache.containsKey(componentIconKey))
            {
                android.graphics.drawable.Drawable.ConstantState cached = mOutsideDrawablesCache.
                                                                          get(componentIconKey);
                return(cached == null ? null : cached.newDrawable(mProviderContext.getResources()
                                                                  ));
            }
            // Then try the activity or application icon
            android.graphics.drawable.Drawable drawable = getActivityIcon(component);
            // Stick it in the cache so we don't do this lookup again.
            android.graphics.drawable.Drawable.ConstantState toCache = drawable == null ? null
                                 : drawable.getConstantState();
            mOutsideDrawablesCache.put(componentIconKey, toCache);
            return(drawable);
        }