diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2014-11-10 22:05:16 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-11-10 22:05:16 +0000 |
commit | a09dda8162ca48bea0fea0e2804af38e216996d8 (patch) | |
tree | 4d73d868fa0c090df6e2a7ebf0174491fabbe159 | |
parent | e6ef98cf0528cbc2722b979e5ad86ba859fa78b0 (diff) | |
parent | 0e3925dfb3ea4e9185202dd963f03f5ca1df17d0 (diff) | |
download | frameworks_base-a09dda8162ca48bea0fea0e2804af38e216996d8.zip frameworks_base-a09dda8162ca48bea0fea0e2804af38e216996d8.tar.gz frameworks_base-a09dda8162ca48bea0fea0e2804af38e216996d8.tar.bz2 |
am 0e3925df: Merge "Remove needlessly thrown IOException." into lmp-dev automerge: f305d2c
* commit '0e3925dfb3ea4e9185202dd963f03f5ca1df17d0':
Remove needlessly thrown IOException.
-rw-r--r-- | tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java | 7 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java | 86 |
2 files changed, 43 insertions, 50 deletions
diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java index f4282ad..8d24d38 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java @@ -141,7 +141,6 @@ public final class Bitmap_Delegate { * Creates and returns a {@link Bitmap} initialized with the given stream content. * * @param input the stream from which to read the bitmap content - * @param createFlags * @param density the density associated with the bitmap * * @see Bitmap#isPremultiplied() @@ -166,8 +165,7 @@ public final class Bitmap_Delegate { * @see Bitmap#isMutable() * @see Bitmap#getDensity() */ - public static Bitmap createBitmap(BufferedImage image, boolean isMutable, - Density density) throws IOException { + public static Bitmap createBitmap(BufferedImage image, boolean isMutable, Density density) { return createBitmap(image, getPremultipliedBitmapCreateFlags(isMutable), density); } @@ -175,7 +173,6 @@ public final class Bitmap_Delegate { * Creates and returns a {@link Bitmap} initialized with the given {@link BufferedImage} * * @param image the bitmap content - * @param createFlags * @param density the density associated with the bitmap * * @see Bitmap#isPremultiplied() @@ -183,7 +180,7 @@ public final class Bitmap_Delegate { * @see Bitmap#getDensity() */ public static Bitmap createBitmap(BufferedImage image, Set<BitmapCreateFlags> createFlags, - Density density) throws IOException { + Density density) { // create a delegate with the given image. Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.ARGB_8888); diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java index b677131..669e6b5 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java @@ -57,63 +57,59 @@ public class RenderDrawable extends RenderAction<DrawableParams> { public Result render() { checkLock(); - try { - // get the drawable resource value - DrawableParams params = getParams(); - HardwareConfig hardwareConfig = params.getHardwareConfig(); - ResourceValue drawableResource = params.getDrawable(); - - // resolve it - BridgeContext context = getContext(); - drawableResource = context.getRenderResources().resolveResValue(drawableResource); - - if (drawableResource == null || - drawableResource.getResourceType() != ResourceType.DRAWABLE) { - return Status.ERROR_NOT_A_DRAWABLE.createResult(); - } + // get the drawable resource value + DrawableParams params = getParams(); + HardwareConfig hardwareConfig = params.getHardwareConfig(); + ResourceValue drawableResource = params.getDrawable(); + + // resolve it + BridgeContext context = getContext(); + drawableResource = context.getRenderResources().resolveResValue(drawableResource); + + if (drawableResource == null || + drawableResource.getResourceType() != ResourceType.DRAWABLE) { + return Status.ERROR_NOT_A_DRAWABLE.createResult(); + } - // create a simple FrameLayout - FrameLayout content = new FrameLayout(context); + // create a simple FrameLayout + FrameLayout content = new FrameLayout(context); - // get the actual Drawable object to draw - Drawable d = ResourceHelper.getDrawable(drawableResource, context); - content.setBackground(d); + // get the actual Drawable object to draw + Drawable d = ResourceHelper.getDrawable(drawableResource, context); + content.setBackground(d); - // set the AttachInfo on the root view. - AttachInfo_Accessor.setAttachInfo(content); + // set the AttachInfo on the root view. + AttachInfo_Accessor.setAttachInfo(content); - // measure - int w = hardwareConfig.getScreenWidth(); - int h = hardwareConfig.getScreenHeight(); - int w_spec = MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY); - int h_spec = MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY); - content.measure(w_spec, h_spec); + // measure + int w = hardwareConfig.getScreenWidth(); + int h = hardwareConfig.getScreenHeight(); + int w_spec = MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY); + int h_spec = MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY); + content.measure(w_spec, h_spec); - // now do the layout. - content.layout(0, 0, w, h); + // now do the layout. + content.layout(0, 0, w, h); - // preDraw setup - AttachInfo_Accessor.dispatchOnPreDraw(content); + // preDraw setup + AttachInfo_Accessor.dispatchOnPreDraw(content); - // draw into a new image - BufferedImage image = getImage(w, h); + // draw into a new image + BufferedImage image = getImage(w, h); - // create an Android bitmap around the BufferedImage - Bitmap bitmap = Bitmap_Delegate.createBitmap(image, - true /*isMutable*/, hardwareConfig.getDensity()); + // create an Android bitmap around the BufferedImage + Bitmap bitmap = Bitmap_Delegate.createBitmap(image, + true /*isMutable*/, hardwareConfig.getDensity()); - // create a Canvas around the Android bitmap - Canvas canvas = new Canvas(bitmap); - canvas.setDensity(hardwareConfig.getDensity().getDpiValue()); + // create a Canvas around the Android bitmap + Canvas canvas = new Canvas(bitmap); + canvas.setDensity(hardwareConfig.getDensity().getDpiValue()); - // and draw - content.draw(canvas); + // and draw + content.draw(canvas); - return Status.SUCCESS.createResult(image); - } catch (IOException e) { - return ERROR_UNKNOWN.createResult(e.getMessage(), e); - } + return Status.SUCCESS.createResult(image); } protected BufferedImage getImage(int w, int h) { |