no background tasks are scheduled after shutting down (yet another attempt to fix the Privileged Options problem)
This commit is contained in:
parent
c908ac1c33
commit
2bad9d60f9
1 changed files with 15 additions and 11 deletions
|
|
@ -22,7 +22,7 @@ import io.github.sspanak.tt9.util.SystemSettings;
|
||||||
|
|
||||||
public class TraditionalT9 extends MainViewHandler {
|
public class TraditionalT9 extends MainViewHandler {
|
||||||
@NonNull
|
@NonNull
|
||||||
private final Handler normalizationHandler = new Handler(Looper.getMainLooper());
|
private final Handler backgroundTasks = new Handler(Looper.getMainLooper());
|
||||||
private final Handler deathDetector = new Handler(Looper.getMainLooper());
|
private final Handler deathDetector = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -140,7 +140,7 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
if (mInputMode.isPassthrough()) {
|
if (mInputMode.isPassthrough()) {
|
||||||
onStop();
|
onStop();
|
||||||
} else {
|
} else {
|
||||||
normalizationHandler.removeCallbacksAndMessages(null);
|
backgroundTasks.removeCallbacksAndMessages(null);
|
||||||
initUi();
|
initUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,14 +170,10 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
updateInputViewShown();
|
updateInputViewShown();
|
||||||
}
|
}
|
||||||
|
|
||||||
normalizationHandler.removeCallbacksAndMessages(null);
|
if (SystemSettings.isTT9Active(this)) {
|
||||||
normalizationHandler.postDelayed(
|
backgroundTasks.removeCallbacksAndMessages(null);
|
||||||
() -> {
|
backgroundTasks.postDelayed(this::runBackgroundTasks, SettingsStore.WORD_BACKGROUND_TASKS_DELAY);
|
||||||
DataStore.saveWordPairs();
|
}
|
||||||
if (!DictionaryLoader.getInstance(this).isRunning()) DataStore.normalizeNext();
|
|
||||||
},
|
|
||||||
SettingsStore.WORD_BACKGROUND_TASKS_DELAY
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -197,7 +193,7 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
Logger.w("onDeath", "===> Killing self");
|
Logger.w("onDeath", "===> Killing self");
|
||||||
requestHideSelf(0);
|
requestHideSelf(0);
|
||||||
onStop();
|
onStop();
|
||||||
normalizationHandler.removeCallbacksAndMessages(null);
|
backgroundTasks.removeCallbacksAndMessages(null);
|
||||||
DataStore.destroy();
|
DataStore.destroy();
|
||||||
stopSelf();
|
stopSelf();
|
||||||
}
|
}
|
||||||
|
|
@ -223,4 +219,12 @@ public class TraditionalT9 extends MainViewHandler {
|
||||||
protected TraditionalT9 getFinalContext() {
|
protected TraditionalT9 getFinalContext() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void runBackgroundTasks() {
|
||||||
|
DataStore.saveWordPairs();
|
||||||
|
if (!DictionaryLoader.getInstance(this).isRunning()) {
|
||||||
|
DataStore.normalizeNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue