Hack-y fixes#115 by manually stripping out decimal separators to parse numbers in a somewhat reliable way. Should work with most locales. Also party fixes#102 or at least until the real date done is given by the qBittorrent web interface.
@ -139,41 +137,42 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -139,41 +137,42 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -181,7 +180,8 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -181,7 +180,8 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -222,7 +222,9 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -222,7 +222,9 @@ public class QbittorrentAdapter implements IDaemonAdapter {
}
// We have to make a separate request per file, it seems
@ -231,18 +233,20 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -231,18 +233,20 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -309,7 +313,8 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -309,7 +313,8 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -331,18 +336,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -331,18 +336,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -387,30 +381,15 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -387,30 +381,15 @@ public class QbittorrentAdapter implements IDaemonAdapter {
doubleratio=parseRatio(tor.getString("ratio"));
doubleprogress=tor.getDouble("progress");
intdlspeed=parseSpeed(tor.getString("dlspeed"));
longeta=-1L;
if(dlspeed>0)
eta=(long)(size-(size*progress))/dlspeed;
// Date added is only available in /json/propertiesGeneral on a per-torrent basis, unfortunately
// Add the parsed torrent to the list
torrents.add(newTorrent(
(long)i,
tor.getString("hash"),
tor.getString("name"),
parseStatus(tor.getString("state")),
null,
dlspeed,
parseSpeed(tor.getString("upspeed")),
leechers,
leechers+seeders,
known,
known,
(int)((size-(size*progress))/dlspeed),
(long)(size*progress),
(long)(size*ratio),
size,
(float)progress,
0f,
null,
null,// Only available in /json/propertiesGeneral on a per-torrent basis, unfortunately
@ -421,6 +400,8 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -421,6 +400,8 @@ public class QbittorrentAdapter implements IDaemonAdapter {
privatedoubleparseRatio(Stringstring){
// Ratio is given in "1.5" string format
try{
// FIXME Hack for issue #115: Strip the possible . and , separators in a hopefully reliable fashion, for now
string=string.replace(",",".");
returnDouble.parseDouble(string);
}catch(Exceptione){
return0D;
@ -431,19 +412,31 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -431,19 +412,31 @@ public class QbittorrentAdapter implements IDaemonAdapter {
// See https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-Documentation
if(string.equals("Unknown"))
return-1;
// Sizes are given in "703.3 MiB"-like string format
// Returns size in B-based long
// Sizes are given in "1,023.3 MiB"-like string format
// FIXME Hack for issue #115: Strip the possible . and , separators in a hopefully reliable fashion, for now
@ -533,14 +526,8 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -533,14 +526,8 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -142,12 +142,14 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
@@ -142,12 +142,14 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
if(realDateDone!=null){
this.dateDone=realDateDone;
}else{
if(this.partDone==1){//finished but no finished date set so move to bottom of list
if(this.partDone==1){
// Finished but no finished date: set so move to bottom of list