9th attempt to fix the privileged options problem: removed onDestroy debugging code and explicitly destroying LanguageCollection and DataStore on shutdown
This commit is contained in:
parent
a7d4fa8318
commit
d0579e9362
3 changed files with 17 additions and 12 deletions
|
|
@ -40,6 +40,12 @@ public class DataStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void destroy() {
|
||||||
|
words = null;
|
||||||
|
pairs = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void runInThread(@NonNull Runnable action) {
|
private static void runInThread(@NonNull Runnable action) {
|
||||||
executor.submit(action);
|
executor.submit(action);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,15 @@
|
||||||
package io.github.sspanak.tt9.ime;
|
package io.github.sspanak.tt9.ime;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputConnection;
|
import android.view.inputmethod.InputConnection;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.R;
|
|
||||||
import io.github.sspanak.tt9.db.DataStore;
|
import io.github.sspanak.tt9.db.DataStore;
|
||||||
import io.github.sspanak.tt9.db.words.DictionaryLoader;
|
import io.github.sspanak.tt9.db.words.DictionaryLoader;
|
||||||
import io.github.sspanak.tt9.hacks.InputType;
|
import io.github.sspanak.tt9.hacks.InputType;
|
||||||
|
|
@ -248,6 +245,8 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
backgroundTasks.removeCallbacksAndMessages(null);
|
backgroundTasks.removeCallbacksAndMessages(null);
|
||||||
zombieChecks = SettingsStore.ZOMBIE_CHECK_MAX;
|
zombieChecks = SettingsStore.ZOMBIE_CHECK_MAX;
|
||||||
zombieDetector.removeCallbacksAndMessages(null);
|
zombieDetector.removeCallbacksAndMessages(null);
|
||||||
|
LanguageCollection.destroy();
|
||||||
|
DataStore.destroy();
|
||||||
Logger.d(LOG_TAG, "===> Final cleanup completed");
|
Logger.d(LOG_TAG, "===> Final cleanup completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -262,18 +261,13 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
cleanUp();
|
cleanUp();
|
||||||
isDead = true;
|
isDead = true;
|
||||||
|
|
||||||
// @todo: investigate the crash and remove this try-catch
|
|
||||||
try {
|
try {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Dialog win = getWindow();
|
if (mainView != null && mainView.getView() != null) {
|
||||||
Window winwin = win != null ? win.getWindow() : null;
|
Logger.e(LOG_TAG, "===> MainView destroy failed: " + e.getMessage() + ". Destroying manually.");
|
||||||
View keys = winwin != null ? winwin.findViewById(R.id.main_soft_keys) : null;
|
mainView.destroy();
|
||||||
boolean hasWindowToken = keys != null && keys.getWindowToken() != null;
|
}
|
||||||
boolean hasAppToken = keys != null && keys.getApplicationWindowToken() != null;
|
|
||||||
|
|
||||||
String shutdownDebug = "Window token: " + hasWindowToken + "; App token: " + hasAppToken + "; main view: " + (keys != null) + "; window.window: " + (winwin != null) + "; window: " + (win != null);
|
|
||||||
throw new RuntimeException("Parent failed to destroy." + shutdownDebug);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.d(LOG_TAG, "===> Shutdown completed");
|
Logger.d(LOG_TAG, "===> Shutdown completed");
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,11 @@ public class LanguageCollection {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void destroy() {
|
||||||
|
self = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static NaturalLanguage getLanguage(String langId) {
|
public static NaturalLanguage getLanguage(String langId) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue