A little more paranoia around the file watcher.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4427 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-08-25 18:27:19 +00:00
parent e223d35252
commit 060f1980f5

View File

@ -105,10 +105,13 @@ public class MainActivity extends Activity {
for (WatchEvent event : key.pollEvents()) {
if (event.context().toString().equals("port.txt")) {
Log.w("tildefriends", "Observed file write: " + event.context().toString());
base_url = "http://127.0.0.1:" + String.valueOf(read_port(port_file_path)) + "/";
int port = read_port(port_file_path);
if (port >= 0) {
base_url = "http://127.0.0.1:" + String.valueOf(port) + "/";
activity.runOnUiThread(() -> {
web_view.loadUrl(base_url);
});
}
break;
}
}