mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Merge pull request #275 from NativeScript/image-cache
Removed image extension validation from image-cache. Images with no exte...
This commit is contained in:
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
4
ui/image-cache/image-cache.d.ts
vendored
4
ui/image-cache/image-cache.d.ts
vendored
@ -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.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user