New BCL approach & BuildTasks

This commit is contained in:
atanasovg
2014-03-12 18:26:58 +02:00
commit 39b505384a
42 changed files with 2907 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
import image_module = require("Image/image");
export module tk {
export module web {
/**
* Android specific WebClient implementation.
*/
export class Client {
/**
* Downloads string from url.
*/
public downloadString(url: string, successCallback: (result: string) => void, errorCallback?: (e: Error) => void) {
try {
if (successCallback) {
var httpClient = new org.apache.http.impl.client.DefaultHttpClient();
var httpGet = new org.apache.http.client.methods.HttpGet(url);
var responseHandler = new org.apache.http.impl.client.BasicResponseHandler();
var responseBody = httpClient.execute(httpGet, responseHandler);
successCallback(responseBody);
}
} catch (ex) {
if (errorCallback) {
errorCallback(ex);
}
}
}
public downloadImage(url: string, successCallback: (image: image_module.tk.ui.Image) => void, errorCallback?: (e: Error) => void) {
try {
if (successCallback) {
var image = new image_module.tk.ui.Image();
image.loadFromData(new java.net.URL(url).getContent());
successCallback(image);
}
} catch (ex) {
if (errorCallback) {
errorCallback(ex);
}
}
}
}
}
}