Browse Source

Very light code cleanup.

pull/465/head
Eric Kok 6 years ago
parent
commit
988c786892
  1. 34
      app/src/main/java/org/transdroid/daemon/Daemon.java
  2. 5
      app/src/main/java/org/transdroid/daemon/DaemonException.java
  3. 2
      app/src/main/java/org/transdroid/daemon/DaemonMethod.java

34
app/src/main/java/org/transdroid/daemon/Daemon.java

@ -302,12 +302,14 @@ public enum Daemon {
} }
public static boolean supportsAvailability(Daemon type) { 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) { public static boolean supportsFileListing(Daemon type) {
return type == Synology || type == Transmission || type == uTorrent || type == BitTorrent || type == KTorrent || type == Deluge || type == DelugeRpc return type == Synology || type == Transmission || type == uTorrent || type == BitTorrent || type == KTorrent || type == Deluge
|| type == rTorrent || type == Vuze || type == DLinkRouterBT || type == Bitflu || type == qBittorrent || type == BuffaloNas || type == BitComet || type == Aria2 || type == tTorrent || type == Dummy; || 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) { public static boolean supportsFineDetails(Daemon type) {
@ -339,7 +341,8 @@ public enum Daemon {
public static boolean supportsSetTransferRates(Daemon type) { public static boolean supportsSetTransferRates(Daemon type) {
return type == Deluge || type == DelugeRpc 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) { public static boolean supportsAddByFile(Daemon type) {
@ -349,26 +352,31 @@ public enum Daemon {
public static boolean supportsAddByMagnetUrl(Daemon type) { public static boolean supportsAddByMagnetUrl(Daemon type) {
return type == uTorrent || type == BitTorrent || type == Transmission || type == Synology || type == Deluge || type == DelugeRpc 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) { public static boolean supportsRemoveWithData(Daemon type) {
return type == uTorrent || type == Vuze || type == Transmission || type == Deluge || type == DelugeRpc 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) { 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; || type == qBittorrent || type == tTorrent || type == Dummy;
} }
public static boolean supportsDateAdded(Daemon type) { 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; || type == qBittorrent || type == Dummy;
} }
public static boolean supportsLabels(Daemon type) { 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) { public static boolean supportsSetLabel(Daemon type) {
@ -389,18 +397,16 @@ public enum Daemon {
} }
public static boolean supportsForceRecheck(Daemon type) { 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) { public static boolean supportsExtraPassword(Daemon type) {
return type == Deluge || type == Aria2; return type == Deluge || type == Aria2;
} }
public static boolean supportsUsernameForHttp(Daemon type) {
return type == Deluge || type == Aria2;
}
public static boolean supportsRemoteRssManagement(Daemon type) { public static boolean supportsRemoteRssManagement(Daemon type) {
return type == uTorrent || type == DelugeRpc; return type == uTorrent || type == DelugeRpc;
} }
} }

5
app/src/main/java/org/transdroid/daemon/DaemonException.java

@ -18,6 +18,8 @@
package org.transdroid.daemon; package org.transdroid.daemon;
import android.support.annotation.NonNull;
/** /**
* An exception thrown when an error occurs inside a server daemon adapter. * 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 * The error message is from a resource string ID, since this can be
@ -40,7 +42,7 @@ public class DaemonException extends Exception {
ParsingFailed, ParsingFailed,
AuthenticationFailure, AuthenticationFailure,
NotConnected, NotConnected,
FileAccessError; FileAccessError
} }
public DaemonException(ExceptionType internalException, String message) { public DaemonException(ExceptionType internalException, String message) {
@ -52,6 +54,7 @@ public class DaemonException extends Exception {
return internalException; return internalException;
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return internalException.toString() + " exception: " + getMessage(); return internalException.toString() + " exception: " + getMessage();

2
app/src/main/java/org/transdroid/daemon/DaemonMethod.java

@ -47,7 +47,7 @@ public enum DaemonMethod {
ForceRecheck (22); ForceRecheck (22);
private int code; private int code;
private static final Map<Integer,DaemonMethod> lookup = new HashMap<Integer,DaemonMethod>(); private static final Map<Integer,DaemonMethod> lookup = new HashMap<>();
static { static {
for(DaemonMethod s : EnumSet.allOf(DaemonMethod.class)) for(DaemonMethod s : EnumSet.allOf(DaemonMethod.class))

Loading…
Cancel
Save