diff --git a/CHANGELOG.md b/CHANGELOG.md index be42719b..3a77a43b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +# 1.0.3 + +Fixed bug with `NullPointerException` ([see](https://github.com/pchmn/MaterialChipsInput/issues/3) issue) + # 1.0.2 Fixed bug with avatar icon when creating `ChipView` programmatically ([see](https://github.com/pchmn/MaterialChipsInput/issues/2) issue) diff --git a/README.md b/README.md index 10a7c5c9..01bdbda4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Implementation of Material Design [Chips](https://material.io/guidelines/compone Demo ## Demo -[Download sample-v1.0.2.apk](https://github.com/pchmn/MaterialChipsInput/raw/master/docs/material-chips-input-sample-v1.0.2.apk) +[Download sample-v1.0.3.apk](https://github.com/pchmn/MaterialChipsInput/raw/master/docs/material-chips-input-sample-v1.0.3.apk) ## Setup @@ -26,7 +26,7 @@ allprojects { In your app level build.gradle : ```java dependencies { - compile 'com.github.pchmn:MaterialChipsInput:1.0.2' + compile 'com.github.pchmn:MaterialChipsInput:1.0.3' } ```

diff --git a/docs/material-chips-input-sample-v1.0.3.apk b/docs/material-chips-input-sample-v1.0.3.apk new file mode 100644 index 00000000..42c97805 Binary files /dev/null and b/docs/material-chips-input-sample-v1.0.3.apk differ diff --git a/library/build.gradle b/library/build.gradle index 3f5d3941..4c19464b 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -9,7 +9,7 @@ android { minSdkVersion 15 targetSdkVersion 25 versionCode 3 - versionName "1.0.2" + versionName "1.0.3" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/library/src/main/java/com/pchmn/materialchips/util/LetterTileProvider.java b/library/src/main/java/com/pchmn/materialchips/util/LetterTileProvider.java index 3d0c736d..416c3950 100644 --- a/library/src/main/java/com/pchmn/materialchips/util/LetterTileProvider.java +++ b/library/src/main/java/com/pchmn/materialchips/util/LetterTileProvider.java @@ -80,10 +80,11 @@ public LetterTileProvider(Context context) { * default image is shown instead */ public Bitmap getLetterTile(String displayName) { - if(displayName.length() == 0) + if(displayName == null || displayName.length() == 0) return null; final Bitmap bitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ARGB_8888); + final char firstChar = displayName.charAt(0); final Canvas c = mCanvas; @@ -96,7 +97,8 @@ public Bitmap getLetterTile(String displayName) { mPaint.getTextBounds(mFirstChar, 0, 1, mBounds); c.drawText(mFirstChar, 0, 1, mWidth / 2, mHeight / 2 + (mBounds.bottom - mBounds.top) / 2, mPaint); - } else { + } + else { // (32 - 24) / 2 = 4 c.drawBitmap(mDefaultBitmap, ViewUtil.dpToPx(4), ViewUtil.dpToPx(4), null); } @@ -110,6 +112,9 @@ public Bitmap getLetterTile(String displayName) { * default image is shown instead */ public Bitmap getCircularLetterTile(String displayName) { + if(displayName == null || displayName.length() == 0) + return null; + final Bitmap bitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ARGB_8888); final char firstChar = displayName.charAt(0); diff --git a/sample/build.gradle b/sample/build.gradle index 01dde3f4..93a87bb5 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -9,8 +9,8 @@ android { applicationId "com.pchmn.sample.materialchipsinput" minSdkVersion 15 targetSdkVersion 25 - versionCode 3 - versionName "1.0.2" + versionCode 4 + versionName "1.0.3" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes {