Skip to content

Commit

Permalink
Hide / show toggle view only it is not the same view as the textview.
Browse files Browse the repository at this point in the history
  • Loading branch information
bffcorreia committed May 11, 2017
1 parent 7fa7390 commit fa3de93
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions fole/src/main/java/io/github/bffcorreia/fole/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ private void addListener(final TextViewStateHandler textViewStateHandler) {
@SuppressWarnings("deprecation") @Override public void onGlobalLayout() {
if (textViewStateHandler.isTextExpanded()) {
fole.textView.setText(textViewStateHandler.ellipsizedText());
toggleView.setVisibility(View.VISIBLE);
isTextViewExpanded = false;
addActionInfoIfCallbackIsSet(false);
} else {
toggleView.setVisibility(View.GONE);
isTextViewExpanded = true;
}

showOrHideToggleViewIfNeeded();

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
fole.textView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
Expand All @@ -131,4 +131,13 @@ private void addListener(final TextViewStateHandler textViewStateHandler) {
}
});
}

private void showOrHideToggleViewIfNeeded() {
if (toggleView == fole.textView) return;
if (isTextViewExpanded) {
toggleView.setVisibility(View.GONE);
} else {
toggleView.setVisibility(View.VISIBLE);
}
}
}

0 comments on commit fa3de93

Please # to comment.