Browse Source

Java 5 migration

pull/559/head
TacoTheDank 4 years ago
parent
commit
4256193edd
  1. 2
      app/src/main/java/org/transdroid/daemon/adapters/deluge/DelugeRpcClient.java
  2. 6
      app/src/main/java/org/transdroid/daemon/adapters/synology/SynologyAdapter.java
  3. 4
      app/src/main/java/org/transdroid/daemon/task/SetTransferRatesTask.java
  4. 2
      app/src/main/java/org/transdroid/daemon/util/SelfSignedTrustManager.java

2
app/src/main/java/org/transdroid/daemon/adapters/deluge/DelugeRpcClient.java

@ -162,7 +162,7 @@ class DelugeRpcClient implements Closeable {
if (!(responseObject instanceof List)) { if (!(responseObject instanceof List)) {
throw new DaemonException(ExceptionType.UnexpectedResponse, responseObject.toString()); throw new DaemonException(ExceptionType.UnexpectedResponse, responseObject.toString());
} }
final List response = (List) responseObject; final List<?> response = (List<?>) responseObject;
if (response.size() < RESPONSE_RETURN_VALUE_INDEX + 1) { if (response.size() < RESPONSE_RETURN_VALUE_INDEX + 1) {
throw new DaemonException(ExceptionType.UnexpectedResponse, responseObject.toString()); throw new DaemonException(ExceptionType.UnexpectedResponse, responseObject.toString());

6
app/src/main/java/org/transdroid/daemon/adapters/synology/SynologyAdapter.java

@ -323,7 +323,7 @@ public class SynologyAdapter implements IDaemonAdapter {
long downloaded = transfer.getLong("size_downloaded"); long downloaded = transfer.getLong("size_downloaded");
int speed = transfer.getInt("speed_download"); int speed = transfer.getInt("speed_download");
long size = jsonTorrent.getLong("size"); long size = jsonTorrent.getLong("size");
Float eta = Float.valueOf(size - downloaded) / speed; float eta = (float) (size - downloaded) / speed;
int totalSeeders = 0; int totalSeeders = 0;
int totalLeechers = 0; int totalLeechers = 0;
if (additional.has("tracker")) { if (additional.has("tracker")) {
@ -349,11 +349,11 @@ public class SynologyAdapter implements IDaemonAdapter {
totalSeeders, totalSeeders,
detail.getInt("connected_leechers"), detail.getInt("connected_leechers"),
totalLeechers, totalLeechers,
eta.intValue(), (int) eta,
downloaded, downloaded,
transfer.getLong("size_uploaded"), transfer.getLong("size_uploaded"),
size, size,
(size == 0) ? 0 : (Float.valueOf(downloaded) / size), (size == 0) ? 0 : ((float) downloaded / size),
0, 0,
jsonTorrent.getString("title"), jsonTorrent.getString("title"),
new Date(detail.getLong("create_time") * 1000), new Date(detail.getLong("create_time") * 1000),

4
app/src/main/java/org/transdroid/daemon/task/SetTransferRatesTask.java

@ -29,8 +29,8 @@ public class SetTransferRatesTask extends DaemonTask {
public static SetTransferRatesTask create(IDaemonAdapter adapter, Integer uploadRate, Integer downloadRate) { public static SetTransferRatesTask create(IDaemonAdapter adapter, Integer uploadRate, Integer downloadRate) {
Bundle data = new Bundle(); Bundle data = new Bundle();
data.putInt("UPLOAD_RATE", (uploadRate == null ? -1 : uploadRate.intValue())); data.putInt("UPLOAD_RATE", (uploadRate == null ? -1 : uploadRate));
data.putInt("DOWNLOAD_RATE", (downloadRate == null ? -1 : downloadRate.intValue())); data.putInt("DOWNLOAD_RATE", (downloadRate == null ? -1 : downloadRate));
return new SetTransferRatesTask(adapter, data); return new SetTransferRatesTask(adapter, data);
} }

2
app/src/main/java/org/transdroid/daemon/util/SelfSignedTrustManager.java

@ -48,7 +48,7 @@ public class SelfSignedTrustManager implements X509TrustManager {
private static String hexify(byte[] bytes) { private static String hexify(byte[] bytes) {
char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
StringBuffer buf = new StringBuffer(bytes.length * 2); StringBuilder buf = new StringBuilder(bytes.length * 2);
for (byte aByte : bytes) { for (byte aByte : bytes) {
buf.append(hexDigits[(aByte & 0xf0) >> 4]); buf.append(hexDigits[(aByte & 0xf0) >> 4]);
buf.append(hexDigits[aByte & 0x0f]); buf.append(hexDigits[aByte & 0x0f]);

Loading…
Cancel
Save