mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
VirtualDisplay size constraint - add a comment explaining the reason (#8780)
* VirtualDisplay size: add a comment explaining the reason Address nits in: https://github.com/flutter/engine/pull/8704 * remove locale import
This commit is contained in:
parent
ee3f04ac80
commit
5aa5b6cbf4
@ -24,7 +24,6 @@ import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -416,15 +415,16 @@ public class PlatformViewsController implements MethodChannel.MethodCallHandler,
|
||||
return coords;
|
||||
}
|
||||
|
||||
// Creating a VirtualDisplay larger than the size of the device screen size
|
||||
// could cause the device to restart: https://github.com/flutter/flutter/issues/28978
|
||||
private void validateVirtualDisplayDimensions(int width, int height) {
|
||||
DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
|
||||
if (height > metrics.heightPixels || width > metrics.widthPixels) {
|
||||
StringBuilder errorBuilder = new StringBuilder();
|
||||
errorBuilder.append("Creating a virtual display of size: ");
|
||||
errorBuilder.append(String.format(Locale.ENGLISH, "[%d, %d], ", width, height));
|
||||
errorBuilder.append(" is not supported. It is larger than the device screen size: ");
|
||||
errorBuilder.append(String.format(Locale.ENGLISH, "[%d, %d].", metrics.widthPixels, metrics.heightPixels));
|
||||
throw new IllegalArgumentException(errorBuilder.toString());
|
||||
String error = "Creating a virtual display of size: "
|
||||
+ "[" + width + ", " + height + "]"
|
||||
+ " is not supported. It is larger than the device screen size: "
|
||||
+ "[" + metrics.widthPixels + ", " + metrics.heightPixels + "].";
|
||||
throw new IllegalArgumentException(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user