From 6c7110969f2fe1c736fc7bf4028d2b34a29d85a0 Mon Sep 17 00:00:00 2001 From: Franck ALARY Date: Fri, 12 Feb 2021 14:31:47 +0100 Subject: [PATCH] v2.0.10 : annotations @Nullable added --- .../connection/bluetooth/BluetoothConnections.java | 5 +++++ .../connection/bluetooth/BluetoothPrintersConnections.java | 4 ++++ .../dantsu/escposprinter/connection/usb/UsbConnections.java | 3 +++ .../dantsu/escposprinter/connection/usb/UsbDeviceHelper.java | 4 ++++ .../escposprinter/connection/usb/UsbPrintersConnections.java | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/escposprinter/src/main/java/com/dantsu/escposprinter/connection/bluetooth/BluetoothConnections.java b/escposprinter/src/main/java/com/dantsu/escposprinter/connection/bluetooth/BluetoothConnections.java index aa3932c..4a9f515 100644 --- a/escposprinter/src/main/java/com/dantsu/escposprinter/connection/bluetooth/BluetoothConnections.java +++ b/escposprinter/src/main/java/com/dantsu/escposprinter/connection/bluetooth/BluetoothConnections.java @@ -1,8 +1,11 @@ package com.dantsu.escposprinter.connection.bluetooth; +import android.annotation.SuppressLint; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; +import androidx.annotation.Nullable; + import java.util.Set; public class BluetoothConnections { @@ -19,6 +22,8 @@ public BluetoothConnections() { * Get a list of bluetooth devices available. * @return Return an array of BluetoothConnection instance */ + @SuppressLint("MissingPermission") + @Nullable public BluetoothConnection[] getList() { if (this.bluetoothAdapter == null) { return null; diff --git a/escposprinter/src/main/java/com/dantsu/escposprinter/connection/bluetooth/BluetoothPrintersConnections.java b/escposprinter/src/main/java/com/dantsu/escposprinter/connection/bluetooth/BluetoothPrintersConnections.java index 84a96c2..a359673 100644 --- a/escposprinter/src/main/java/com/dantsu/escposprinter/connection/bluetooth/BluetoothPrintersConnections.java +++ b/escposprinter/src/main/java/com/dantsu/escposprinter/connection/bluetooth/BluetoothPrintersConnections.java @@ -4,6 +4,8 @@ import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; +import androidx.annotation.Nullable; + import com.dantsu.escposprinter.exceptions.EscPosConnectionException; public class BluetoothPrintersConnections extends BluetoothConnections { @@ -13,6 +15,7 @@ public class BluetoothPrintersConnections extends BluetoothConnections { * * @return a EscPosPrinterCommands instance */ + @Nullable public static BluetoothConnection selectFirstPaired() { BluetoothPrintersConnections printers = new BluetoothPrintersConnections(); BluetoothConnection[] bluetoothPrinters = printers.getList(); @@ -36,6 +39,7 @@ public static BluetoothConnection selectFirstPaired() { * @return an array of EscPosPrinterCommands */ @SuppressLint("MissingPermission") + @Nullable public BluetoothConnection[] getList() { BluetoothConnection[] bluetoothDevicesList = super.getList(); diff --git a/escposprinter/src/main/java/com/dantsu/escposprinter/connection/usb/UsbConnections.java b/escposprinter/src/main/java/com/dantsu/escposprinter/connection/usb/UsbConnections.java index 14bedaa..28702d2 100644 --- a/escposprinter/src/main/java/com/dantsu/escposprinter/connection/usb/UsbConnections.java +++ b/escposprinter/src/main/java/com/dantsu/escposprinter/connection/usb/UsbConnections.java @@ -4,6 +4,8 @@ import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbManager; +import androidx.annotation.Nullable; + import java.util.Collection; public class UsbConnections { @@ -22,6 +24,7 @@ public UsbConnections(Context context) { * Get a list of USB devices available. * @return Return an array of UsbConnection instance */ + @Nullable public UsbConnection[] getList() { if (this.usbManager == null) { return null; diff --git a/escposprinter/src/main/java/com/dantsu/escposprinter/connection/usb/UsbDeviceHelper.java b/escposprinter/src/main/java/com/dantsu/escposprinter/connection/usb/UsbDeviceHelper.java index 7f212fd..8acc625 100644 --- a/escposprinter/src/main/java/com/dantsu/escposprinter/connection/usb/UsbDeviceHelper.java +++ b/escposprinter/src/main/java/com/dantsu/escposprinter/connection/usb/UsbDeviceHelper.java @@ -5,6 +5,8 @@ import android.hardware.usb.UsbEndpoint; import android.hardware.usb.UsbInterface; +import androidx.annotation.Nullable; + public class UsbDeviceHelper { /** * Find the correct USB interface for printing @@ -12,6 +14,7 @@ public class UsbDeviceHelper { * @param usbDevice USB device * @return correct USB interface for printing, null if not found */ + @Nullable static public UsbInterface findPrinterInterface(UsbDevice usbDevice) { if (usbDevice == null) { return null; @@ -32,6 +35,7 @@ static public UsbInterface findPrinterInterface(UsbDevice usbDevice) { * @param usbInterface USB interface * @return Input endpoint or null if not found */ + @Nullable static public UsbEndpoint findEndpointIn(UsbInterface usbInterface) { if (usbInterface != null) { int endpointsCount = usbInterface.getEndpointCount(); diff --git a/escposprinter/src/main/java/com/dantsu/escposprinter/connection/usb/UsbPrintersConnections.java b/escposprinter/src/main/java/com/dantsu/escposprinter/connection/usb/UsbPrintersConnections.java index 01a7f50..cf7ee4c 100644 --- a/escposprinter/src/main/java/com/dantsu/escposprinter/connection/usb/UsbPrintersConnections.java +++ b/escposprinter/src/main/java/com/dantsu/escposprinter/connection/usb/UsbPrintersConnections.java @@ -4,6 +4,8 @@ import android.hardware.usb.UsbConstants; import android.hardware.usb.UsbDevice; +import androidx.annotation.Nullable; + import com.dantsu.escposprinter.exceptions.EscPosConnectionException; public class UsbPrintersConnections extends UsbConnections { @@ -22,6 +24,7 @@ public UsbPrintersConnections(Context context) { * * @return a UsbConnection instance */ + @Nullable public static UsbConnection selectFirstConnected(Context context) { UsbPrintersConnections printers = new UsbPrintersConnections(context); UsbConnection[] bluetoothPrinters = printers.getList(); @@ -39,6 +42,7 @@ public static UsbConnection selectFirstConnected(Context context) { * * @return an array of UsbConnection */ + @Nullable public UsbConnection[] getList() { UsbConnection[] usbConnections = super.getList();