Browse Source

core/lib: allow for sorting based on torrent size

pull/165/head
Dan Pasanen 10 years ago
parent
commit
1473d81224
  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

@ -73,6 +73,7 @@ @@ -73,6 +73,7 @@
<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" />
<item android:id="@+id/action_sort_size" android:title="@string/action_sort_size" />
</menu>
</item>
<item

1
core/res/values/strings.xml

@ -36,6 +36,7 @@ @@ -36,6 +36,7 @@
<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_sort_size">Size</string>
<string name="action_filter">Filter list</string>
<string name="action_settings">Settings</string>
<string name="action_help">Help</string>

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

@ -816,6 +816,11 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -816,6 +816,11 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
fragmentTorrents.sortBy(TorrentsSortBy.Ratio);
}
@OptionsItem(resName = "action_sort_size")
protected void sortBySize() {
fragmentTorrents.sortBy(TorrentsSortBy.Size);
}
@OptionsItem(resName = "action_filter")
protected void startFilterEntryDialog() {
FilterEntryDialog.startFilterEntry(this);

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

@ -74,6 +74,8 @@ public class TorrentsComparator implements Comparator<Torrent> { @@ -74,6 +74,8 @@ public class TorrentsComparator implements Comparator<Torrent> {
return new Integer(tor1.getRateUpload()).compareTo(new Integer(tor2.getRateUpload()));
case Ratio:
return new Double(tor1.getRatio()).compareTo(new Double(tor2.getRatio()));
case Size:
return new Double(tor1.getTotalSize()).compareTo(new Double(tor2.getTotalSize()));
default:
return alphanumComparator.compare(tor1.getName().toLowerCase(), tor2.getName().toLowerCase());
}
@ -97,6 +99,8 @@ public class TorrentsComparator implements Comparator<Torrent> { @@ -97,6 +99,8 @@ public class TorrentsComparator implements Comparator<Torrent> {
return 0 - (new Integer(tor1.getRateUpload()).compareTo(new Integer(tor2.getRateUpload())));
case Ratio:
return 0 - new Double(tor1.getRatio()).compareTo(new Double(tor2.getRatio()));
case Size:
return 0 - new Double(tor1.getTotalSize()).compareTo(new Double(tor2.getTotalSize()));
default:
return 0 - alphanumComparator.compare(tor1.getName().toLowerCase(), tor2.getName().toLowerCase());
}

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

@ -29,7 +29,8 @@ public enum TorrentsSortBy { @@ -29,7 +29,8 @@ public enum TorrentsSortBy {
UploadSpeed (5),
Ratio (6),
DownloadSpeed (7),
Percent (8);
Percent (8),
Size (9);
private int code;
private static final Map<Integer,TorrentsSortBy> lookup = new HashMap<Integer,TorrentsSortBy>();

Loading…
Cancel
Save