Browse Source

Added sorting by download speed. Fixes #34.

pull/82/head
Eric Kok 11 years ago
parent
commit
ee44470a3a
  1. 1
      core/res/menu/activity_torrents.xml
  2. 1
      core/res/values/strings.xml
  3. 5
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  4. 4
      lib/src/org/transdroid/daemon/TorrentsComparator.java
  5. 3
      lib/src/org/transdroid/daemon/TorrentsSortBy.java

1
core/res/menu/activity_torrents.xml

@ -69,6 +69,7 @@ @@ -69,6 +69,7 @@
<item android:id="@+id/action_sort_status" android:title="@string/action_sort_status" />
<item android:id="@+id/action_sort_done" android:title="@string/action_sort_done" />
<item android:id="@+id/action_sort_added" android:title="@string/action_sort_added" />
<item android:id="@+id/action_sort_downspeed" android:title="@string/action_sort_downspeed" />
<item android:id="@+id/action_sort_upspeed" android:title="@string/action_sort_upspeed" />
<item android:id="@+id/action_sort_ratio" android:title="@string/action_sort_ratio" />
</menu>

1
core/res/values/strings.xml

@ -32,6 +32,7 @@ @@ -32,6 +32,7 @@
<string name="action_sort_status">Status</string>
<string name="action_sort_done">Date done</string>
<string name="action_sort_added">Date added</string>
<string name="action_sort_downspeed">Download speed</string>
<string name="action_sort_upspeed">Upload speed</string>
<string name="action_sort_ratio">Ratio</string>
<string name="action_filter">Filter list</string>

5
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -683,6 +683,11 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -683,6 +683,11 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
fragmentTorrents.sortBy(TorrentsSortBy.DateAdded);
}
@OptionsItem(resName = "action_sort_downspeed")
protected void sortByDownspeed() {
fragmentTorrents.sortBy(TorrentsSortBy.DownloadSpeed);
}
@OptionsItem(resName = "action_sort_upspeed")
protected void sortByUpspeed() {
fragmentTorrents.sortBy(TorrentsSortBy.UploadSpeed);

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

@ -66,6 +66,8 @@ public class TorrentsComparator implements Comparator<Torrent> { @@ -66,6 +66,8 @@ public class TorrentsComparator implements Comparator<Torrent> {
return tor1.getDateAdded().compareTo(tor2.getDateAdded());
case DateDone:
return tor1.getDateDone().compareTo(tor2.getDateDone());
case DownloadSpeed:
return new Integer(tor1.getRateDownload()).compareTo(new Integer(tor2.getRateDownload()));
case UploadSpeed:
return new Integer(tor1.getRateUpload()).compareTo(new Integer(tor2.getRateUpload()));
case Ratio:
@ -85,6 +87,8 @@ public class TorrentsComparator implements Comparator<Torrent> { @@ -85,6 +87,8 @@ public class TorrentsComparator implements Comparator<Torrent> {
return 0 - tor1.getDateAdded().compareTo(tor2.getDateAdded());
case DateDone:
return 0 - tor1.getDateDone().compareTo(tor2.getDateDone());
case DownloadSpeed:
return 0 - (new Integer(tor1.getRateDownload()).compareTo(new Integer(tor2.getRateDownload())));
case UploadSpeed:
return 0 - (new Integer(tor1.getRateUpload()).compareTo(new Integer(tor2.getRateUpload())));
case Ratio:

3
lib/src/org/transdroid/daemon/TorrentsSortBy.java

@ -27,7 +27,8 @@ public enum TorrentsSortBy { @@ -27,7 +27,8 @@ public enum TorrentsSortBy {
DateDone (3),
DateAdded (4),
UploadSpeed (5),
Ratio (6);
Ratio (6),
DownloadSpeed (7);
private int code;
private static final Map<Integer,TorrentsSortBy> lookup = new HashMap<Integer,TorrentsSortBy>();

Loading…
Cancel
Save