use of im.actor.core.api.rpc.ResponseGetParameters in project actor-platform by actorapp.
the class SettingsSyncActor method preStart.
@Override
public void preStart() {
super.preStart();
syncState = new SettingsSyncState();
byte[] data = preferences().getBytes(SYNC_STATE);
if (data != null) {
try {
syncState = SettingsSyncState.fromBytes(data);
} catch (IOException e) {
e.printStackTrace();
}
}
for (SettingsSyncAction action : syncState.getPendingActions()) {
performSync(action);
}
if (!preferences().getBool(SYNC_STATE_LOADED, false)) {
// TODO: Avoid race conditions
request(new RequestGetParameters(), new RpcCallback<ResponseGetParameters>() {
@Override
public void onResult(ResponseGetParameters response) {
for (ApiParameter p : response.getParameters()) {
context().getSettingsModule().onUpdatedSetting(p.getKey(), p.getValue());
}
context().getSettingsModule().notifySettingsChanged();
preferences().putBool(SYNC_STATE_LOADED, true);
context().getConductor().getConductor().onSettingsLoaded();
}
@Override
public void onError(RpcException e) {
// Ignore
}
});
} else {
context().getConductor().getConductor().onSettingsLoaded();
}
}
Aggregations