Browse Source

Sort files in details screen using natural order.

pull/11/head
Eric Kok 12 years ago
parent
commit
b81bf09e53
  1. 3
      core/res/values/strings.xml
  2. 2
      core/src/org/transdroid/core/gui/lists/TorrentDetailsView.java
  3. 9
      lib/src/org/transdroid/daemon/TorrentFilesComparator.java
  4. 4
      lib/src/org/transdroid/daemon/TorrentsComparator.java

3
core/res/values/strings.xml

@ -78,7 +78,8 @@ @@ -78,7 +78,8 @@
<string name="status_ratio">RATIO %1$s</string>
<string name="status_peers">%1$s OF %2$s PEERS</string>
<string name="status_speed_up" translatable="false">↑ %1$s</string>
<string name="status_speed_down" translatable="false">%1$s ↓</string>
<string name="status_speed_down" translatable="false">↓ %1$s</string>
<string name="status_speed_down_details" translatable="false">%1$s ↓</string>
<string name="status_downloading">Downloading</string>
<string name="status_seeding">Seeding</string>
<string name="status_paused">Paused</string>

2
core/src/org/transdroid/core/gui/lists/TorrentDetailsView.java

@ -84,7 +84,7 @@ public class TorrentDetailsView extends RelativeLayout { @@ -84,7 +84,7 @@ public class TorrentDetailsView extends RelativeLayout {
downloadedunitText.setText(FileSizeConverter.getSizeUnit(torrent.getDownloadedEver()).toString());
uploadedText.setText(FileSizeConverter.getSize(torrent.getUploadedEver(), false));
uploadedunitText.setText(FileSizeConverter.getSizeUnit(torrent.getUploadedEver()).toString());
downspeedText.setText(getResources().getString(R.string.status_speed_down,
downspeedText.setText(getResources().getString(R.string.status_speed_down_details,
FileSizeConverter.getSize(torrent.getRateDownload()) + "/s"));
upspeedText.setText(getResources().getString(R.string.status_speed_up,
FileSizeConverter.getSize(torrent.getRateUpload()) + "/s"));

9
lib/src/org/transdroid/daemon/TorrentFilesComparator.java

@ -28,8 +28,9 @@ import java.util.Comparator; @@ -28,8 +28,9 @@ import java.util.Comparator;
*/
public class TorrentFilesComparator implements Comparator<TorrentFile> {
TorrentFilesSortBy sortBy;
boolean reversed;
private TorrentFilesSortBy sortBy;
private boolean reversed;
private Comparator<String> alphanumComparator = new AlphanumComparator();
/**
* Instantiate a torrent files comparator.
@ -50,7 +51,7 @@ public class TorrentFilesComparator implements Comparator<TorrentFile> { @@ -50,7 +51,7 @@ public class TorrentFilesComparator implements Comparator<TorrentFile> {
case TotalSize:
return new Long(file1.getTotalSize()).compareTo(file2.getTotalSize());
default:
return file1.getName().toLowerCase().compareTo(file2.getName().toLowerCase());
return alphanumComparator.compare(file1.getName().toLowerCase(), file2.getName().toLowerCase());
}
} else {
switch (sortBy) {
@ -59,7 +60,7 @@ public class TorrentFilesComparator implements Comparator<TorrentFile> { @@ -59,7 +60,7 @@ public class TorrentFilesComparator implements Comparator<TorrentFile> {
case TotalSize:
return 0 - new Long(file1.getTotalSize()).compareTo(file2.getTotalSize());
default:
return 0 - file1.getName().toLowerCase().compareTo(file2.getName().toLowerCase());
return 0 - alphanumComparator.compare(file1.getName().toLowerCase(), file2.getName().toLowerCase());
}
}
}

4
lib/src/org/transdroid/daemon/TorrentsComparator.java

@ -67,7 +67,7 @@ public class TorrentsComparator implements Comparator<Torrent> { @@ -67,7 +67,7 @@ public class TorrentsComparator implements Comparator<Torrent> {
case Ratio:
return new Double(tor1.getRatio()).compareTo(new Double(tor2.getRatio()));
default:
return alphanumComparator.compare(tor1.getName(), tor2.getName());
return alphanumComparator.compare(tor1.getName().toLowerCase(), tor2.getName().toLowerCase());
}
} else {
switch (sortBy) {
@ -82,7 +82,7 @@ public class TorrentsComparator implements Comparator<Torrent> { @@ -82,7 +82,7 @@ public class TorrentsComparator implements Comparator<Torrent> {
case Ratio:
return 0 - new Double(tor1.getRatio()).compareTo(new Double(tor2.getRatio()));
default:
return 0 - alphanumComparator.compare(tor1.getName(), tor2.getName());
return 0 - alphanumComparator.compare(tor1.getName().toLowerCase(), tor2.getName().toLowerCase());
}
}
}

Loading…
Cancel
Save