From 988c7868929d0f8f12d31fe955c5671e0a655014 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Fri, 5 Oct 2018 22:06:46 +0200 Subject: [PATCH] Very light code cleanup. --- .../java/org/transdroid/daemon/Daemon.java | 34 +++++++++++-------- .../transdroid/daemon/DaemonException.java | 5 ++- .../org/transdroid/daemon/DaemonMethod.java | 2 +- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/transdroid/daemon/Daemon.java b/app/src/main/java/org/transdroid/daemon/Daemon.java index 0d1b655f..1024efe3 100644 --- a/app/src/main/java/org/transdroid/daemon/Daemon.java +++ b/app/src/main/java/org/transdroid/daemon/Daemon.java @@ -302,12 +302,14 @@ public enum Daemon { } public static boolean supportsAvailability(Daemon type) { - return type == uTorrent || type == BitTorrent || type == DLinkRouterBT || type == Transmission || type == Vuze || type == BuffaloNas || type == Dummy; + return type == uTorrent || type == BitTorrent || type == DLinkRouterBT || type == Transmission || type == Vuze || type == BuffaloNas + || type == Dummy; } public static boolean supportsFileListing(Daemon type) { - return type == Synology || type == Transmission || type == uTorrent || type == BitTorrent || type == KTorrent || type == Deluge || type == DelugeRpc - || type == rTorrent || type == Vuze || type == DLinkRouterBT || type == Bitflu || type == qBittorrent || type == BuffaloNas || type == BitComet || type == Aria2 || type == tTorrent || type == Dummy; + return type == Synology || type == Transmission || type == uTorrent || type == BitTorrent || type == KTorrent || type == Deluge + || type == DelugeRpc || type == rTorrent || type == Vuze || type == DLinkRouterBT || type == Bitflu || type == qBittorrent + || type == BuffaloNas || type == BitComet || type == Aria2 || type == tTorrent || type == Dummy; } public static boolean supportsFineDetails(Daemon type) { @@ -339,7 +341,8 @@ public enum Daemon { public static boolean supportsSetTransferRates(Daemon type) { return type == Deluge || type == DelugeRpc - || type == Transmission || type == uTorrent || type == BitTorrent || type == rTorrent || type == Vuze || type == BuffaloNas || type == BitComet || type == Aria2 || type == qBittorrent || type == Dummy; + || type == Transmission || type == uTorrent || type == BitTorrent || type == rTorrent || type == Vuze || type == BuffaloNas + || type == BitComet || type == Aria2 || type == qBittorrent || type == Dummy; } public static boolean supportsAddByFile(Daemon type) { @@ -349,26 +352,31 @@ public enum Daemon { public static boolean supportsAddByMagnetUrl(Daemon type) { return type == uTorrent || type == BitTorrent || type == Transmission || type == Synology || type == Deluge || type == DelugeRpc - || type == Bitflu || type == KTorrent || type == rTorrent || type == qBittorrent || type == BitComet || type == Aria2 || type == tTorrent || type == Dummy; + || type == Bitflu || type == KTorrent || type == rTorrent || type == qBittorrent || type == BitComet || type == Aria2 + || type == tTorrent || type == Dummy; } public static boolean supportsRemoveWithData(Daemon type) { return type == uTorrent || type == Vuze || type == Transmission || type == Deluge || type == DelugeRpc - || type == BitTorrent || type == Tfb4rt || type == DLinkRouterBT || type == Bitflu || type == qBittorrent || type == BuffaloNas || type == BitComet || type == rTorrent || type == Aria2 || type == tTorrent || type == Dummy; + || type == BitTorrent || type == Tfb4rt || type == DLinkRouterBT || type == Bitflu || type == qBittorrent || type == BuffaloNas + || type == BitComet || type == rTorrent || type == Aria2 || type == tTorrent || type == Dummy; } public static boolean supportsFilePrioritySetting(Daemon type) { - return type == BitTorrent || type == uTorrent || type == Transmission || type == KTorrent || type == rTorrent || type == Vuze || type == Deluge || type == DelugeRpc + return type == BitTorrent || type == uTorrent || type == Transmission || type == KTorrent || type == rTorrent || type == Vuze + || type == Deluge || type == DelugeRpc || type == qBittorrent || type == tTorrent || type == Dummy; } public static boolean supportsDateAdded(Daemon type) { - return type == Vuze || type == Transmission || type == rTorrent || type == Bitflu || type == BitComet || type == uTorrent || type == BitTorrent || type == Deluge || type == DelugeRpc + return type == Vuze || type == Transmission || type == rTorrent || type == Bitflu || type == BitComet || type == uTorrent + || type == BitTorrent || type == Deluge || type == DelugeRpc || type == qBittorrent || type == Dummy; } public static boolean supportsLabels(Daemon type) { - return type == uTorrent || type == BitTorrent || type == Deluge || type == DelugeRpc || type == BitComet || type == rTorrent || type == qBittorrent || type == Dummy; + return type == uTorrent || type == BitTorrent || type == Deluge || type == DelugeRpc || type == BitComet || type == rTorrent + || type == qBittorrent || type == Dummy; } public static boolean supportsSetLabel(Daemon type) { @@ -389,18 +397,16 @@ public enum Daemon { } public static boolean supportsForceRecheck(Daemon type) { - return type == uTorrent || type == BitTorrent || type == Deluge || type == DelugeRpc || type == rTorrent || type == Transmission || type == Dummy || type == qBittorrent; + return type == uTorrent || type == BitTorrent || type == Deluge || type == DelugeRpc || type == rTorrent || type == Transmission + || type == Dummy || type == qBittorrent; } public static boolean supportsExtraPassword(Daemon type) { return type == Deluge || type == Aria2; } - public static boolean supportsUsernameForHttp(Daemon type) { - return type == Deluge || type == Aria2; - } - public static boolean supportsRemoteRssManagement(Daemon type) { return type == uTorrent || type == DelugeRpc; } + } diff --git a/app/src/main/java/org/transdroid/daemon/DaemonException.java b/app/src/main/java/org/transdroid/daemon/DaemonException.java index f2d721c7..ca367540 100644 --- a/app/src/main/java/org/transdroid/daemon/DaemonException.java +++ b/app/src/main/java/org/transdroid/daemon/DaemonException.java @@ -18,6 +18,8 @@ package org.transdroid.daemon; +import android.support.annotation.NonNull; + /** * An exception thrown when an error occurs inside a server daemon adapter. * The error message is from a resource string ID, since this can be @@ -40,7 +42,7 @@ public class DaemonException extends Exception { ParsingFailed, AuthenticationFailure, NotConnected, - FileAccessError; + FileAccessError } public DaemonException(ExceptionType internalException, String message) { @@ -52,6 +54,7 @@ public class DaemonException extends Exception { return internalException; } + @NonNull @Override public String toString() { return internalException.toString() + " exception: " + getMessage(); diff --git a/app/src/main/java/org/transdroid/daemon/DaemonMethod.java b/app/src/main/java/org/transdroid/daemon/DaemonMethod.java index d459dcb1..f9ec9b7b 100644 --- a/app/src/main/java/org/transdroid/daemon/DaemonMethod.java +++ b/app/src/main/java/org/transdroid/daemon/DaemonMethod.java @@ -47,7 +47,7 @@ public enum DaemonMethod { ForceRecheck (22); private int code; - private static final Map lookup = new HashMap(); + private static final Map lookup = new HashMap<>(); static { for(DaemonMethod s : EnumSet.allOf(DaemonMethod.class))