Skip to content

Commit 1c7ef88

Browse files
committed
Version 12.1.0
- Adds back programmatic option. Please note that unlike versions 11 and earlier, no automatic formatting is done.
1 parent 1bf273b commit 1c7ef88

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

lib/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apply plugin: 'com.android.library'
22

3-
def libVersion = '12.0.2'
3+
def libVersion = '12.1.0'
44

55
android {
66
compileSdkVersion 25

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.content.Context;
2020
import android.content.res.TypedArray;
2121
import android.support.v4.view.ViewCompat;
22+
import android.support.v7.widget.RecyclerView;
2223
import android.util.AttributeSet;
2324
import android.view.MotionEvent;
2425
import android.view.View;
@@ -37,6 +38,10 @@ public DragScrollBar(Context context, AttributeSet attributeSet){
3738
super(context, attributeSet);
3839
}
3940

41+
public DragScrollBar(Context context, RecyclerView recyclerView){
42+
super(context, recyclerView);
43+
}
44+
4045
boolean held = false;
4146

4247
public DragScrollBar setDraggableFromAnywhere(boolean draggableFromAnywhere){

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ abstract class MaterialScrollBar<T> extends RelativeLayout {
9191

9292
//CHAPTER I - INITIAL SETUP
9393

94+
//Programmatic constructor
95+
MaterialScrollBar(Context context, RecyclerView recyclerView){
96+
super(context);
97+
98+
this.recyclerView = recyclerView;
99+
100+
addView(setUpHandleTrack(context)); //Adds the handle track
101+
addView(setUpHandle(context, false)); //Adds the handle
102+
103+
setRightToLeft(Utils.isRightToLeft(context)); //Detects and applies the Right-To-Left status of the app
104+
105+
generalSetup();
106+
}
107+
94108
//Style-less XML Constructor
95109
MaterialScrollBar(Context context, AttributeSet attributeSet){
96110
this(context, attributeSet, 0);
@@ -227,15 +241,17 @@ private void generalSetup(){
227241
void identifySwipeRefreshParents(){
228242
boolean cycle = true;
229243
ViewParent parent = getParent();
230-
while(cycle){
231-
if(parent instanceof SwipeRefreshLayout){
232-
swipeRefreshLayout = (SwipeRefreshLayout)parent;
233-
cycle = false;
234-
} else {
235-
if(parent.getParent() == null){
244+
if(parent != null){
245+
while(cycle){
246+
if(parent instanceof SwipeRefreshLayout){
247+
swipeRefreshLayout = (SwipeRefreshLayout)parent;
236248
cycle = false;
237249
} else {
238-
parent = parent.getParent();
250+
if(parent.getParent() == null){
251+
cycle = false;
252+
} else {
253+
parent = parent.getParent();
254+
}
239255
}
240256
}
241257
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import android.content.res.TypedArray;
2121
import android.os.Handler;
2222
import android.os.Looper;
23+
import android.support.v7.widget.RecyclerView;
2324
import android.util.AttributeSet;
2425
import android.view.MotionEvent;
2526
import android.view.View;
@@ -49,6 +50,10 @@ public TouchScrollBar(Context context, AttributeSet attributeSet, int defStyle){
4950
super(context, attributeSet, defStyle);
5051
}
5152

53+
public TouchScrollBar(Context context, RecyclerView recyclerView){
54+
super(context, recyclerView);
55+
}
56+
5257
public TouchScrollBar setHideDuration(int duration){
5358
hideDuration = duration;
5459
return this;

0 commit comments

Comments
 (0)