Merge pull request #358 from Rainer-Lang/state_layout

use boolean to show reload instead of int
This commit is contained in:
kosh 2017-04-24 02:07:56 +08:00 committed by GitHub
commit 121ab47da0

View File

@ -37,7 +37,7 @@ public class StateLayout extends NestedScrollView {
@State int layoutState = HIDDEN;
@State String emptyTextValue;
@State int adapterSize;
@State boolean showReload;
@OnClick(R.id.reload) void onReload() {
if (onReloadListener != null && !progressBar.isShown()) {
@ -81,9 +81,13 @@ public class StateLayout extends NestedScrollView {
}
public void showReload(int adapterCount) {
this.adapterSize = adapterCount;
showReload = adapterCount == 0;
showReload();
}
protected void showReload() {
hideProgress();
if (adapterCount == 0) {
if (showReload) {
layoutState = SHOW_RELOAD_STATE;
reload.setVisibility(VISIBLE);
emptyText.setVisibility(VISIBLE);
@ -157,7 +161,7 @@ public class StateLayout extends NestedScrollView {
hideReload();
break;
case SHOW_RELOAD_STATE:
showReload(adapterSize);
showReload();
break;
case HIDDEN:
setVisibility(GONE);
@ -167,7 +171,7 @@ public class StateLayout extends NestedScrollView {
break;
case SHOWN:
setVisibility(VISIBLE);
showReload(adapterSize);
showReload();
break;
}
}