Skip to content

Commit 2b7c971

Browse files
committed
Fix issue where indicator would always appear. Closes #113.
1 parent 829b351 commit 2b7c971

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/src/main/java/com/turingtechnologies/materialscrollbar/MaterialScrollBar.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ public abstract class MaterialScrollBar<T> extends RelativeLayout {
7676
int handleOffColor = Color.parseColor("#9c9c9c");
7777
protected boolean hidden = true;
7878
private int textColor = ContextCompat.getColor(getContext(), android.R.color.white);
79-
boolean lightOnTouch;
79+
private boolean lightOnTouch;
8080
private TypedArray a; //XML attributes
8181
private Boolean rtl = false;
8282
boolean hiddenByUser = false;
83+
private boolean hiddenByNotEnoughElements = false;
8384
private float fastScrollSnapPercent = 0;
8485

8586
//Associated Objects
@@ -294,14 +295,12 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
294295

295296
if(!isInEditMode()) {
296297
scrollUtils.scrollHandleAndIndicator();
297-
if(scrollUtils.getAvailableScrollHeight() <= 0) {
298+
if(hiddenByNotEnoughElements = (scrollUtils.getAvailableScrollHeight() <= 0)) {
298299
handleTrack.setVisibility(GONE);
299300
handleThumb.setVisibility(GONE);
300-
if(indicator != null) indicator.setVisibility(GONE);
301301
} else {
302302
handleTrack.setVisibility(VISIBLE);
303303
handleThumb.setVisibility(VISIBLE);
304-
if(indicator != null) indicator.setVisibility(VISIBLE);
305304
}
306305
}
307306
}
@@ -718,7 +717,7 @@ void fadeIn() {
718717
}
719718

720719
protected void onDown(MotionEvent event) {
721-
if (indicator != null && indicator.getVisibility() == INVISIBLE && recyclerView.getAdapter() != null) {
720+
if (indicator != null && indicator.getVisibility() == INVISIBLE && recyclerView.getAdapter() != null && !hiddenByNotEnoughElements) {
722721
indicator.setVisibility(VISIBLE);
723722
indicator.setAlpha(0F);
724723
indicator.animate().alpha(1F).setDuration(150).setListener(new AnimatorListenerAdapter() {

0 commit comments

Comments
 (0)