Fixes bug where the order of notifications could be jumbled when removing duplicates using a HashSet.

This commit is contained in:
Vavassor 2017-07-13 20:17:50 -04:00
commit 5754a3a177
4 changed files with 17 additions and 11 deletions

View file

@ -17,6 +17,8 @@ package com.keylesspalace.tusky.util;
import android.support.annotation.Nullable;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
public class ListUtils {
@ -33,4 +35,11 @@ public class ListUtils {
return list.size();
}
}
/** @return a new ArrayList containing the elements without duplicates in the same order */
public static <T> ArrayList<T> removeDuplicates(List<T> list) {
LinkedHashSet<T> set = new LinkedHashSet<>();
set.addAll(list);
return new ArrayList<>(set);
}
}