修复 java.util.concurrent.RejectedExecutionException

Task org.autojs.autojs.model.autocomplete.AnyWordsCompletion$$Lambda$0@d714baf rejected from java.util.concurrent.ThreadPoolExecutor@6a6bbbc[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 30]
This commit is contained in:
hyb1996
2018-10-18 10:35:14 +08:00
parent 5b0ef0b272
commit 9e3b40e3c9
3 changed files with 9 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package org.autojs.autojs.model.autocomplete;
import android.text.Editable;
import android.text.TextWatcher;
import org.autojs.autojs.model.indices.Property;
import org.autojs.autojs.ui.widget.SimpleTextWatcher;
@@ -15,7 +16,7 @@ import java.util.regex.Pattern;
* Created by Stardust on 2018/2/26.
*/
public class AnyWordsCompletion implements SimpleTextWatcher.AfterTextChangedListener {
public class AnyWordsCompletion extends SimpleTextWatcher {
private static final String PATTERN = "[\\W]";

View File

@@ -45,11 +45,13 @@ public class AutoCompletion {
private AnyWordsCompletion mAnyWordsCompletion;
private AtomicInteger mExecuteId = new AtomicInteger();
private Handler mHandler = new Handler(Looper.getMainLooper());
private final EditText mEditText;
public AutoCompletion(Context context, EditText editText) {
buildDictionaryTree(context);
mEditText = editText;
mAnyWordsCompletion = new AnyWordsCompletion(mExecutorService);
editText.addTextChangedListener(new SimpleTextWatcher(mAnyWordsCompletion));
editText.addTextChangedListener(mAnyWordsCompletion);
}
public void setAutoCompleteCallback(AutoCompleteCallback autoCompleteCallback) {
@@ -162,6 +164,7 @@ public class AutoCompletion {
public void shutdown(){
mEditText.removeTextChangedListener(mAnyWordsCompletion);
mExecutorService.shutdownNow();
}
}

View File

@@ -43,6 +43,9 @@ public class SimpleTextWatcher implements TextWatcher {
mOnTextChangedListener = onTextChangedListener;
}
public SimpleTextWatcher() {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
if (mBeforeTextChangedListener != null) {