本文整理了Java中android.view.Display.getDisplayId()
方法的一些代码示例,展示了Display.getDisplayId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Display.getDisplayId()
方法的具体详情如下:
包路径:android.view.Display
类名称:Display
方法名:getDisplayId
暂无
代码示例来源:origin: robolectric/robolectric
public List<View> getViews() {
return ImmutableList.copyOf(views.get(realObject.getDefaultDisplay().getDisplayId()));
}
代码示例来源:origin: ACRA/acra
@Override
void collect(@NonNull ReportField reportField, @NonNull Context context, @NonNull CoreConfiguration config, @NonNull ReportBuilder reportBuilder, @NonNull CrashReportData target) {
final JSONObject result = new JSONObject();
for (Display display : getDisplays(context)) {
try {
result.put(String.valueOf(display.getDisplayId()), collectDisplayData(display));
} catch (JSONException e) {
ACRA.log.w(ACRA.LOG_TAG, "Failed to collect data for display " + display.getDisplayId(), e);
}
}
target.put(ReportField.DISPLAY, result);
}
代码示例来源:origin: robolectric/robolectric
/**
* If {@link #setDisplayId(int)} has been called, this method will return the specified value.
*
* @deprecated This behavior is deprecated and will be removed in Robolectric 3.7.
*/
@Deprecated
@Implementation
protected int getDisplayId() {
return displayId == null
? directlyOn(realObject, Display.class).getDisplayId()
: displayId;
}
代码示例来源:origin: square/assertj-android
public DisplayAssert hasDisplayId(int id) {
isNotNull();
int actualId = actual.getDisplayId();
assertThat(actualId) //
.overridingErrorMessage("Expected ID <%s> but was <%s>", id, actualId) //
.isEqualTo(id);
return this;
}
代码示例来源:origin: robolectric/robolectric
/**
* Changes the vertical DPI for this display.
*
* Any registered {@link android.hardware.display.DisplayManager.DisplayListener}s will be
* notified of the change.
*/
public void setYdpi(float ydpi) {
if (isJB()) {
this.ydpi = ydpi;
} else {
ShadowDisplayManager.changeDisplay(realObject.getDisplayId(),
di -> di.physicalYDpi = ydpi);
}
}
代码示例来源:origin: robolectric/robolectric
/**
* Changes the density for this display.
*
* Any registered {@link android.hardware.display.DisplayManager.DisplayListener}s will be
* notified of the change.
*/
public void setDensityDpi(int densityDpi) {
if (isJB()) {
this.densityDpi = densityDpi;
} else {
ShadowDisplayManager.changeDisplay(realObject.getDisplayId(),
di -> di.logicalDensityDpi = densityDpi);
}
}
代码示例来源:origin: robolectric/robolectric
/**
* Changes the name for this display.
*
* Any registered {@link android.hardware.display.DisplayManager.DisplayListener}s will be
* notified of the change.
*/
public void setName(String name) {
if (isJB()) {
this.name = name;
} else {
ShadowDisplayManager.changeDisplay(realObject.getDisplayId(),
di -> di.name = name);
}
}
代码示例来源:origin: robolectric/robolectric
/**
* Changes the horizontal DPI for this display.
*
* Any registered {@link android.hardware.display.DisplayManager.DisplayListener}s will be
* notified of the change.
*/
public void setXdpi(float xdpi) {
if (isJB()) {
this.xdpi = xdpi;
} else {
ShadowDisplayManager.changeDisplay(realObject.getDisplayId(),
di -> di.physicalXDpi = xdpi);
}
}
代码示例来源:origin: robolectric/robolectric
/**
* Changes the height available to the application for this display.
*
* Any registered {@link android.hardware.display.DisplayManager.DisplayListener}s will be
* notified of the change.
*
* @param height new height in pixels
*/
public void setHeight(int height) {
if (isJB()) {
this.height = height;
} else {
ShadowDisplayManager.changeDisplay(realObject.getDisplayId(),
di -> di.appHeight = height);
}
}
代码示例来源:origin: robolectric/robolectric
/**
* Changes the simulated state for this display, such as whether it is on or off
*
* Any registered {@link android.hardware.display.DisplayManager.DisplayListener}s will be
* notified of the change.
*
* @param state the new state: one of {@link Display#STATE_OFF}, {@link Display#STATE_ON},
* {@link Display#STATE_DOZE}, {@link Display#STATE_DOZE_SUSPEND}, or
* {@link Display#STATE_UNKNOWN}.
*/
public void setState(int state) {
if (!isJB()) {
ShadowDisplayManager.changeDisplay(realObject.getDisplayId(),
di -> di.state = state);
}
}
代码示例来源:origin: robolectric/robolectric
/**
* Changes the simulated physical width for this display.
*
* Any registered {@link android.hardware.display.DisplayManager.DisplayListener}s will be
* notified of the change.
*
* @param width the new width in pixels
*/
public void setRealWidth(int width) {
if (isJB()) {
this.realWidth = width;
} else {
ShadowDisplayManager.changeDisplay(realObject.getDisplayId(),
di -> di.logicalWidth = width);
}
}
代码示例来源:origin: robolectric/robolectric
/**
* Changes the simulated physical height for this display.
*
* Any registered {@link android.hardware.display.DisplayManager.DisplayListener}s will be
* notified of the change.
*
* @param height the new height in pixels
*/
public void setRealHeight(int height) {
if (isJB()) {
this.realHeight = height;
} else {
ShadowDisplayManager.changeDisplay(realObject.getDisplayId(),
di -> di.logicalHeight = height);
}
}
代码示例来源:origin: robolectric/robolectric
/**
* Changes the width available to the application for this display.
*
* Any registered {@link android.hardware.display.DisplayManager.DisplayListener}s will be
* notified of the change.
*
* @param width the new width in pixels
*/
public void setWidth(int width) {
if (isJB()) {
this.width = width;
} else {
ShadowDisplayManager.changeDisplay(realObject.getDisplayId(),
di -> di.appWidth = width);
}
}
代码示例来源:origin: robolectric/robolectric
/**
* Changes the rotation for this display.
*
* Any registered {@link android.hardware.display.DisplayManager.DisplayListener}s will be
* notified of the change.
*
* @param rotation one of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
* {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}
*/
public void setRotation(int rotation) {
if (isJB()) {
this.rotation = rotation;
} else {
ShadowDisplayManager.changeDisplay(realObject.getDisplayId(),
di -> di.rotation = rotation);
}
}
代码示例来源:origin: robolectric/robolectric
@Implementation
public void removeView(View view) {
views.remove(realObject.getDefaultDisplay().getDisplayId(), view);
directlyOn(realObject, WindowManagerImpl.class, "removeView",
ClassParameter.from(View.class, view));
}
代码示例来源:origin: robolectric/robolectric
@Implementation
protected void removeViewImmediate(View view) {
views.remove(realObject.getDefaultDisplay().getDisplayId(), view);
directlyOn(
realObject,
WindowManagerImpl.class,
"removeViewImmediate",
ClassParameter.from(View.class, view));
}
代码示例来源:origin: robolectric/robolectric
@Implementation
public void addView(View view, android.view.ViewGroup.LayoutParams layoutParams) {
views.put(realObject.getDefaultDisplay().getDisplayId(), view);
// views.add(view);
directlyOn(
realObject,
WindowManagerImpl.class,
"addView",
ClassParameter.from(View.class, view),
ClassParameter.from(ViewGroup.LayoutParams.class, layoutParams));
}
代码示例来源:origin: robolectric/robolectric
/**
* Changes the flags for this display.
*
* Any registered {@link android.hardware.display.DisplayManager.DisplayListener}s will be
* notified of the change.
*/
public void setFlags(int flags) {
reflector(_Display_.class, realObject).setFlags(flags);
if (!isJB()) {
ShadowDisplayManager.changeDisplay(realObject.getDisplayId(),
di -> di.flags = flags);
}
}
代码示例来源:origin: robolectric/robolectric
@Test @Config(minSdk = JELLY_BEAN_MR1)
public void withQualifiers_changeDisplay_shouldUpdateSmallestAndLargestNominalWidthAndHeight() throws Exception {
Point smallest = new Point();
Point largest = new Point();
Display display = ShadowDisplay.getDefaultDisplay();
display.getCurrentSizeRange(smallest, largest);
assertThat(smallest).isEqualTo(new Point(320, 320));
assertThat(largest).isEqualTo(new Point(470, 470));
ShadowDisplayManager.changeDisplay(display.getDisplayId(), "w310dp-h460dp");
display.getCurrentSizeRange(smallest, largest);
assertThat(smallest).isEqualTo(new Point(310, 310));
assertThat(largest).isEqualTo(new Point(460, 460));
}
代码示例来源:origin: robolectric/robolectric
@Test @Config(minSdk = JELLY_BEAN_MR1)
public void addDisplay() throws Exception {
int displayId = ShadowDisplayManager.addDisplay("w100dp-h200dp");
assertThat(displayId).isGreaterThan(0);
DisplayInfo di = getGlobal().getDisplayInfo(displayId);
assertThat(di.appWidth).isEqualTo(100);
assertThat(di.appHeight).isEqualTo(200);
Display display = instance.getDisplay(displayId);
assertThat(display.getDisplayId()).isEqualTo(displayId);
}
内容来源于网络,如有侵权,请联系作者删除!