Created
August 29, 2013 22:26
-
-
Save iriina/6384158 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void checkEmpty() { | |
final Adapter adapter = getAdapter(); | |
if (getEmptyView() != null) { | |
updateEmptyStatus((adapter == null) || adapter.isEmpty()); | |
} | |
} | |
@SuppressLint("WrongCall") | |
private void updateEmptyStatus(boolean empty) { | |
if (empty) { | |
if (getEmptyView() != null) { | |
getEmptyView().setVisibility(View.VISIBLE); | |
setVisibility(View.GONE); | |
} else { | |
// If the caller just removed our empty view, make sure the list | |
// view is visible | |
setVisibility(View.VISIBLE); | |
} | |
// We are now GONE, so pending layouts will not be dispatched. | |
// Force one here to make sure that the state of the list matches | |
// the state of the adapter. | |
// if (mDataChanged) { | |
onLayout(false, getLeft(), getTop(), getRight(), getBottom()); | |
// } | |
} else { | |
if (getEmptyView() != null) | |
getEmptyView().setVisibility(View.GONE); | |
setVisibility(View.VISIBLE); | |
} | |
} | |
private void onDataChanged() { | |
adapterDataCount = adapter.getCount(); | |
int activeIndex; | |
if (adapterIndex < 0) | |
activeIndex = 0; | |
else | |
activeIndex = Math.min(adapterIndex, adapterDataCount - 1); | |
releaseViews(); | |
if (adapterDataCount > 0) | |
setSelection(activeIndex); | |
checkEmpty(); | |
refreshAllPages(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i apply your method but it is not working same it is throw exception junit.framework.AssertionFailedError: Invalid indexInAdapter: 2.