List of usage examples for android.view Display getDisplayId
public int getDisplayId()
From source file:org.xwalk.runtime.extension.api.device_capabilities.DeviceCapabilitiesDisplay.java
public void onResume() { Display[] displays = mDisplayManager.getDisplays(); // Firstly, check whether display in latest list is in cached display list. // If not found, then send out "onconnect" message and insert to cache. // If found, only update the display object without sending message. for (Display disp : displays) { Display foundDisplay = mDisplayList.get(disp.getDisplayId()); if (foundDisplay == null) { notifyAndSaveConnectedDisplay(disp); } else {//from w w w . j a v a 2s. c o m mDisplayList.put(disp.getDisplayId(), disp); } } // Secondly, remove those displays that only in cache. for (int i = 0; i < mDisplayList.size(); i++) { boolean found = false; for (Display disp : displays) { if (mDisplayList.valueAt(i).getDisplayId() == disp.getDisplayId()) { found = true; break; } } if (!found) { notifyAndRemoveDisconnectedDisplay(mDisplayList.valueAt(i)); } } // Register the listener to display manager. // // XWalkDisplayManager.registerDisplayListener only works on UI thread, // otherwise coredump. // // Register the listener here lead to a connect/disconnect event will // unconditionally be posted to JS whatever there is a JS listener // registered or not. It is kind of waste of resource. // // Fortunately, the listneres map in JSAPI will ensurce no noise messages // will exposed out. mDisplayManager.registerDisplayListener(mDisplayListener); }
From source file:org.chromium.ChromeSystemDisplay.java
private JSONObject getDisplayInfo(final Display display) throws JSONException { JSONObject displayInfo = new JSONObject(); displayInfo.put("id", Integer.toString(display.getDisplayId())); try {//from ww w . ja v a 2 s.co m displayInfo.put("name", display.getName()); } catch (NoSuchMethodError e) { displayInfo.put("name", "Default"); } displayInfo.put("isPrimary", display.getDisplayId() == android.view.Display.DEFAULT_DISPLAY); displayInfo.put("dpiX", getDpiX(display)); displayInfo.put("dpiY", getDpiY(display)); displayInfo.put("rotation", getRotation(display)); displayInfo.put("bounds", getBounds(display)); displayInfo.put("overscan", getOverscan()); displayInfo.put("workArea", getWorkArea(display)); // mirroringSourceId, isInternal and isEnabled cannot be retrieved at this moment. return displayInfo; }
From source file:me.wimanacra.collector.DisplayManagerCollector.java
@NonNull @Override/*ww w. j av a2 s.c om*/ Element collect(ReportField reportField, ReportBuilder reportBuilder) { final ComplexElement result = new ComplexElement(); for (Display display : DisplayManagerCompat.getInstance(context).getDisplays()) { 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); } } return result; }
From source file:org.acra.collector.DisplayManagerCollector.java
@NonNull private Object collectDisplayData(@NonNull Display display) { final DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics);/*from w w w . jav a 2 s .co m*/ //noinspection deprecation return collectCurrentSizeRange(display) + collectFlags(display) + display.getDisplayId() + ".height=" + display.getHeight() + '\n' + collectMetrics(display) + collectName(display) + display.getDisplayId() + ".orientation=" + display.getRotation() + '\n' + display.getDisplayId() + ".pixelFormat=" + display.getPixelFormat() + '\n' + collectRealMetrics(display) + collectRealSize(display) + collectRectSize(display) + display.getDisplayId() + ".refreshRate=" + display.getRefreshRate() + '\n' + collectRotation(display) + collectSize(display) + display.getDisplayId() + ".width=" + display.getWidth() + '\n' + collectIsValid(display); }
From source file:com.commonsware.android.preso.fragment.MainActivity.java
private void handleRoute(RouteInfo route) { if (route == null) { clearPreso(true);/*from w ww .j av a 2 s . c o m*/ } else { Display display = route.getPresentationDisplay(); if (route.isEnabled() && display != null) { if (preso == null) { showPreso(route); Log.d(getClass().getSimpleName(), "enabled route"); } else if (preso.getDisplay().getDisplayId() != display.getDisplayId()) { clearPreso(true); showPreso(route); Log.d(getClass().getSimpleName(), "switched route"); } else { // no-op: should already be set } } else { clearPreso(true); Log.d(getClass().getSimpleName(), "disabled route"); } } }
From source file:org.xwalk.runtime.extension.api.device_capabilities.DeviceCapabilitiesDisplay.java
private void notifyAndRemoveDisconnectedDisplay(Display disp) { JSONObject out = new JSONObject(); try {/*from w w w .j a v a 2s. c om*/ out.put("reply", "disconnectDisplay"); out.put("eventName", "displaydisconnect"); out.put("data", convertDisplayToJSON(disp)); mDeviceCapabilities.broadcastMessage(out.toString()); mDisplayList.remove(disp.getDisplayId()); } catch (JSONException e) { mDeviceCapabilities.printErrorMessage(e); } }
From source file:org.xwalk.runtime.extension.api.device_capabilities.DeviceCapabilitiesDisplay.java
public JSONObject convertDisplayToJSON(Display disp) { DisplayMetrics displayMetrics = new DisplayMetrics(); disp.getRealMetrics(displayMetrics); Point realSize = new Point(); disp.getRealSize(realSize);//from w w w.j av a 2s . c om Point availSize = new Point(); disp.getSize(availSize); JSONObject out = new JSONObject(); try { out.put("id", disp.getDisplayId()); out.put("name", disp.getName()); out.put("isPrimary", disp.getDisplayId() == disp.DEFAULT_DISPLAY); out.put("isInternal", disp.getDisplayId() == disp.DEFAULT_DISPLAY); out.put("dpiX", (int) displayMetrics.xdpi); out.put("dpiY", (int) displayMetrics.ydpi); out.put("width", realSize.x); out.put("height", realSize.y); out.put("availWidth", availSize.x); out.put("availHeight", availSize.y); } catch (JSONException e) { return mDeviceCapabilities.setErrorMessage(e.toString()); } return out; }
From source file:org.xwalk.runtime.extension.api.device_capabilities.DeviceCapabilitiesDisplay.java
private void notifyAndSaveConnectedDisplay(Display disp) { if (disp == null) { return;/* w ww . ja v a 2s.c o m*/ } JSONObject out = new JSONObject(); try { out.put("reply", "connectDisplay"); out.put("eventName", "displayconnect"); out.put("data", convertDisplayToJSON(disp)); mDeviceCapabilities.broadcastMessage(out.toString()); mDisplayList.put(disp.getDisplayId(), disp); } catch (JSONException e) { mDeviceCapabilities.printErrorMessage(e); } }
From source file:com.quectel.presentationtest.PresentationTest.java
/** * Hides a {@link Presentation} on the specified display. *///from w w w. j a v a 2 s .c o m private void hidePresentation(Display display) { final int displayId = display.getDisplayId(); DemoPresentation presentation = mActivePresentations.get(displayId); if (presentation == null) { return; } Log.d(TAG, "Dismissing presentation on display #" + displayId + "."); presentation.dismiss(); mActivePresentations.delete(displayId); }
From source file:com.quectel.presentationtest.PresentationTest.java
/** * Sets the display mode of the {@link Presentation} on the specified display * if it is already shown.//from w w w .j av a2 s . com */ private void setPresentationDisplayMode(Display display, int displayModeId) { final int displayId = display.getDisplayId(); DemoPresentation presentation = mActivePresentations.get(displayId); if (presentation == null) { return; } presentation.setPreferredDisplayMode(displayModeId); }