Skip to content

Commit

Permalink
Fixed bug with NullPointerException
Browse files Browse the repository at this point in the history
  • Loading branch information
pchmn committed Apr 20, 2017
1 parent 1336e79 commit 6136d85
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Implementation of Material Design [Chips](https://material.io/guidelines/compone
<img src="https://github.com/pchmn/MaterialChipsInput/blob/master/docs/demo2.gif" alt="Demo" height="600px"/>

## 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

Expand All @@ -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'
}
```
<br><br>
Expand Down
Binary file added docs/material-chips-input-sample-v1.0.3.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6136d85

Please sign in to comment.