use of com.android.tools.idea.configurations.ConfigurationListener.CFG_DEVICE in project android by JetBrains.
the class Scene method add.
/**
* Add the NlComponents contained in the given NlModel to the Scene
*
* @param model the NlModel to use
*/
public void add(@NotNull NlModel model) {
ConfigurationListener listener = (flags) -> {
if ((flags & CFG_DEVICE) != 0 && !isManualDpiFactor) {
float newDpiFactor = model.getConfiguration().getDensity().getDpiValue() / 160f;
if (myDpiFactor != newDpiFactor) {
// Update from the model to update the dpi
updateFrom(model);
}
}
return true;
};
model.getConfiguration().addListener(listener);
Disposer.register(model, () -> model.getConfiguration().removeListener(listener));
List<NlComponent> components = model.getComponents();
if (components.size() != 0) {
NlComponent rootComponent = components.get(0).getRoot();
myAnimate = false;
myRoot = updateFromComponent(rootComponent);
myAnimate = true;
addTargets(myRoot);
}
model.addListener(this);
myModel = model;
// let's make sure the selection is correct
if (myScreenView != null) {
selectionChanged(myScreenView.getSelectionModel(), myScreenView.getSelectionModel().getSelection());
}
}
Aggregations