mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Rename com.tns.Async.xxx to org.nativescript.widgets.Async.xxx
This commit is contained in:
8
tns-core-modules/declarations.android.d.ts
vendored
8
tns-core-modules/declarations.android.d.ts
vendored
@ -49,8 +49,9 @@ declare module android {
|
||||
}
|
||||
}
|
||||
|
||||
declare module com {
|
||||
export module tns {
|
||||
declare module org {
|
||||
export module nativescript {
|
||||
export module widgets {
|
||||
export module Async {
|
||||
export class CompleteCallback {
|
||||
constructor(implementation: ICompleteCallback);
|
||||
@ -61,6 +62,8 @@ declare module com {
|
||||
onComplete(result: Object, context: Object): void;
|
||||
}
|
||||
|
||||
export function DownloadImage(url: string, callback: CompleteCallback, context: any);
|
||||
|
||||
export module Http {
|
||||
export class KeyValuePair {
|
||||
public key: string;
|
||||
@ -92,3 +95,4 @@ declare module com {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -34,13 +34,13 @@ function ensurePlatform() {
|
||||
}
|
||||
}
|
||||
|
||||
var completeCallback: com.tns.Async.CompleteCallback;
|
||||
var completeCallback: org.nativescript.widgets.Async.CompleteCallback;
|
||||
function ensureCompleteCallback() {
|
||||
if (completeCallback) {
|
||||
return;
|
||||
}
|
||||
|
||||
completeCallback = new com.tns.Async.CompleteCallback({
|
||||
completeCallback = new org.nativescript.widgets.Async.CompleteCallback({
|
||||
onComplete: function (result: any, context: any) {
|
||||
// as a context we will receive the id of the request
|
||||
onRequestComplete(context, result);
|
||||
@ -48,7 +48,7 @@ function ensureCompleteCallback() {
|
||||
});
|
||||
}
|
||||
|
||||
function onRequestComplete(requestId: number, result: com.tns.Async.Http.RequestResult) {
|
||||
function onRequestComplete(requestId: number, result: org.nativescript.widgets.Async.Http.RequestResult) {
|
||||
var callbacks = pendingRequests[requestId];
|
||||
delete pendingRequests[requestId];
|
||||
|
||||
@ -63,7 +63,7 @@ function onRequestComplete(requestId: number, result: com.tns.Async.Http.Request
|
||||
var jHeaders = result.headers;
|
||||
var length = jHeaders.size();
|
||||
var i;
|
||||
var pair: com.tns.Async.Http.KeyValuePair;
|
||||
var pair: org.nativescript.widgets.Async.Http.KeyValuePair;
|
||||
for (i = 0; i < length; i++) {
|
||||
pair = jHeaders.get(i);
|
||||
|
||||
@ -130,7 +130,7 @@ function buildJavaOptions(options: http.HttpRequestOptions) {
|
||||
throw new Error("Http request must provide a valid url.");
|
||||
}
|
||||
|
||||
var javaOptions = new com.tns.Async.Http.RequestOptions();
|
||||
var javaOptions = new org.nativescript.widgets.Async.Http.RequestOptions();
|
||||
|
||||
javaOptions.url = options.url;
|
||||
|
||||
@ -145,8 +145,8 @@ function buildJavaOptions(options: http.HttpRequestOptions) {
|
||||
}
|
||||
|
||||
if (options.headers) {
|
||||
var arrayList = new java.util.ArrayList<com.tns.Async.Http.KeyValuePair>();
|
||||
var pair = com.tns.Async.Http.KeyValuePair;
|
||||
var arrayList = new java.util.ArrayList<org.nativescript.widgets.Async.Http.KeyValuePair>();
|
||||
var pair = org.nativescript.widgets.Async.Http.KeyValuePair;
|
||||
|
||||
for (var key in options.headers) {
|
||||
arrayList.add(new pair(key, options.headers[key] + ""));
|
||||
@ -186,7 +186,7 @@ export function request(options: http.HttpRequestOptions): Promise<http.HttpResp
|
||||
|
||||
ensureCompleteCallback();
|
||||
//make the actual async call
|
||||
com.tns.Async.Http.MakeRequest(javaOptions, completeCallback, new java.lang.Integer(requestIdCounter));
|
||||
org.nativescript.widgets.Async.Http.MakeRequest(javaOptions, completeCallback, new java.lang.Integer(requestIdCounter));
|
||||
|
||||
// increment the id counter
|
||||
requestIdCounter++;
|
||||
|
@ -41,7 +41,7 @@ export class Cache extends common.Cache {
|
||||
this._cache = new LruBitmapCacheClass(cacheSize);
|
||||
|
||||
var that = new WeakRef(this);
|
||||
this._callback = new (<any>com).tns.Async.CompleteCallback({
|
||||
this._callback = new org.nativescript.widgets.Async.CompleteCallback({
|
||||
onComplete: function (result: any, context: any) {
|
||||
var instance = that.get();
|
||||
if (instance) {
|
||||
@ -52,7 +52,7 @@ export class Cache extends common.Cache {
|
||||
}
|
||||
|
||||
public _downloadCore(request: common.DownloadRequest) {
|
||||
(<any>com).tns.Async.DownloadImage(request.url, this._callback, request.key);
|
||||
org.nativescript.widgets.Async.DownloadImage(request.url, this._callback, request.key);
|
||||
}
|
||||
|
||||
public get(key: string): any {
|
||||
|
Reference in New Issue
Block a user