/** * Changes properties of a simulated display. If `qualifiersStr` starts with a plus (`+`) sign, * the display's previous configuration is modified with the given qualifiers; otherwise defaults * are applied as described [here](http://robolectric.org/device-configuration/). * * * @param displayId the display id to change * @param qualifiersStr the {@link Qualifiers} string representing characteristics of the new * display */ public static void changeDisplay(int displayId, String qualifiersStr) { DisplayInfo baseDisplayInfo = DisplayManagerGlobal.getInstance().getDisplayInfo(displayId); DisplayInfo displayInfo = createDisplayInfo(qualifiersStr, baseDisplayInfo); getShadowDisplayManagerGlobal().changeDisplay(displayId, displayInfo); }
/** * Changes properties of a simulated display. The original properties will be passed to the * `consumer`, which may modify them in place. The display will be updated with the new * properties. * * @param displayId the display id to change * @param consumer a function which modifies the display properties */ static void changeDisplay(int displayId, Consumer<DisplayConfig> consumer) { DisplayInfo displayInfo = DisplayManagerGlobal.getInstance().getDisplayInfo(displayId); if (displayInfo != null) { DisplayConfig displayConfig = new DisplayConfig(displayInfo); consumer.accept(displayConfig); displayConfig.copyTo(displayInfo); fixNominalDimens(displayInfo); } getShadowDisplayManagerGlobal().changeDisplay(displayId, displayInfo); }
/** * Changes properties of a simulated display. If `qualifiersStr` starts with a plus (`+`) sign, * the display's previous configuration is modified with the given qualifiers; otherwise defaults * are applied as described [here](http://robolectric.org/device-configuration/). * * * @param displayId the display id to change * @param qualifiersStr the {@link Qualifiers} string representing characteristics of the new * display */ public static void changeDisplay(int displayId, String qualifiersStr) { DisplayInfo baseDisplayInfo = DisplayManagerGlobal.getInstance().getDisplayInfo(displayId); DisplayInfo displayInfo = createDisplayInfo(qualifiersStr, baseDisplayInfo); getShadowDisplayManagerGlobal().changeDisplay(displayId, displayInfo); }
/** * Changes properties of a simulated display. The original properties will be passed to the * `consumer`, which may modify them in place. The display will be updated with the new * properties. * * @param displayId the display id to change * @param consumer a function which modifies the display properties */ static void changeDisplay(int displayId, Consumer<DisplayConfig> consumer) { DisplayInfo displayInfo = DisplayManagerGlobal.getInstance().getDisplayInfo(displayId); if (displayInfo != null) { DisplayConfig displayConfig = new DisplayConfig(displayInfo); consumer.accept(displayConfig); displayConfig.copyTo(displayInfo); fixNominalDimens(displayInfo); } getShadowDisplayManagerGlobal().changeDisplay(displayId, displayInfo); }