use of android.view.Display in project glide by bumptech.
the class RecyclerAdapter method getScreenWidth.
// Display#getSize(Point)
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
@SuppressWarnings("deprecation")
private static int getScreenWidth(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
final int result;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
Point size = new Point();
display.getSize(size);
result = size.x;
} else {
result = display.getWidth();
}
return result;
}
use of android.view.Display in project cw-omnibus by commonsguy.
the class MainActivity method handleRoute.
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void handleRoute(RouteInfo route) {
if (route == null) {
clearPreso();
} 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();
showPreso(route);
Log.d(getClass().getSimpleName(), "switched route");
} else {
// no-op: should already be set
}
} else {
clearPreso();
Log.d(getClass().getSimpleName(), "disabled route");
}
}
}
use of android.view.Display in project android-app by eoecn.
the class CameraConfigurationManager method initFromCameraParameters.
/**
* Reads, one time, values from the camera that are needed by the app.
*/
void initFromCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
previewFormat = parameters.getPreviewFormat();
previewFormatString = parameters.get("preview-format");
Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString);
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
screenResolution = new Point(display.getWidth(), display.getHeight());
Log.d(TAG, "Screen resolution: " + screenResolution);
/** modify here **/
Point screenResolutionForCamera = new Point();
screenResolutionForCamera.x = screenResolution.x;
screenResolutionForCamera.y = screenResolution.y;
// preview size is always something like 480*320, other 320*480
if (screenResolution.x < screenResolution.y) {
screenResolutionForCamera.x = screenResolution.y;
screenResolutionForCamera.y = screenResolution.x;
}
/** end **/
cameraResolution = getCameraResolution(parameters, screenResolutionForCamera);
Log.d(TAG, "Camera resolution: " + screenResolutionForCamera);
/*
* cameraResolution = getCameraResolution(parameters, screenResolution);
* Log.d(TAG, "Camera resolution: " + screenResolution);
*/
/** end **/
}
use of android.view.Display in project android_frameworks_base by ParanoidAndroid.
the class UiAutomation method takeScreenshot.
/**
* Takes a screenshot.
*
* @return The screenshot bitmap on success, null otherwise.
*/
public Bitmap takeScreenshot() {
synchronized (mLock) {
throwIfNotConnectedLocked();
}
Display display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
Point displaySize = new Point();
display.getRealSize(displaySize);
final int displayWidth = displaySize.x;
final int displayHeight = displaySize.y;
final float screenshotWidth;
final float screenshotHeight;
final int rotation = display.getRotation();
switch(rotation) {
case ROTATION_FREEZE_0:
{
screenshotWidth = displayWidth;
screenshotHeight = displayHeight;
}
break;
case ROTATION_FREEZE_90:
{
screenshotWidth = displayHeight;
screenshotHeight = displayWidth;
}
break;
case ROTATION_FREEZE_180:
{
screenshotWidth = displayWidth;
screenshotHeight = displayHeight;
}
break;
case ROTATION_FREEZE_270:
{
screenshotWidth = displayHeight;
screenshotHeight = displayWidth;
}
break;
default:
{
throw new IllegalArgumentException("Invalid rotation: " + rotation);
}
}
// Take the screenshot
Bitmap screenShot = null;
try {
// Calling out without a lock held.
screenShot = mUiAutomationConnection.takeScreenshot((int) screenshotWidth, (int) screenshotHeight);
if (screenShot == null) {
return null;
}
} catch (RemoteException re) {
Log.e(LOG_TAG, "Error while taking screnshot!", re);
return null;
}
// Rotate the screenshot to the current orientation
if (rotation != ROTATION_FREEZE_0) {
Bitmap unrotatedScreenShot = Bitmap.createBitmap(displayWidth, displayHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(unrotatedScreenShot);
canvas.translate(unrotatedScreenShot.getWidth() / 2, unrotatedScreenShot.getHeight() / 2);
canvas.rotate(getDegreesForRotation(rotation));
canvas.translate(-screenshotWidth / 2, -screenshotHeight / 2);
canvas.drawBitmap(screenShot, 0, 0, null);
canvas.setBitmap(null);
screenShot = unrotatedScreenShot;
}
// Optimization
screenShot.setHasAlpha(false);
return screenShot;
}
use of android.view.Display in project android_frameworks_base by ParanoidAndroid.
the class BigCache method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
final LinearLayout testBed = new LinearLayout(this);
testBed.setOrientation(LinearLayout.VERTICAL);
testBed.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
final int cacheSize = ViewConfiguration.getMaximumDrawingCacheSize();
final Display display = getWindowManager().getDefaultDisplay();
final int screenWidth = display.getWidth();
final int screenHeight = display.getHeight();
final View tiny = new View(this);
tiny.setId(R.id.a);
tiny.setBackgroundColor(0xFFFF0000);
tiny.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenHeight));
final View large = new View(this);
large.setId(R.id.b);
large.setBackgroundColor(0xFF00FF00);
// Compute the height of the view assuming a cache size based on ARGB8888
final int height = 2 * (cacheSize / 2) / screenWidth;
large.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, height));
final ScrollView scroller = new ScrollView(this);
scroller.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
testBed.addView(tiny);
testBed.addView(large);
scroller.addView(testBed);
setContentView(scroller);
}
Aggregations