Search in sources :

Example 1 with Int8Array

use of com.google.gwt.typedarrays.shared.Int8Array in project libgdx by libgdx.

the class AssetDownloader method loadBinary.

public void loadBinary(final String url, final AssetLoaderListener<Blob> listener) {
    XMLHttpRequest request = XMLHttpRequest.create();
    request.setOnReadyStateChange(new ReadyStateChangeHandler() {

        @Override
        public void onReadyStateChange(XMLHttpRequest xhr) {
            if (xhr.getReadyState() == XMLHttpRequest.DONE) {
                if (xhr.getStatus() != 200) {
                    listener.onFailure();
                } else {
                    Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
                    listener.onSuccess(new Blob(data));
                }
            }
        }
    });
    setOnProgress(request, listener);
    request.open("GET", url);
    request.setResponseType(ResponseType.ArrayBuffer);
    request.send();
}
Also used : Int8Array(com.google.gwt.typedarrays.shared.Int8Array) XMLHttpRequest(com.google.gwt.xhr.client.XMLHttpRequest) ReadyStateChangeHandler(com.google.gwt.xhr.client.ReadyStateChangeHandler)

Aggregations

Int8Array (com.google.gwt.typedarrays.shared.Int8Array)1 ReadyStateChangeHandler (com.google.gwt.xhr.client.ReadyStateChangeHandler)1 XMLHttpRequest (com.google.gwt.xhr.client.XMLHttpRequest)1