From 4f96d850cc9a2807d61076ef50ed1dbd6e54b339 Mon Sep 17 00:00:00 2001 From: Vavassor Date: Fri, 28 Jul 2017 12:36:54 -0400 Subject: [PATCH] Fixes a crash when autocompleting a mention, second try. (previous fix was commit ab537ef3cbacaeca6e2a19ca3ffc6403ac5c1dbe) --- .../java/com/keylesspalace/tusky/ComposeActivity.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 4ddafd3e..6f22c48c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -1663,24 +1663,25 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm return ((Account) resultValue).username; } + // This method is invoked in a worker thread. @Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults filterResults = new FilterResults(); if (constraint != null) { ArrayList accounts = autocompleteMention(constraint.toString()); - synchronized (this) { - resultList.clear(); - resultList.addAll(accounts); - } filterResults.values = accounts; filterResults.count = accounts.size(); } return filterResults; } + @SuppressWarnings("unchecked") @Override protected void publishResults(CharSequence constraint, FilterResults results) { if (results != null && results.count > 0) { + resultList.clear(); + ArrayList newResults = (ArrayList) results.values; + resultList.addAll(newResults); notifyDataSetChanged(); } else { notifyDataSetInvalidated();