From c2c2175c26a06cb5ac4a7cdda558646a0d3b1993 Mon Sep 17 00:00:00 2001 From: Iurii Sergiichuk Date: Mon, 24 Aug 2015 15:51:30 +0300 Subject: [PATCH] Issue #15 - fix bug with swipe Fixed bug with swipe cannot be performed due to improper usage of variables with multithreaded operations. fixed possible NPE while setting default windows size from property file. Version changed to 0.0.5.1S --- pom.xml | 2 +- .../screencast/api/injector/MultiLineReceiverPrinter.java | 3 +++ .../github/xsavikx/android/screencast/ui/JFrameMain.java | 7 ++++--- .../screencast/ui/interaction/KeyboardActionListener.java | 1 - .../screencast/ui/interaction/MouseActionAdapter.java | 6 +++++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 27c7b60..1dc8e0a 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 AndroidScreencast AndroidScreencast - 0.0.5S + 0.0.5.1S Android Screencast 4.2.0.RELEASE diff --git a/src/com/github/xsavikx/android/screencast/api/injector/MultiLineReceiverPrinter.java b/src/com/github/xsavikx/android/screencast/api/injector/MultiLineReceiverPrinter.java index 85ef1b3..e1d8ee9 100644 --- a/src/com/github/xsavikx/android/screencast/api/injector/MultiLineReceiverPrinter.java +++ b/src/com/github/xsavikx/android/screencast/api/injector/MultiLineReceiverPrinter.java @@ -1,7 +1,10 @@ package com.github.xsavikx.android.screencast.api.injector; +import org.springframework.stereotype.Component; + import com.android.ddmlib.MultiLineReceiver; +@Component public class MultiLineReceiverPrinter extends MultiLineReceiver { @Override diff --git a/src/com/github/xsavikx/android/screencast/ui/JFrameMain.java b/src/com/github/xsavikx/android/screencast/ui/JFrameMain.java index 7069959..2e10acd 100644 --- a/src/com/github/xsavikx/android/screencast/ui/JFrameMain.java +++ b/src/com/github/xsavikx/android/screencast/ui/JFrameMain.java @@ -70,9 +70,10 @@ public JFrameMain(Environment env, Injector injector, AndroidDevice androidDevic private void setPrefferedWindowSize() { if (env.containsProperty(Constants.DEFAULT_WINDOW_HEIGHT) && env.containsProperty(Constants.DEFAULT_WINDOW_WIDTH)) { - int height = env.getProperty(Constants.DEFAULT_WINDOW_HEIGHT, Integer.class).intValue(); - int width = env.getProperty(Constants.DEFAULT_WINDOW_WIDTH, Integer.class).intValue(); - getContentPane().setPreferredSize(new Dimension(width, height)); + Integer height = env.getProperty(Constants.DEFAULT_WINDOW_HEIGHT, Integer.class); + Integer width = env.getProperty(Constants.DEFAULT_WINDOW_WIDTH, Integer.class); + if (height != null && width != null) + getContentPane().setPreferredSize(new Dimension(width.intValue(), height.intValue())); } pack(); } diff --git a/src/com/github/xsavikx/android/screencast/ui/interaction/KeyboardActionListener.java b/src/com/github/xsavikx/android/screencast/ui/interaction/KeyboardActionListener.java index 0c97644..05db73b 100644 --- a/src/com/github/xsavikx/android/screencast/ui/interaction/KeyboardActionListener.java +++ b/src/com/github/xsavikx/android/screencast/ui/interaction/KeyboardActionListener.java @@ -20,7 +20,6 @@ public KeyboardActionListener(int key) { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { - @Override public void run() { getCommandExecutor().execute(AdbInputCommandFactory.getKeyCommand(key)); diff --git a/src/com/github/xsavikx/android/screencast/ui/interaction/MouseActionAdapter.java b/src/com/github/xsavikx/android/screencast/ui/interaction/MouseActionAdapter.java index b55661e..1022adf 100644 --- a/src/com/github/xsavikx/android/screencast/ui/interaction/MouseActionAdapter.java +++ b/src/com/github/xsavikx/android/screencast/ui/interaction/MouseActionAdapter.java @@ -65,11 +65,15 @@ public void mouseDragged(MouseEvent e) { public void mouseReleased(MouseEvent e) { if (timeFromPress >= ONE_SECOND) { final Point p2 = jp.getRawPoint(e.getPoint()); + final int xFrom = dragFromX; + final int yFrom = dragFromY; + final int xTo = p2.x; + final int yTo = p2.y; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - getCommandExecutor().execute(AdbInputCommandFactory.getSwipeCommand(dragFromX, dragFromY, p2.x, p2.y)); + getCommandExecutor().execute(AdbInputCommandFactory.getSwipeCommand(xFrom, yFrom, xTo, yTo)); } }); dragFromX = -1;