mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Replace knownEvents modules with static strings.
This commit is contained in:
@@ -2,10 +2,6 @@
|
||||
import observable = require("data/observable");
|
||||
import imageSource = require("image-source");
|
||||
|
||||
export module knownEvents {
|
||||
export var downloaded = "downloaded";
|
||||
}
|
||||
|
||||
export interface DownloadRequest {
|
||||
url: string;
|
||||
key: string;
|
||||
@@ -13,6 +9,8 @@ export interface DownloadRequest {
|
||||
}
|
||||
|
||||
export class Cache extends observable.Observable implements definition.Cache {
|
||||
public static downloadedEvent = "downloaded";
|
||||
|
||||
public placeholder: imageSource.ImageSource;
|
||||
public maxRequests = 5;
|
||||
private _enabled = true;
|
||||
@@ -135,9 +133,9 @@ export class Cache extends observable.Observable implements definition.Cache {
|
||||
request.completed(image, request.key);
|
||||
}
|
||||
|
||||
if (this.hasListeners(knownEvents.downloaded)) {
|
||||
if (this.hasListeners(Cache.downloadedEvent)) {
|
||||
this.notify({
|
||||
eventName: knownEvents.downloaded,
|
||||
eventName: Cache.downloadedEvent,
|
||||
object: this,
|
||||
key: key,
|
||||
image: image
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import common = require("ui/image-cache/image-cache-common");
|
||||
|
||||
module.exports.knownEvents = common.knownEvents;
|
||||
|
||||
class LruBitmapCache extends android.util.LruCache<string, android.graphics.Bitmap> {
|
||||
constructor(cacheSize: number) {
|
||||
super(cacheSize);
|
||||
|
||||
27
ui/image-cache/image-cache.d.ts
vendored
27
ui/image-cache/image-cache.d.ts
vendored
@@ -27,6 +27,10 @@ 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 {
|
||||
/**
|
||||
* String value used when hooking to downloaded event.
|
||||
*/
|
||||
public static downloadedEvent: string;
|
||||
/**
|
||||
* The image to be used to notify for a pending download request - e.g. loading indicator.
|
||||
*/
|
||||
@@ -71,22 +75,25 @@ declare module "ui/image-cache" {
|
||||
*/
|
||||
clear(): void;
|
||||
|
||||
/**
|
||||
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
|
||||
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
|
||||
* @param callback - Callback function which will be executed when event is raised.
|
||||
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
|
||||
*/
|
||||
on(eventNames: string, callback: (args: observable.EventData) => void , thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when the image has been downloaded.
|
||||
*/
|
||||
on(event: "downloaded", callback: (args: DownloadedData) => void , thisArg?: any);
|
||||
|
||||
//@private
|
||||
_downloadCore(request: DownloadRequest);
|
||||
_onDownloadCompleted(key: string, image: any);
|
||||
//@endprivate
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines an enum with events specific for image-cache class.
|
||||
*/
|
||||
export module knownEvents {
|
||||
/**
|
||||
* Raised when the image has been downloaded.
|
||||
*/
|
||||
export var downloaded: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides data for downloaded event.
|
||||
*/
|
||||
|
||||
@@ -3,8 +3,6 @@ import httpRequest = require("http/http-request");
|
||||
import utils = require("utils/utils");
|
||||
import trace = require("trace");
|
||||
|
||||
module.exports.knownEvents = common.knownEvents;
|
||||
|
||||
//class NSCacheDelegateImpl extends NSObject implements NSCacheDelegate {
|
||||
// public static ObjCProtocols = [NSCacheDelegate];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user