From 9903e86ae27c56603936e44d7677332739cc0db5 Mon Sep 17 00:00:00 2001 From: JessYan Date: Mon, 22 Oct 2018 14:17:29 +0800 Subject: [PATCH] Add AutoSizeConfig#setDesignWidthInDp(int) and AutoSizeConfig#setDesignHeightInDp(int) --- .../me/jessyan/autosize/AutoSizeConfig.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java b/autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java index 25ba707..828a0a3 100644 --- a/autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java +++ b/autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java @@ -449,6 +449,7 @@ public void setVertical(boolean vertical) { * @param screenWidth 屏幕宽度 */ public void setScreenWidth(int screenWidth) { + Preconditions.checkArgument(screenWidth > 0, "screenWidth must be > 0"); mScreenWidth = screenWidth; } @@ -458,9 +459,30 @@ public void setScreenWidth(int screenWidth) { * @param screenHeight 屏幕高度 (包含状态栏和导航栏) */ public void setScreenHeight(int screenHeight) { + Preconditions.checkArgument(screenHeight > 0, "screenHeight must be > 0"); mScreenHeight = screenHeight; } + /** + * 设置全局设计图宽度 + * + * @param designWidthInDp 设计图宽度 + */ + public void setDesignWidthInDp(int designWidthInDp) { + Preconditions.checkArgument(designWidthInDp > 0, "designWidthInDp must be > 0"); + mDesignWidthInDp = designWidthInDp; + } + + /** + * 设置全局设计图高度 + * + * @param designHeightInDp 设计图高度 + */ + public void setDesignHeightInDp(int designHeightInDp) { + Preconditions.checkArgument(designHeightInDp > 0, "designHeightInDp must be > 0"); + mDesignHeightInDp = designHeightInDp; + } + /** * 获取使用者在 AndroidManifest 中填写的 Meta 信息 *