Skip to content

Commit e892a92

Browse files
committed
Closes #36
1 parent f0a85ea commit e892a92

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

lib/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
22
apply plugin: 'com.github.dcendents.android-maven'
33
apply plugin: 'com.jfrog.bintray'
44

5-
def version = 'RC1-9.2.0'
5+
def version = 'EXPERIMENTAL-3'
66

77
install {
88
repositories.mavenInstaller {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ abstract class MaterialScrollBar<T> extends RelativeLayout {
7171
Handle handle;
7272
int handleColour;
7373
int handleOffColour = Color.parseColor("#9c9c9c");
74-
private boolean hidden = true;
74+
protected boolean hidden = true;
7575
RecyclerView recyclerView;
7676
Indicator indicator;
7777
private int textColour = ContextCompat.getColor(getContext(), android.R.color.white);
@@ -338,6 +338,11 @@ private void useCustomScrolling(){
338338
scrollUtils.customScroller = (ICustomScroller) recyclerView.getAdapter();
339339
}
340340

341+
/**
342+
* The scrollBar should attempt to use dev provided scrolling logic and not default logic.
343+
*
344+
* The adapter must implement {@link ICustomScroller}.
345+
*/
341346
public T shouldUseCustomScrolling(){
342347
customScroll = true;
343348
return (T)this;

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class TouchScrollBar extends MaterialScrollBar<TouchScrollBar>{
3232
private boolean hide = true;
3333
private int hideDuration = 2500;
3434
private Handler uiHandler = new Handler(Looper.getMainLooper());
35+
private boolean respondToTouch = true;
3536

3637
private Runnable fadeBar = new Runnable() {
3738

@@ -67,12 +68,15 @@ public boolean onTouch(View v, MotionEvent event) {
6768
//On Down
6869
if (event.getAction() != MotionEvent.ACTION_UP) {
6970

70-
onDown(event);
71+
if(!hidden || respondToTouch){
72+
onDown(event);
7173

72-
if(hide){
73-
uiHandler.removeCallbacks(fadeBar);
74-
fadeIn();
74+
if(hide){
75+
uiHandler.removeCallbacks(fadeBar);
76+
fadeIn();
77+
}
7578
}
79+
7680
//On Up
7781
} else {
7882

@@ -139,8 +143,10 @@ float getIndicatorOffset(){
139143
* Provides the ability to programmatically alter whether the scrollbar
140144
* should hide after a period of inactivity or not.
141145
* @param hide sets whether the bar should hide or not.
146+
*
147+
* This method is experimental
142148
*/
143-
public MaterialScrollBar setAutoHide(Boolean hide){
149+
public TouchScrollBar setAutoHide(Boolean hide){
144150
if(!hide){
145151
TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
146152
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
@@ -153,4 +159,12 @@ public MaterialScrollBar setAutoHide(Boolean hide){
153159
this.hide = hide;
154160
return this;
155161
}
162+
163+
/**
164+
* @param respondToTouchIfHidden Should the bar pop out and scroll if it is hidden?
165+
*/
166+
public TouchScrollBar setRespondToTouchIfHidden(boolean respondToTouchIfHidden){
167+
respondToTouch = respondToTouchIfHidden;
168+
return this;
169+
}
156170
}

0 commit comments

Comments
 (0)