Merge pull request #1958 from drabux/sort_by_feed_title
Add option to sort queue by feed title
This commit is contained in:
commit
6106fdc899
|
@ -304,11 +304,11 @@ public class QueueFragment extends Fragment {
|
|||
};
|
||||
conDialog.createNewDialog().show();
|
||||
return true;
|
||||
case R.id.queue_sort_alpha_asc:
|
||||
QueueSorter.sort(getActivity(), QueueSorter.Rule.ALPHA_ASC, true);
|
||||
case R.id.queue_sort_episode_title_asc:
|
||||
QueueSorter.sort(getActivity(), QueueSorter.Rule.EPISODE_TITLE_ASC, true);
|
||||
return true;
|
||||
case R.id.queue_sort_alpha_desc:
|
||||
QueueSorter.sort(getActivity(), QueueSorter.Rule.ALPHA_DESC, true);
|
||||
case R.id.queue_sort_episode_title_desc:
|
||||
QueueSorter.sort(getActivity(), QueueSorter.Rule.EPISODE_TITLE_DESC, true);
|
||||
return true;
|
||||
case R.id.queue_sort_date_asc:
|
||||
QueueSorter.sort(getActivity(), QueueSorter.Rule.DATE_ASC, true);
|
||||
|
@ -322,6 +322,12 @@ public class QueueFragment extends Fragment {
|
|||
case R.id.queue_sort_duration_desc:
|
||||
QueueSorter.sort(getActivity(), QueueSorter.Rule.DURATION_DESC, true);
|
||||
return true;
|
||||
case R.id.queue_sort_feed_title_asc:
|
||||
QueueSorter.sort(getActivity(), QueueSorter.Rule.FEED_TITLE_ASC, true);
|
||||
return true;
|
||||
case R.id.queue_sort_feed_title_desc:
|
||||
QueueSorter.sort(getActivity(), QueueSorter.Rule.FEED_TITLE_DESC, true);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -35,20 +35,6 @@
|
|||
android:title="@string/sort">
|
||||
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/queue_sort_alpha"
|
||||
android:title="@string/alpha">
|
||||
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/queue_sort_alpha_asc"
|
||||
android:title="@string/ascending"/>
|
||||
<item
|
||||
android:id="@+id/queue_sort_alpha_desc"
|
||||
android:title="@string/descending"/>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/queue_sort_date"
|
||||
android:title="@string/date">
|
||||
|
@ -77,6 +63,33 @@
|
|||
</menu>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/queue_sort_episode_title"
|
||||
android:title="@string/episode_title">
|
||||
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/queue_sort_episode_title_asc"
|
||||
android:title="@string/ascending"/>
|
||||
<item
|
||||
android:id="@+id/queue_sort_episode_title_desc"
|
||||
android:title="@string/descending"/>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/queue_sort_feed_title"
|
||||
android:title="@string/feed_title">
|
||||
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/queue_sort_feed_title_asc"
|
||||
android:title="@string/ascending"/>
|
||||
<item
|
||||
android:id="@+id/queue_sort_feed_title_desc"
|
||||
android:title="@string/descending"/>
|
||||
</menu>
|
||||
</item>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
|
|
|
@ -13,22 +13,24 @@ import de.danoeh.antennapod.core.storage.DBWriter;
|
|||
*/
|
||||
public class QueueSorter {
|
||||
public enum Rule {
|
||||
ALPHA_ASC,
|
||||
ALPHA_DESC,
|
||||
EPISODE_TITLE_ASC,
|
||||
EPISODE_TITLE_DESC,
|
||||
DATE_ASC,
|
||||
DATE_DESC,
|
||||
DURATION_ASC,
|
||||
DURATION_DESC
|
||||
DURATION_DESC,
|
||||
FEED_TITLE_ASC,
|
||||
FEED_TITLE_DESC
|
||||
}
|
||||
|
||||
public static void sort(final Context context, final Rule rule, final boolean broadcastUpdate) {
|
||||
Comparator<FeedItem> comparator = null;
|
||||
|
||||
switch (rule) {
|
||||
case ALPHA_ASC:
|
||||
case EPISODE_TITLE_ASC:
|
||||
comparator = (f1, f2) -> f1.getTitle().compareTo(f2.getTitle());
|
||||
break;
|
||||
case ALPHA_DESC:
|
||||
case EPISODE_TITLE_DESC:
|
||||
comparator = (f1, f2) -> f2.getTitle().compareTo(f1.getTitle());
|
||||
break;
|
||||
case DATE_ASC:
|
||||
|
@ -60,6 +62,12 @@ public class QueueSorter {
|
|||
return -1 * (duration1 - duration2);
|
||||
};
|
||||
break;
|
||||
case FEED_TITLE_ASC:
|
||||
comparator = (f1, f2) -> f1.getFeed().getTitle().compareTo(f2.getFeed().getTitle());
|
||||
break;
|
||||
case FEED_TITLE_DESC:
|
||||
comparator = (f1, f2) -> f2.getFeed().getTitle().compareTo(f1.getFeed().getTitle());
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
|
|
|
@ -231,9 +231,10 @@
|
|||
<string name="move_to_top_label">Move to top</string>
|
||||
<string name="move_to_bottom_label">Move to bottom</string>
|
||||
<string name="sort">Sort</string>
|
||||
<string name="alpha">Alphabetically</string>
|
||||
<string name="date">Date</string>
|
||||
<string name="duration">Duration</string>
|
||||
<string name="episode_title">Episode title</string>
|
||||
<string name="feed_title">Feed title</string>
|
||||
<string name="ascending">Ascending</string>
|
||||
<string name="descending">Descending</string>
|
||||
<string name="clear_queue_confirmation_msg">Please confirm that you want to clear the queue of ALL of the episodes in it</string>
|
||||
|
|
Loading…
Reference in New Issue