diff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java index a8219edd..7663b1cf 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Controller.java +++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java @@ -258,12 +258,9 @@ public class Controller { * Schedule a call to set power mode to off after a small delay. */ private static void schedulePowerModeOff() { - EXECUTOR.schedule(new Runnable() { - @Override - public void run() { - Ln.i("Forcing screen off"); - Device.setScreenPowerMode(Device.POWER_MODE_OFF); - } + EXECUTOR.schedule(() -> { + Ln.i("Forcing screen off"); + Device.setScreenPowerMode(Device.POWER_MODE_OFF); }, 200, TimeUnit.MILLISECONDS); } diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java index a8b948c6..4a371e5b 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Server.java +++ b/server/src/main/java/com/genymobile/scrcpy/Server.java @@ -88,12 +88,7 @@ public final class Server { controllerThread = startController(controller); deviceMessageSenderThread = startDeviceMessageSender(controller.getSender()); - device.setClipboardListener(new Device.ClipboardListener() { - @Override - public void onClipboardTextChanged(String text) { - controller.getSender().pushClipboardText(text); - } - }); + device.setClipboardListener(text -> controller.getSender().pushClipboardText(text)); } try { @@ -115,26 +110,18 @@ public final class Server { } private static Thread startInitThread(final Options options) { - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - initAndCleanUp(options); - } - }); + Thread thread = new Thread(() -> initAndCleanUp(options)); thread.start(); return thread; } private static Thread startController(final Controller controller) { - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - try { - controller.control(); - } catch (IOException e) { - // this is expected on close - Ln.d("Controller stopped"); - } + Thread thread = new Thread(() -> { + try { + controller.control(); + } catch (IOException e) { + // this is expected on close + Ln.d("Controller stopped"); } }); thread.start(); @@ -142,15 +129,12 @@ public final class Server { } private static Thread startDeviceMessageSender(final DeviceMessageSender sender) { - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - try { - sender.loop(); - } catch (IOException | InterruptedException e) { - // this is expected on close - Ln.d("Device message sender stopped"); - } + Thread thread = new Thread(() -> { + try { + sender.loop(); + } catch (IOException | InterruptedException e) { + // this is expected on close + Ln.d("Device message sender stopped"); } }); thread.start(); @@ -327,12 +311,9 @@ public final class Server { } public static void main(String... args) throws Exception { - Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { - @Override - public void uncaughtException(Thread t, Throwable e) { - Ln.e("Exception on thread " + t, e); - suggestFix(e); - } + Thread.setDefaultUncaughtExceptionHandler((t, e) -> { + Ln.e("Exception on thread " + t, e); + suggestFix(e); }); Options options = createOptions(args);