fixed several async operation listeners, assigned to static objects, not being cleared after the end of the operation
This commit is contained in:
parent
44bd6ce084
commit
a7d4fa8318
6 changed files with 32 additions and 8 deletions
|
|
@ -48,6 +48,13 @@ public class CustomWordsImporter extends AbstractFileProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void clearAllHandlers() {
|
||||||
|
failureHandler = null;
|
||||||
|
progressHandler = null;
|
||||||
|
successHandler = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setProgressHandler(ConsumerCompat<Integer> handler) {
|
public void setProgressHandler(ConsumerCompat<Integer> handler) {
|
||||||
progressHandler = handler;
|
progressHandler = handler;
|
||||||
}
|
}
|
||||||
|
|
@ -71,6 +78,7 @@ public class CustomWordsImporter extends AbstractFileProcessor {
|
||||||
protected void sendSuccess() {
|
protected void sendSuccess() {
|
||||||
if (successHandler != null) {
|
if (successHandler != null) {
|
||||||
successHandler.accept(file.getName());
|
successHandler.accept(file.getName());
|
||||||
|
clearAllHandlers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,6 +86,7 @@ public class CustomWordsImporter extends AbstractFileProcessor {
|
||||||
private void sendFailure(String errorMessage) {
|
private void sendFailure(String errorMessage) {
|
||||||
if (failureHandler != null) {
|
if (failureHandler != null) {
|
||||||
failureHandler.accept(errorMessage);
|
failureHandler.accept(errorMessage);
|
||||||
|
clearAllHandlers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,7 @@ public class DictionaryDeleter extends BaseSyncStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteTask = null;
|
deleteTask = null;
|
||||||
|
onFinish();
|
||||||
if (notification != null) {
|
|
||||||
notification.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.d(LOG_TAG, "Deleted " + languages.size() + " languages. Time: " + Timer.stop(LOG_TAG) + " ms");
|
Logger.d(LOG_TAG, "Deleted " + languages.size() + " languages. Time: " + Timer.stop(LOG_TAG) + " ms");
|
||||||
}
|
}
|
||||||
|
|
@ -91,6 +88,7 @@ public class DictionaryDeleter extends BaseSyncStore {
|
||||||
private void onFinish() {
|
private void onFinish() {
|
||||||
if (notification != null) {
|
if (notification != null) {
|
||||||
notification.run();
|
notification.run();
|
||||||
|
notification = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,12 @@ public class DictionaryLoader {
|
||||||
progressMsg.putLong("time", Timer.get(IMPORT_TIMER));
|
progressMsg.putLong("time", Timer.get(IMPORT_TIMER));
|
||||||
progressMsg.putInt("progress", Math.round(progress));
|
progressMsg.putInt("progress", Math.round(progress));
|
||||||
progressMsg.putInt("currentFile", currentFile);
|
progressMsg.putInt("currentFile", currentFile);
|
||||||
asyncHandler.post(() -> onStatusChange.accept(progressMsg));
|
asyncHandler.post(() -> {
|
||||||
|
onStatusChange.accept(progressMsg);
|
||||||
|
if (progress >= 100) {
|
||||||
|
onStatusChange = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -363,7 +368,10 @@ public class DictionaryLoader {
|
||||||
Bundle errorMsg = new Bundle();
|
Bundle errorMsg = new Bundle();
|
||||||
errorMsg.putString("error", message);
|
errorMsg.putString("error", message);
|
||||||
errorMsg.putInt("languageId", langId);
|
errorMsg.putInt("languageId", langId);
|
||||||
asyncHandler.post(() -> onStatusChange.accept(errorMsg));
|
asyncHandler.post(() -> {
|
||||||
|
onStatusChange.accept(errorMsg);
|
||||||
|
onStatusChange = null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -377,7 +385,10 @@ public class DictionaryLoader {
|
||||||
errorMsg.putString("error", message);
|
errorMsg.putString("error", message);
|
||||||
errorMsg.putLong("fileLine", fileLine + 1);
|
errorMsg.putLong("fileLine", fileLine + 1);
|
||||||
errorMsg.putInt("languageId", langId);
|
errorMsg.putInt("languageId", langId);
|
||||||
asyncHandler.post(() -> onStatusChange.accept(errorMsg));
|
asyncHandler.post(() -> {
|
||||||
|
onStatusChange.accept(errorMsg);
|
||||||
|
onStatusChange = null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ abstract public class TextEditingHandler extends VoiceHandler {
|
||||||
mainView.showCommandPalette();
|
mainView.showCommandPalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
Clipboard.setOnChangeListener(this, null);
|
Clipboard.clearListener(this);
|
||||||
resetStatus();
|
resetStatus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
import io.github.sspanak.tt9.ui.UI;
|
import io.github.sspanak.tt9.ui.UI;
|
||||||
import io.github.sspanak.tt9.ui.dialogs.RequestPermissionDialog;
|
import io.github.sspanak.tt9.ui.dialogs.RequestPermissionDialog;
|
||||||
import io.github.sspanak.tt9.util.Logger;
|
import io.github.sspanak.tt9.util.Logger;
|
||||||
|
import io.github.sspanak.tt9.util.sys.Clipboard;
|
||||||
import io.github.sspanak.tt9.util.sys.DeviceInfo;
|
import io.github.sspanak.tt9.util.sys.DeviceInfo;
|
||||||
import io.github.sspanak.tt9.util.sys.SystemSettings;
|
import io.github.sspanak.tt9.util.sys.SystemSettings;
|
||||||
|
|
||||||
|
|
@ -174,6 +175,7 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
stopVoiceInput();
|
stopVoiceInput();
|
||||||
onFinishTyping();
|
onFinishTyping();
|
||||||
suggestionOps.clear();
|
suggestionOps.clear();
|
||||||
|
Clipboard.clearListener(this);
|
||||||
statusBar.setText(mInputMode);
|
statusBar.setText(mInputMode);
|
||||||
|
|
||||||
if (isInputViewShown()) {
|
if (isInputViewShown()) {
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,10 @@ public class Clipboard {
|
||||||
externalChangeListener = newListener;
|
externalChangeListener = newListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clearListener(Context context) {
|
||||||
|
setOnChangeListener(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
private static void changeListener() {
|
private static void changeListener() {
|
||||||
if (ignoreNextChange) {
|
if (ignoreNextChange) {
|
||||||
ignoreNextChange = false;
|
ignoreNextChange = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue