本文整理汇总了C#中ImageView.SetImageRounded方法的典型用法代码示例。如果您正苦于以下问题:C# ImageView.SetImageRounded方法的具体用法?C# ImageView.SetImageRounded怎么用?C# ImageView.SetImageRounded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageView
的用法示例。
在下文中一共展示了ImageView.SetImageRounded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUrlDrawable
private static void SetUrlDrawable(Context context, ImageView imageView, string url, Drawable defaultDrawable, long cacheDurationMs, IUrlImageViewCallback callback)
{
Cleanup(context);
if (imageView != null)
pendingViews.Remove(imageView);
if (string.IsNullOrEmpty(url))
{
if (imageView != null)
imageView.SetImageDrawable(defaultDrawable);
return;
}
var cache = UrlImageCache.Instance;
var drawable = cache.Get(url);
if (drawable != null)
{
if (imageView != null)
imageView.SetImageRounded((BitmapDrawable)drawable);
if (callback != null)
callback.OnLoaded(imageView, drawable, url, true);
return;
}
var baseDir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var filename = System.IO.Path.Combine(baseDir, GetFilenameForUrl(url));
var file = new System.IO.FileInfo(filename);
if (file.Exists)
{
try
{
if (cacheDurationMs == CACHE_DURATION_INFINITE || DateTime.UtcNow < file.LastWriteTimeUtc.AddMilliseconds(cacheDurationMs))
{
drawable = LoadDrawableFromFile(context, filename);
//var fis = context.OpenFileInput(filename);
//drawable = LoadDrawableFromStream(context, fis);
//fis.Close();
if (imageView != null)
imageView.SetImageDrawable(drawable);
cache.Put(url, drawable);
if (callback != null)
callback.OnLoaded(imageView, drawable, url, true);
return;
}
else
{
//TODO: File cache expired, refreshing
Android.Util.Log.Debug(LOGTAG, "File Cache Expired: " + file.Name);
}
}
catch (Exception ex)
{
Android.Util.Log.Debug(LOGTAG, "File Cache Exception " + ex.ToString());
}
}
if (imageView != null)
imageView.SetImageDrawable(defaultDrawable);
if (imageView != null)
pendingViews.Put(imageView, url);
//Check to see if another view is already waiting for this url so we don't download it again
var currentDownload = pendingDownloads.Get(url);
if (currentDownload != null)
{
if (imageView != null)
currentDownload.Add(imageView);
return;
}
var downloads = new List<ImageView>();
if (imageView != null)
downloads.Add(imageView);
pendingDownloads.Put(url, downloads);
var downloaderTask = new AnonymousAsyncTask<string, string, BitmapDrawable>((p) =>
{
try
{
var client = new System.Net.WebClient();
var data = client.DownloadData(url);
System.IO.File.WriteAllBytes(filename, data);
return LoadDrawableFromFile(context, filename);
}
catch (Exception ex)
{
Android.Util.Log.Debug(LOGTAG, "Download Error: " + ex.ToString());
//.........这里部分代码省略.........