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) {
|
||||
progressHandler = handler;
|
||||
}
|
||||
|
|
@ -71,6 +78,7 @@ public class CustomWordsImporter extends AbstractFileProcessor {
|
|||
protected void sendSuccess() {
|
||||
if (successHandler != null) {
|
||||
successHandler.accept(file.getName());
|
||||
clearAllHandlers();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +86,7 @@ public class CustomWordsImporter extends AbstractFileProcessor {
|
|||
private void sendFailure(String errorMessage) {
|
||||
if (failureHandler != null) {
|
||||
failureHandler.accept(errorMessage);
|
||||
clearAllHandlers();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,10 +58,7 @@ public class DictionaryDeleter extends BaseSyncStore {
|
|||
}
|
||||
|
||||
deleteTask = null;
|
||||
|
||||
if (notification != null) {
|
||||
notification.run();
|
||||
}
|
||||
onFinish();
|
||||
|
||||
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() {
|
||||
if (notification != null) {
|
||||
notification.run();
|
||||
notification = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -350,7 +350,12 @@ public class DictionaryLoader {
|
|||
progressMsg.putLong("time", Timer.get(IMPORT_TIMER));
|
||||
progressMsg.putInt("progress", Math.round(progress));
|
||||
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();
|
||||
errorMsg.putString("error", message);
|
||||
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.putLong("fileLine", fileLine + 1);
|
||||
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();
|
||||
}
|
||||
|
||||
Clipboard.setOnChangeListener(this, null);
|
||||
Clipboard.clearListener(this);
|
||||
resetStatus();
|
||||
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.dialogs.RequestPermissionDialog;
|
||||
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.SystemSettings;
|
||||
|
||||
|
|
@ -174,6 +175,7 @@ public class TraditionalT9 extends MainViewHandler {
|
|||
stopVoiceInput();
|
||||
onFinishTyping();
|
||||
suggestionOps.clear();
|
||||
Clipboard.clearListener(this);
|
||||
statusBar.setText(mInputMode);
|
||||
|
||||
if (isInputViewShown()) {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,10 @@ public class Clipboard {
|
|||
externalChangeListener = newListener;
|
||||
}
|
||||
|
||||
public static void clearListener(Context context) {
|
||||
setOnChangeListener(context, null);
|
||||
}
|
||||
|
||||
private static void changeListener() {
|
||||
if (ignoreNextChange) {
|
||||
ignoreNextChange = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue