Merge pull request #445 from sk22/better-inline-emoji-search
Improve inline emoji search
This commit is contained in:
commit
b79ba71228
|
@ -28,6 +28,7 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
@ -154,11 +155,16 @@ public class ComposeAutocompleteViewController{
|
||||||
}else if(mode==Mode.EMOJIS){
|
}else if(mode==Mode.EMOJIS){
|
||||||
String _text=text.substring(1); // remove ':'
|
String _text=text.substring(1); // remove ':'
|
||||||
List<WrappedEmoji> oldList=emojis;
|
List<WrappedEmoji> oldList=emojis;
|
||||||
emojis=AccountSessionManager.getInstance()
|
List<Emoji> allEmojis = AccountSessionManager.getInstance()
|
||||||
.getCustomEmojis(AccountSessionManager.getInstance().getAccount(accountID).domain)
|
.getCustomEmojis(AccountSessionManager.getInstance().getAccount(accountID).domain)
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(ec->ec.emojis.stream())
|
.flatMap(ec->ec.emojis.stream())
|
||||||
.filter(e->e.visibleInPicker && e.shortcode.startsWith(_text))
|
.filter(e->e.visibleInPicker)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<Emoji> startsWithSearch = allEmojis.stream().filter(e -> e.shortcode.toLowerCase().startsWith(_text.toLowerCase())).collect(Collectors.toList());
|
||||||
|
emojis=Stream.concat(startsWithSearch.stream(), allEmojis.stream()
|
||||||
|
.filter(e -> !startsWithSearch.contains(e))
|
||||||
|
.filter(e -> e.shortcode.toLowerCase().contains(_text.toLowerCase())))
|
||||||
.map(WrappedEmoji::new)
|
.map(WrappedEmoji::new)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
UiUtils.updateList(oldList, emojis, list, emojisAdapter, (e1, e2)->e1.emoji.shortcode.equals(e2.emoji.shortcode));
|
UiUtils.updateList(oldList, emojis, list, emojisAdapter, (e1, e2)->e1.emoji.shortcode.equals(e2.emoji.shortcode));
|
||||||
|
|
Loading…
Reference in New Issue