Merge pull request #275 from NativeScript/image-cache

Removed image extension validation from image-cache. Images with no exte...
This commit is contained in:
Rossen Hristov
2015-04-09 16:47:50 +03:00
4 changed files with 0 additions and 17 deletions

View File

@ -17,7 +17,6 @@ var ISSCROLLING = "isLoading";
// initialize the image cache for the main list
export var cache = new imageCache.Cache();
cache.invalid = defaultNoThumbnailImageSource;
cache.placeholder = defaultThumbnailImageSource;
cache.maxRequests = 5;

View File

@ -13,7 +13,6 @@ export function test_DummyTestForSnippetOnly() {
// ### Requesting Images
// ``` JavaScript
var cache = new imageCacheModule.Cache();
cache.invalid = imageSource.fromFile(fs.path.join(__dirname, "res/reddit-logo.png"));
cache.placeholder = imageSource.fromFile(fs.path.join(__dirname, "res/no-image.png"));
cache.maxRequests = 5;

View File

@ -2,11 +2,6 @@
import observable = require("data/observable");
import imageSource = require("image-source");
// TODO: What is valid image?
function isValidImage(url: string): boolean {
return url.indexOf(".png") !== -1 || url.indexOf(".jpg") !== -1;
}
export module knownEvents {
export var downloaded = "downloaded";
}
@ -18,7 +13,6 @@ export interface DownloadRequest {
}
export class Cache extends observable.Observable implements definition.Cache {
public invalid: imageSource.ImageSource;
public placeholder: imageSource.ImageSource;
public maxRequests = 5;
private _enabled = true;
@ -166,11 +160,6 @@ export class Cache extends observable.Observable implements definition.Cache {
return false;
}
if (!isValidImage(request.url)) {
this._cache[request.key] = this.invalid;
return false;
}
if (this._currentDownloads >= this.maxRequests || !this._enabled) {
if (onTop) {
this._queue.push(request);

View File

@ -27,10 +27,6 @@ declare module "ui/image-cache" {
* Represents a class that stores handles image download requests and caches the already downloaded images.
*/
export class Cache extends observable.Observable {
/**
* The image to be used when the requested url is invalid or the result may not be decoded.
*/
invalid: imageSource.ImageSource;
/**
* The image to be used to notify for a pending download request - e.g. loading indicator.
*/