fix Exception when tile url is a 404

This commit is contained in:
Hannes Janetzek 2013-08-10 11:17:48 +02:00
parent 69fe006725
commit 8c9eaaea96

View File

@ -55,6 +55,7 @@ public class LwHttp {
Uint8Array mBuffer; Uint8Array mBuffer;
int mPos; int mPos;
int mEnd; int mEnd;
public Buffer(Uint8Array buf) { public Buffer(Uint8Array buf) {
mBuffer = buf; mBuffer = buf;
mPos = 0; mPos = 0;
@ -76,6 +77,7 @@ public class LwHttp {
} }
private PbfTileDataSource mDataSource; private PbfTileDataSource mDataSource;
public boolean sendRequest(Tile tile, PbfTileDataSource dataSource) throws IOException { public boolean sendRequest(Tile tile, PbfTileDataSource dataSource) throws IOException {
mDataSource = dataSource; mDataSource = dataSource;
@ -104,16 +106,20 @@ public class LwHttp {
@Override @Override
public void onReadyStateChange(XMLHttpRequest xhr) { public void onReadyStateChange(XMLHttpRequest xhr) {
int status = xhr.getStatus();
int state = xhr.getReadyState(); int state = xhr.getReadyState();
//Log.d(TAG, mCurrentUrl + "response " + status + "/" + state); //Log.d(TAG, mCurrentUrl + "response " + status + "/" + state);
if (state == XMLHttpRequest.DONE && status == 200){ if (state == XMLHttpRequest.DONE) {
int status = xhr.getStatus();
if (status == 200) {
Uint8Array buf = Uint8ArrayNative.create(xhr.getResponseArrayBuffer()); Uint8Array buf = Uint8ArrayNative.create(xhr.getResponseArrayBuffer());
mDataSource.process(new Buffer(buf), buf.byteLength()); mDataSource.process(new Buffer(buf), buf.byteLength());
} else if (state == XMLHttpRequest.DONE){ } else {
mDataSource.process(null, 0); mDataSource.process(null, -1);
}
} }
} }
}; };