diff --git a/src/main/java/com/github/xsavikx/androidscreencast/api/AndroidDeviceImpl.java b/src/main/java/com/github/xsavikx/androidscreencast/api/AndroidDeviceImpl.java index 33eac1e..f19ac15 100644 --- a/src/main/java/com/github/xsavikx/androidscreencast/api/AndroidDeviceImpl.java +++ b/src/main/java/com/github/xsavikx/androidscreencast/api/AndroidDeviceImpl.java @@ -5,6 +5,7 @@ import com.android.ddmlib.SyncService.ISyncProgressMonitor; import com.github.xsavikx.androidscreencast.api.file.FileInfo; import com.github.xsavikx.androidscreencast.api.injector.OutputStreamShellOutputReceiver; +import com.github.xsavikx.androidscreencast.exception.AndroidScreenCastRuntimeException; import com.github.xsavikx.androidscreencast.exception.ExecuteCommandException; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -13,8 +14,8 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.List; -import java.util.Vector; @Component public class AndroidDeviceImpl implements AndroidDevice { @@ -31,9 +32,7 @@ public String executeCommand(String cmd) { if (logger.isDebugEnabled()) { logger.debug("executeCommand(String) - start"); } - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { + try (ByteArrayOutputStream bos = new ByteArrayOutputStream();) { device.executeShellCommand(cmd, new OutputStreamShellOutputReceiver(bos)); String returnString = new String(bos.toByteArray(), "UTF-8"); if (logger.isDebugEnabled()) { @@ -42,7 +41,6 @@ public String executeCommand(String cmd) { return returnString; } catch (Exception ex) { logger.error("executeCommand(String)", ex); - throw new ExecuteCommandException(cmd); } } @@ -56,13 +54,13 @@ public List list(String path) { try { String s = executeCommand("ls -l " + path); String[] entries = s.split("\r\n"); - Vector liste = new Vector<>(); + List fileInfos = new ArrayList<>(); for (String entry : entries) { String[] data = entry.split(" "); if (data.length < 4) continue; String attributes = data[0]; - boolean directory = attributes.startsWith("d"); + boolean directory = attributes.charAt(0) == 'd'; String name = data[data.length - 1]; FileInfo fi = new FileInfo(); @@ -72,17 +70,16 @@ public List list(String path) { fi.path = path; fi.device = this; - liste.add(fi); + fileInfos.add(fi); } if (logger.isDebugEnabled()) { logger.debug("list(String) - end"); } - return liste; + return fileInfos; } catch (Exception ex) { logger.error("list(String)", ex); - - throw new RuntimeException(ex); + throw new AndroidScreenCastRuntimeException(ex); } } @@ -117,7 +114,7 @@ public void pullFile(String removeFrom, File localTo) { } catch (Exception ex) { logger.error("pullFile(String, File)", ex); - throw new RuntimeException(ex); + throw new AndroidScreenCastRuntimeException(ex); } if (logger.isDebugEnabled()) { @@ -133,14 +130,14 @@ public void pushFile(File localFrom, String remoteTo) { try { if (device.getSyncService() == null) - throw new RuntimeException("SyncService is null, ADB crashed ?"); + throw new AndroidScreenCastRuntimeException("SyncService is null, ADB crashed ?"); device.getSyncService().pushFile(localFrom.getAbsolutePath(), remoteTo, SyncService.getNullProgressMonitor()); } catch (Exception ex) { logger.error("pushFile(File, String)", ex); - throw new RuntimeException(ex); + throw new AndroidScreenCastRuntimeException(ex); } if (logger.isDebugEnabled()) { diff --git a/src/main/java/com/github/xsavikx/androidscreencast/api/file/FileInfo.java b/src/main/java/com/github/xsavikx/androidscreencast/api/file/FileInfo.java index ce9c284..007de7f 100644 --- a/src/main/java/com/github/xsavikx/androidscreencast/api/file/FileInfo.java +++ b/src/main/java/com/github/xsavikx/androidscreencast/api/file/FileInfo.java @@ -1,9 +1,11 @@ package com.github.xsavikx.androidscreencast.api.file; import com.github.xsavikx.androidscreencast.api.AndroidDeviceImpl; +import com.github.xsavikx.androidscreencast.exception.IORuntimeException; import org.springframework.stereotype.Component; import java.io.File; +import java.io.IOException; @Component public class FileInfo { @@ -19,8 +21,8 @@ public File downloadTemporary() { device.pullFile(path + name, tempFile); tempFile.deleteOnExit(); return tempFile; - } catch (Exception ex) { - throw new RuntimeException(ex); + } catch (IOException ex) { + throw new IORuntimeException(ex); } } diff --git a/src/main/java/com/github/xsavikx/androidscreencast/api/image/SixteenBitColorModel.java b/src/main/java/com/github/xsavikx/androidscreencast/api/image/SixteenBitColorModel.java index 5827c80..520d98d 100644 --- a/src/main/java/com/github/xsavikx/androidscreencast/api/image/SixteenBitColorModel.java +++ b/src/main/java/com/github/xsavikx/androidscreencast/api/image/SixteenBitColorModel.java @@ -4,9 +4,6 @@ * Modified version of SixteenBitColorModel from android.chimpchat */ public class SixteenBitColorModel extends AbstractRawImageColorModel { - public SixteenBitColorModel() { - super(); - } @Override protected int getPixel(byte[] data) { diff --git a/src/main/java/com/github/xsavikx/androidscreencast/api/injector/Injector.java b/src/main/java/com/github/xsavikx/androidscreencast/api/injector/Injector.java index d72caee..eed9306 100644 --- a/src/main/java/com/github/xsavikx/androidscreencast/api/injector/Injector.java +++ b/src/main/java/com/github/xsavikx/androidscreencast/api/injector/Injector.java @@ -1,6 +1,5 @@ package com.github.xsavikx.androidscreencast.api.injector; -import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -8,7 +7,6 @@ @Service public class Injector { - private static final Logger LOGGER = Logger.getLogger(Injector.class); private final ScreenCaptureRunnable screenCaptureRunnable; private final Thread screenCaptureThread; diff --git a/src/main/java/com/github/xsavikx/androidscreencast/api/injector/ScreenCaptureRunnable.java b/src/main/java/com/github/xsavikx/androidscreencast/api/injector/ScreenCaptureRunnable.java index bcebeb3..7d2a16f 100644 --- a/src/main/java/com/github/xsavikx/androidscreencast/api/injector/ScreenCaptureRunnable.java +++ b/src/main/java/com/github/xsavikx/androidscreencast/api/injector/ScreenCaptureRunnable.java @@ -23,7 +23,6 @@ @Component public class ScreenCaptureRunnable implements Runnable { private static final Logger LOGGER = Logger.getLogger(ScreenCaptureRunnable.class); - private static final String MOV_FILE_TYPE = ".mov"; private static final int MOV_FPS = 30; private static final float MOV_COMPRESSION_RATE = 1f; private static final int FRAME_DURATION = 10; diff --git a/src/main/java/com/github/xsavikx/androidscreencast/api/recording/atom/CompositeAtom.java b/src/main/java/com/github/xsavikx/androidscreencast/api/recording/atom/CompositeAtom.java index f9c9fdc..16f982a 100644 --- a/src/main/java/com/github/xsavikx/androidscreencast/api/recording/atom/CompositeAtom.java +++ b/src/main/java/com/github/xsavikx/androidscreencast/api/recording/atom/CompositeAtom.java @@ -8,7 +8,7 @@ import javax.imageio.stream.ImageOutputStream; import java.io.IOException; -import java.util.LinkedList; +import java.util.List; import static com.google.common.collect.Lists.newLinkedList; @@ -17,7 +17,7 @@ */ public class CompositeAtom extends CommonAtom { private static final int HEADER_SIZE = 1; - private final LinkedList children; + private final List children; /** * Creates a new CompositeAtom at the current position of the ImageOutputStream. @@ -36,7 +36,7 @@ protected int getHeaderElements() { public void add(Atom child) { if (children.size() > 0) { - children.getLast().finish(); + children.get(children.size() - 1).finish(); } children.add(child); } diff --git a/src/main/java/com/github/xsavikx/androidscreencast/ui/explorer/JFrameExplorer.java b/src/main/java/com/github/xsavikx/androidscreencast/ui/explorer/JFrameExplorer.java index 3cbd222..41a7f0f 100644 --- a/src/main/java/com/github/xsavikx/androidscreencast/ui/explorer/JFrameExplorer.java +++ b/src/main/java/com/github/xsavikx/androidscreencast/ui/explorer/JFrameExplorer.java @@ -14,10 +14,10 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.File; +import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Vector; @Component public class JFrameExplorer extends JFrame { @@ -64,7 +64,6 @@ public void launch() { setLocationRelativeTo(null); jListFichiers.addMouseListener(new MouseAdapter() { - @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { @@ -74,7 +73,6 @@ public void mouseClicked(MouseEvent e) { launchFile(item); } } - }); } @@ -83,7 +81,7 @@ private void displayFolder(String path) { if (fileInfos == null) fileInfos = androidDevice.list(path); - List files = new Vector<>(); + List files = new ArrayList<>(); for (FileInfo fi2 : fileInfos) { if (fi2.directory) continue; diff --git a/src/main/java/com/github/xsavikx/androidscreencast/ui/explorer/LazyLoadingTreeNode.java b/src/main/java/com/github/xsavikx/androidscreencast/ui/explorer/LazyLoadingTreeNode.java index 15f8754..24f63e9 100644 --- a/src/main/java/com/github/xsavikx/androidscreencast/ui/explorer/LazyLoadingTreeNode.java +++ b/src/main/java/com/github/xsavikx/androidscreencast/ui/explorer/LazyLoadingTreeNode.java @@ -9,7 +9,8 @@ import javax.swing.tree.TreeModel; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.ExecutionException; public abstract class LazyLoadingTreeNode extends DefaultMutableTreeNode implements TreeWillExpandListener { @@ -242,7 +243,7 @@ protected static class CancelWorkersAction extends AbstractAction { /** * the SwingWorkers */ - private Vector> workers = new Vector<>(); + private List> workers = new ArrayList<>(); /** * Default constructor