Fixes bug where the order of notifications could be jumbled when removing duplicates using a HashSet.
This commit is contained in:
parent
b77d9934ab
commit
5754a3a177
4 changed files with 17 additions and 11 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue