@Test public void close_safeToCallTwice() throws IOException { Apa102 leds = new Apa102(mSpiDevice, Apa102.Mode.BGR, Apa102.Direction.NORMAL); leds.close(); leds.close(); Mockito.verify(mSpiDevice, times(1)).close(); }
@Override public void close() throws IOException { if (mDevice != null) { try { mDevice.close(); } finally { mDevice = null; } } }
Apa102 implements AutoCloseable { @Override public void close() throws IOException { if (mDevice != null) { try { mDevice.close(); } finally { mDevice = null; } } } }
Apa102 implements AutoCloseable { @Override public void close() throws IOException { if (mDevice != null) { try { mDevice.close(); } finally { mDevice = null; } } } Apa102(String spiBusPort, Mode ledMode);  Apa102(String spiBusPort, Mode ledMode, Direction direction);  Apa102(String spiBusPort, Mode ledMode, Direction direction, int spiMode); @VisibleForTesting  Apa102(SpiDevice device, Mode ledMode, Direction direction); }
Apa102 implements AutoCloseable { @Override public void close() throws IOException { if (mDevice != null) { try { mDevice.close(); } finally { mDevice = null; } } } Apa102(String spiBusPort, Mode ledMode);  Apa102(String spiBusPort, Mode ledMode, Direction direction);  Apa102(String spiBusPort, Mode ledMode, Direction direction, int spiMode); @VisibleForTesting  Apa102(SpiDevice device, Mode ledMode, Direction direction); void setBrightness(int ledBrightness); int getBrightness(); void setDirection(Direction direction); Direction getDirection(); void write(int[] colors); @Override void close(); }
Apa102 implements AutoCloseable { @Override public void close() throws IOException { if (mDevice != null) { try { mDevice.close(); } finally { mDevice = null; } } } Apa102(String spiBusPort, Mode ledMode);  Apa102(String spiBusPort, Mode ledMode, Direction direction);  Apa102(String spiBusPort, Mode ledMode, Direction direction, int spiMode); @VisibleForTesting  Apa102(SpiDevice device, Mode ledMode, Direction direction); void setBrightness(int ledBrightness); int getBrightness(); void setDirection(Direction direction); Direction getDirection(); void write(int[] colors); @Override void close(); static final int MAX_BRIGHTNESS; }