mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
sort lists before changing position
This commit is contained in:
@@ -270,6 +270,13 @@ public class CategoryREST extends AbstractResourceREST {
|
||||
if (req.getPosition() != null) {
|
||||
List<FeedCategory> categories = feedCategoryDAO.findByParent(
|
||||
getUser(), parent);
|
||||
Collections.sort(categories, new Comparator<FeedCategory>() {
|
||||
@Override
|
||||
public int compare(FeedCategory o1, FeedCategory o2) {
|
||||
return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
|
||||
}
|
||||
});
|
||||
|
||||
int existingIndex = -1;
|
||||
for (int i = 0; i < categories.size(); i++) {
|
||||
if (ObjectUtils.equals(categories.get(i).getId(),
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.commafeed.frontend.rest.resources;
|
||||
import java.io.StringWriter;
|
||||
import java.net.URI;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -332,6 +334,13 @@ public class FeedREST extends AbstractResourceREST {
|
||||
if (req.getPosition() != null) {
|
||||
List<FeedSubscription> subs = feedSubscriptionDAO.findByCategory(
|
||||
getUser(), parent);
|
||||
Collections.sort(subs, new Comparator<FeedSubscription>() {
|
||||
@Override
|
||||
public int compare(FeedSubscription o1, FeedSubscription o2) {
|
||||
return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
|
||||
}
|
||||
});
|
||||
|
||||
int existingIndex = -1;
|
||||
for (int i = 0; i < subs.size(); i++) {
|
||||
if (ObjectUtils.equals(subs.get(i).getId(),
|
||||
|
||||
Reference in New Issue
Block a user