Search in sources :

Example 1 with JsBlob

use of im.actor.runtime.js.fs.JsBlob in project actor-platform by actorapp.

the class JsSmallAvatarFileCache method onAvatarUrlLoaded.

private void onAvatarUrlLoaded(final long id, String url) {
    JsHttpRequest request = JsHttpRequest.create();
    request.open("GET", url);
    request.setOnLoadHandler(new JsHttpRequestHandler() {

        @Override
        public void onStateChanged(JsHttpRequest request) {
            if (request.getReadyState() == 4) {
                if (request.getStatus() == 200) {
                    JsBlob blob = request.getResponseBlob();
                    onAvatarDownloaded(id, blob);
                } else {
                    // TODO: Implement better
                    cachedImages.put(id, null);
                }
            }
        }
    });
    request.send();
}
Also used : JsHttpRequestHandler(im.actor.runtime.js.http.JsHttpRequestHandler) JsHttpRequest(im.actor.runtime.js.http.JsHttpRequest) JsBlob(im.actor.runtime.js.fs.JsBlob)

Aggregations

JsBlob (im.actor.runtime.js.fs.JsBlob)1 JsHttpRequest (im.actor.runtime.js.http.JsHttpRequest)1 JsHttpRequestHandler (im.actor.runtime.js.http.JsHttpRequestHandler)1