修复 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:
@@ -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]";
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user