Skip to content

Commit

Permalink
fix set null crash bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fingdo committed Mar 31, 2017
1 parent 358c763 commit e79b4da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ compile 'com.github.fingdo:stateLayout:1.0.1'
```

### 代码提前设置图标和文字
#### 如果你设置了一个`null`数据的时候,将使用上一次设置的提示语。空字符串可以正常显示为空,即只显示一个提示图片。
``` java
//type为StateLayout的固定Type变量
public static final int ERROR = 1;
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Dependently
- one step
add to your project `build.gradle`
add to your project `build.gradle`

``` base
allprojects {
Expand All @@ -17,7 +17,7 @@ allprojects {
}
}
```
```
- second step

``` base
Expand Down Expand Up @@ -90,6 +90,7 @@ Usage is consistent with `ScrollView`, allowing only one root layout
```

### Code set icon and text (show before)
#### if you set `null`,will use last time tip text.set "" can show,only show tip image.
``` java
//StateLayout Constants Type
public static final int ERROR = 1;
Expand Down
4 changes: 4 additions & 0 deletions library/src/main/java/com/fingdo/statelayout/StateLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -492,6 +493,9 @@ public void showCustomView(View view) {
* @param text 文字
*/
public void setTipText(int type, String text) {
if (text == null) { //text is null
return;
}
switch (type) {
case ERROR:
((ErrorViewHolder) errorView.getTag()).tvTip.setText(text);
Expand Down

0 comments on commit e79b4da

Please sign in to comment.