Browse Source

Fixed torrent list sorting.

pull/11/head
Eric Kok 12 years ago
parent
commit
ed718e2cfe
  1. BIN
      core/res/drawable-hdpi/ic_action_turtle_enabled.png
  2. BIN
      core/res/drawable-mdpi/ic_action_turtle_disabled.png
  3. BIN
      core/res/drawable-mdpi/ic_action_turtle_enabled.png
  4. BIN
      core/res/drawable-xhdpi/ic_action_turtle_disabled.png
  5. BIN
      core/res/drawable-xhdpi/ic_action_turtle_enabled.png
  6. 2
      core/res/layout/fragment_details.xml
  7. 2
      core/res/layout/fragment_torrents.xml
  8. 29
      core/src/org/transdroid/core/gui/TorrentsFragment.java

BIN
core/res/drawable-hdpi/ic_action_turtle_enabled.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

BIN
core/res/drawable-mdpi/ic_action_turtle_disabled.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

BIN
core/res/drawable-mdpi/ic_action_turtle_enabled.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

BIN
core/res/drawable-xhdpi/ic_action_turtle_disabled.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
core/res/drawable-xhdpi/ic_action_turtle_enabled.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

2
core/res/layout/fragment_details.xml

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
android:layout_height="128dp"
android:layout_gravity="center"
android:indeterminate="true"
android:indeterminateDrawable="@drawable/loading_progress_dark"
android:indeterminateDrawable="?attr/loading_progress"
android:indeterminateOnly="true"
android:visibility="gone" />

2
core/res/layout/fragment_torrents.xml

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
android:layout_height="128dp"
android:layout_gravity="center"
android:indeterminate="true"
android:indeterminateDrawable="@drawable/loading_progress_dark"
android:indeterminateDrawable="?attr/loading_progress"
android:indeterminateOnly="true"
android:visibility="visible" />

29
core/src/org/transdroid/core/gui/TorrentsFragment.java

@ -112,22 +112,15 @@ public class TorrentsFragment extends SherlockFragment { @@ -112,22 +112,15 @@ public class TorrentsFragment extends SherlockFragment {
this.currentSortDescending = false;
}
applicationSettings.setLastUsedSortOrder(this.currentSortOrder, this.currentSortDescending);
// Get the server daemon type directly form the local list of torrents, if it's not empty
Daemon serverType = (this.torrents != null && this.torrents.size() > 0 ? this.torrents.get(0).getDaemon()
: Daemon.Transmission);
Collections.sort(this.torrents, new TorrentsComparator(serverType, this.currentSortOrder,
this.currentSortDescending));
// Show the new resorted list
applyAllFilters();
}
public void applyTextFilter(String newTextFilter) {
this.currentTextFilter = newTextFilter;
// TODO: Actually apply text filter
// Show the new filtered list
applyAllFilters();
}
/**
* Apply a filter on the current list of all torrents, showing the appropriate sublist of torrents only
* @param newFilter The new filter to apply to the local list of torrents
@ -136,15 +129,18 @@ public class TorrentsFragment extends SherlockFragment { @@ -136,15 +129,18 @@ public class TorrentsFragment extends SherlockFragment {
this.currentNavigationFilter = newFilter;
applyAllFilters();
}
private void applyAllFilters() {
// No torrents? Directly update views accordingly
// No torrents? Directly update views accordingly
if (torrents == null) {
updateViewVisibility();
return;
}
// Get the server daemon type directly form the local list of torrents, if it's not empty
Daemon serverType = (this.torrents.size() > 0 ? this.torrents.get(0).getDaemon() : Daemon.Transmission);
// Filter the list of torrents to show according to navigation and text filters
ArrayList<Torrent> filteredTorrents = torrents;
if (torrents != null && currentNavigationFilter != null) {
@ -162,6 +158,11 @@ public class TorrentsFragment extends SherlockFragment { @@ -162,6 +158,11 @@ public class TorrentsFragment extends SherlockFragment {
torrentIter.remove();
}
}
// Sort the list of filtered torrents
Collections.sort(this.torrents, new TorrentsComparator(serverType, this.currentSortOrder,
this.currentSortDescending));
((TorrentsAdapter) torrentsList.getAdapter()).update(filteredTorrents);
updateViewVisibility();
}
@ -237,7 +238,7 @@ public class TorrentsFragment extends SherlockFragment { @@ -237,7 +238,7 @@ public class TorrentsFragment extends SherlockFragment {
@ItemClick(resName = "torrent_list")
protected void torrentsListClicked(Torrent torrent) {
((TorrentsActivity)getActivity()).openDetails(torrent);
((TorrentsActivity) getActivity()).openDetails(torrent);
}
/**

Loading…
Cancel
Save