Fix for not responsive home screen widget
If the app is killed the widget doesn't receive updates and it keeps the old value of the editor. Pressing f.e. cursor buttons in such case has not effect as real editor is empty and no "editor change" events are triggered, thus, widget is not updated. To solve the issue let's just update the widget any time its buttons are pressed.
This commit is contained in:
parent
d5e5c9b6ac
commit
733cc27599
@ -69,6 +69,9 @@ public final class App {
|
|||||||
|
|
||||||
private static volatile boolean initialized;
|
private static volatile boolean initialized;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private static CalculatorBroadcaster broadcaster;
|
||||||
|
|
||||||
private App() {
|
private App() {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
@ -104,6 +107,7 @@ public final class App {
|
|||||||
App.locator = new ServiceLocator() {
|
App.locator = new ServiceLocator() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
App.broadcaster = new CalculatorBroadcaster(application);
|
||||||
|
|
||||||
App.initialized = true;
|
App.initialized = true;
|
||||||
} else {
|
} else {
|
||||||
@ -163,4 +167,9 @@ public final class App {
|
|||||||
checkInit();
|
checkInit();
|
||||||
return eventBus;
|
return eventBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static CalculatorBroadcaster getBroadcaster() {
|
||||||
|
return broadcaster;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,15 +32,15 @@ public final class CalculatorBroadcaster implements CalculatorEventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendDisplayStateChanged() {
|
public void sendDisplayStateChanged() {
|
||||||
sendBroadcastIntent(ACTION_DISPLAY_STATE_CHANGED);
|
sendBroadcastIntent(ACTION_DISPLAY_STATE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendEditorStateChangedIntent() {
|
public void sendEditorStateChangedIntent() {
|
||||||
sendBroadcastIntent(ACTION_EDITOR_STATE_CHANGED);
|
sendBroadcastIntent(ACTION_EDITOR_STATE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendBroadcastIntent(@Nonnull String action) {
|
public void sendBroadcastIntent(@Nonnull String action) {
|
||||||
context.sendBroadcast(new Intent(action));
|
context.sendBroadcast(new Intent(action));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ public final class CalculatorReceiver extends BroadcastReceiver {
|
|||||||
if (button != null) {
|
if (button != null) {
|
||||||
button.onClick(context);
|
button.onClick(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
App.getBroadcaster().sendEditorStateChangedIntent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,9 +97,6 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
protected final Handler uiHandler = new Handler();
|
protected final Handler uiHandler = new Handler();
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final CalculatorBroadcaster broadcaster = new CalculatorBroadcaster(this);
|
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private final Wizards wizards = new CalculatorWizards(this);
|
private final Wizards wizards = new CalculatorWizards(this);
|
||||||
|
|
||||||
@ -194,7 +191,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
calculator.addCalculatorEventListener(listener);
|
calculator.addCalculatorEventListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
calculator.addCalculatorEventListener(broadcaster);
|
calculator.addCalculatorEventListener(App.getBroadcaster());
|
||||||
|
|
||||||
Locator.getInstance().getCalculator().init();
|
Locator.getInstance().getCalculator().init();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user