Exemplo n.º 1
0
 /// <summary>Gets a drawable by URI, without using the cache.</summary>
 /// <remarks>Gets a drawable by URI, without using the cache.</remarks>
 /// <returns>
 /// A drawable, or
 /// <code>null</code>
 /// if the drawable could not be loaded.
 /// </returns>
 private android.graphics.drawable.Drawable getDrawable(System.Uri uri)
 {
     try
     {
         string scheme = uri.Scheme;
         if (android.content.ContentResolver.SCHEME_ANDROID_RESOURCE.Equals(scheme))
         {
             // Load drawables through Resources, to get the source density information
             android.content.ContentResolver.OpenResourceIdResult r = mProviderContext.getContentResolver
                                                                          ().getResourceId(uri);
             try
             {
                 return(r.r.getDrawable(r.id));
             }
             catch (android.content.res.Resources.NotFoundException)
             {
                 throw new java.io.FileNotFoundException("Resource does not exist: " + uri);
             }
         }
         else
         {
             // Let the ContentResolver handle content and file URIs.
             java.io.InputStream stream = mProviderContext.getContentResolver().openInputStream
                                              (uri);
             if (stream == null)
             {
                 throw new java.io.FileNotFoundException("Failed to open " + uri);
             }
             try
             {
                 return(android.graphics.drawable.Drawable.createFromStream(stream, null));
             }
             finally
             {
                 try
                 {
                     stream.close();
                 }
                 catch (System.IO.IOException ex)
                 {
                     android.util.Log.e(LOG_TAG, "Error closing icon stream for " + uri, ex);
                 }
             }
         }
     }
     catch (java.io.FileNotFoundException fnfe)
     {
         android.util.Log.w(LOG_TAG, "Icon not found: " + uri + ", " + fnfe.Message);
         return(null);
     }
 }
Exemplo n.º 2
0
 public override android.content.ContentResolver getContentResolver()
 {
     return(mBase.getContentResolver());
 }