mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 06:26:41 +00:00
Version 4.12.2 Improved ImageLoader/TileImageLoader
This commit is contained in:
parent
25bdf3050b
commit
4a7e384152
4 changed files with 54 additions and 57 deletions
|
|
@ -36,17 +36,19 @@ namespace MapControl
|
|||
|
||||
if (cacheBuffer == null || cacheItem.Expiration < DateTime.UtcNow)
|
||||
{
|
||||
using (var stream = await ImageLoader.LoadImageStreamAsync(uri).ConfigureAwait(false))
|
||||
{
|
||||
if (stream != null) // download succeeded
|
||||
{
|
||||
cacheBuffer = null; // discard cached image
|
||||
var response = await ImageLoader.GetHttpResponseAsync(uri, false).ConfigureAwait(false);
|
||||
|
||||
if (stream.Length > 0) // tile image available
|
||||
if (response != null) // download succeeded
|
||||
{
|
||||
cacheBuffer = null; // discard cached image
|
||||
|
||||
if (response.Stream != null) // tile image available
|
||||
{
|
||||
using (var stream = response.Stream)
|
||||
{
|
||||
await SetTileImageAsync(tile, () => ImageLoader.LoadImageAsync(stream)).ConfigureAwait(false);
|
||||
|
||||
await Cache.SetAsync(cacheKey, stream.ToArray().AsBuffer(), GetExpiration(stream.MaxAge)).ConfigureAwait(false);
|
||||
await Cache.SetAsync(cacheKey, stream.ToArray().AsBuffer(), GetExpiration(response.MaxAge)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue