Save initial URI for all loadUri methods

This commit is contained in:
Paul Rouget 2018-09-10 10:14:16 +02:00
parent f7630dad87
commit 77f38a0789

View file

@ -38,7 +38,7 @@ public class ServoSurface {
private Servo mServo; private Servo mServo;
private Client mClient = null; private Client mClient = null;
private String mServoArgs = ""; private String mServoArgs = "";
private Uri mInitialUri = null; private String mInitialUri = null;
private Activity mActivity; private Activity mActivity;
public ServoSurface(Surface surface, int width, int height) { public ServoSurface(Surface surface, int width, int height) {
@ -82,7 +82,15 @@ public class ServoSurface {
} }
public void loadUri(String uri) { public void loadUri(String uri) {
if (mServo != null) {
mServo.loadUri(uri); mServo.loadUri(uri);
} else {
mInitialUri = uri;
}
}
public void loadUri(Uri uri) {
loadUri(uri.toString());
} }
public void scrollStart(int dx, int dy, int x, int y) { public void scrollStart(int dx, int dy, int x, int y) {
@ -105,14 +113,6 @@ public class ServoSurface {
mServo.resize(width, height); mServo.resize(width, height);
} }
public void loadUri(Uri uri) {
if (mServo != null) {
mServo.loadUri(uri.toString());
} else {
mInitialUri = uri;
}
}
static class GLSurface implements GfxCallbacks { static class GLSurface implements GfxCallbacks {
private EGLConfig[] mEGLConfigs; private EGLConfig[] mEGLConfigs;
private EGLDisplay mEglDisplay; private EGLDisplay mEglDisplay;
@ -196,15 +196,14 @@ public class ServoSurface {
GLSurface surface = new GLSurface(mASurface); GLSurface surface = new GLSurface(mASurface);
final boolean showLogs = true;
String uri = mInitialUri == null ? null : mInitialUri.toString();
mGLLooperHandler = new Handler() { mGLLooperHandler = new Handler() {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
} }
}; };
inUIThread(() -> { inUIThread(() -> {
final boolean showLogs = true;
String uri = mInitialUri == null ? null : mInitialUri;
mServo = new Servo(this, surface, mClient, mActivity, mServoArgs, uri, mWidth, mHeight, showLogs); mServo = new Servo(this, surface, mClient, mActivity, mServoArgs, uri, mWidth, mHeight, showLogs);
}); });