mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +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
|
// initialize the image cache for the main list
|
||||||
export var cache = new imageCache.Cache();
|
export var cache = new imageCache.Cache();
|
||||||
cache.invalid = defaultNoThumbnailImageSource;
|
|
||||||
cache.placeholder = defaultThumbnailImageSource;
|
cache.placeholder = defaultThumbnailImageSource;
|
||||||
cache.maxRequests = 5;
|
cache.maxRequests = 5;
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ export function test_DummyTestForSnippetOnly() {
|
|||||||
// ### Requesting Images
|
// ### Requesting Images
|
||||||
// ``` JavaScript
|
// ``` JavaScript
|
||||||
var cache = new imageCacheModule.Cache();
|
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.placeholder = imageSource.fromFile(fs.path.join(__dirname, "res/no-image.png"));
|
||||||
cache.maxRequests = 5;
|
cache.maxRequests = 5;
|
||||||
|
|
||||||
|
@ -2,11 +2,6 @@
|
|||||||
import observable = require("data/observable");
|
import observable = require("data/observable");
|
||||||
import imageSource = require("image-source");
|
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 module knownEvents {
|
||||||
export var downloaded = "downloaded";
|
export var downloaded = "downloaded";
|
||||||
}
|
}
|
||||||
@ -18,7 +13,6 @@ export interface DownloadRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Cache extends observable.Observable implements definition.Cache {
|
export class Cache extends observable.Observable implements definition.Cache {
|
||||||
public invalid: imageSource.ImageSource;
|
|
||||||
public placeholder: imageSource.ImageSource;
|
public placeholder: imageSource.ImageSource;
|
||||||
public maxRequests = 5;
|
public maxRequests = 5;
|
||||||
private _enabled = true;
|
private _enabled = true;
|
||||||
@ -166,11 +160,6 @@ export class Cache extends observable.Observable implements definition.Cache {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isValidImage(request.url)) {
|
|
||||||
this._cache[request.key] = this.invalid;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._currentDownloads >= this.maxRequests || !this._enabled) {
|
if (this._currentDownloads >= this.maxRequests || !this._enabled) {
|
||||||
if (onTop) {
|
if (onTop) {
|
||||||
this._queue.push(request);
|
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.
|
* Represents a class that stores handles image download requests and caches the already downloaded images.
|
||||||
*/
|
*/
|
||||||
export class Cache extends observable.Observable {
|
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.
|
* The image to be used to notify for a pending download request - e.g. loading indicator.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user