From c4e32e3ddc869397c4a5216f502080f821c9da4b Mon Sep 17 00:00:00 2001 From: Greg Alexander Date: Sat, 19 May 2018 18:33:47 -0400 Subject: [PATCH] runOnUiThread() wants a Runnable, not a Thread, but i don't think it matters. anyways, re-factored while i was there. --- src/org/galexander/sshd/SimpleSSHD.java | 40 +++++++++++-------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/org/galexander/sshd/SimpleSSHD.java b/src/org/galexander/sshd/SimpleSSHD.java index 0b7144b..c1778c6 100644 --- a/src/org/galexander/sshd/SimpleSSHD.java +++ b/src/org/galexander/sshd/SimpleSSHD.java @@ -134,23 +134,24 @@ public class SimpleSSHD extends Activity } } - public static void update_startstop() { - Thread t = new Thread() { - public void run() { - synchronized (lock) { - if (curr != null) { - curr.update_startstop_prime(); - } - } - } - }; + private static void run_on_ui(Runnable r) { synchronized (lock) { if (curr != null) { - curr.runOnUiThread(t); + curr.runOnUiThread(r); } } } + public static void update_startstop() { + run_on_ui(new Runnable() { public void run() { + synchronized (lock) { + if (curr != null) { + curr.update_startstop_prime(); + } + } + } }); + } + public void startstop_clicked(View v) { boolean already_started = SimpleSSHDService.is_started(); Intent i = new Intent(this, SimpleSSHDService.class); @@ -199,20 +200,13 @@ public class SimpleSSHD extends Activity } public static void update_log() { - Thread t = new Thread() { - public void run() { - synchronized (lock) { - if (curr != null) { - curr.update_log_prime(); - } + run_on_ui(new Runnable() { public void run() { + synchronized (lock) { + if (curr != null) { + curr.update_log_prime(); } } - }; - synchronized (lock) { - if (curr != null) { - curr.runOnUiThread(t); - } - } + } }); } public static String get_ip(boolean pretty) {