Skip to content

Commit 9d1ab3c

Browse files
committed
support no child view
1 parent 584011d commit 9d1ab3c

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#MultiStateLayout
22
[![](https://jitpack.io/v/andyxialm/MultiStateLayout.svg)](https://jitpack.io/#andyxialm/MultiStateLayout)
3-
<a href="http://www.methodscount.com/?lib=com.github.andyxialm%3AMultiStateLayout%3A0.0.1"><img src="https://img.shields.io/badge/Methods count-core: 60 | deps: 32-e91e63.svg"/></a>
3+
<a href="http://www.methodscount.com/?lib=com.github.andyxialm%3AMultiStateLayout%3A0.0.2"><img src="https://img.shields.io/badge/Methods count-core: 60 | deps: 32-e91e63.svg"/></a>
44

55
A customize multiple state layout for Android.
66

@@ -21,7 +21,7 @@ allprojects {
2121
##### Step 2. Add the dependency
2222
~~~ xml
2323
dependencies {
24-
compile 'com.github.andyxialm:MultiStateLayout:0.0.1'
24+
compile 'com.github.andyxialm:MultiStateLayout:0.0.2'
2525
}
2626
~~~
2727

@@ -41,7 +41,7 @@ dependencies {
4141
<dependency>
4242
<groupId>com.github.andyxialm</groupId>
4343
<artifactId>MultiStateLayout</artifactId>
44-
<version>0.0.1</version>
44+
<version>0.0.2</version>
4545
</dependency>
4646
~~~
4747

multistatelayout/src/main/java/cn/refactor/multistatelayout/MultiStateLayout.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ protected void onFinishInflate() {
9898

9999
if (getChildCount() > 1) {
100100
throw new IllegalStateException("Expect to have one child.");
101+
} else if (getChildCount() == 1) {
102+
mContentView = getChildAt(CONTENT);
103+
} else {
104+
mContentView = null;
101105
}
102-
mContentView = getChildAt(CONTENT);
103106
}
104107

105108
/**
@@ -351,7 +354,9 @@ private void showViewByState(@State int state) {
351354
* show content view
352355
*/
353356
private void showContentView() {
354-
mContentView.setVisibility(VISIBLE);
357+
if (null != mContentView) {
358+
mContentView.setVisibility(VISIBLE);
359+
}
355360
}
356361

357362
/**

0 commit comments

Comments
 (0)