Browse Source

Fixes #525 labels support for qBittorrent < 4.1

pull/551/head
Eric Kok 5 years ago
parent
commit
39d69ea7ed
  1. 8
      app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

8
app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

@ -641,12 +641,10 @@ public class QbittorrentAdapter implements IDaemonAdapter {
Map<String, Label> labels = new HashMap<>(); Map<String, Label> labels = new HashMap<>();
for (int i = 0; i < response.length(); i++) { for (int i = 0; i < response.length(); i++) {
JSONObject tor = response.getJSONObject(i); JSONObject tor = response.getJSONObject(i);
if (version >= 40100) { if (tor.has("category")) {
String label = tor.optString("category"); String label = tor.optString("category");
if (label != null && label.length() > 0) { final Label labelObject = labels.get(label);
final Label labelObject = labels.get(label); labels.put(label, new Label(label, (labelObject != null) ? labelObject.getCount() + 1 : 1));
labels.put(label, new Label(label, (labelObject != null) ? labelObject.getCount() + 1 : 1));
}
} }
} }
return new ArrayList<>(labels.values()); return new ArrayList<>(labels.values());

Loading…
Cancel
Save