Skip to content

Commit 1faeaa9

Browse files
committed
Version 11.2.0
- Adds support for RTL languages. Detected automatically but can be overriden by the developer if needed. (Fixes #70) - Marked programmatic addition as depreciated in order to simplify library and removed documentation. Will be removed shortly.
1 parent e322794 commit 1faeaa9

File tree

17 files changed

+189
-75
lines changed

17 files changed

+189
-75
lines changed

README.md

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ Note: All customisation methods (`setAutoHide`, `setBarColour`, etc) return the
3737

3838
####How to use - ScrollBar
3939

40-
The 'scrollBar' can be implemented programatically or through XML.
41-
42-
#####XML
40+
The library comes in two flavours, drag and touch. Try both out to see which you prefer.
4341

4442
Option 1
4543

@@ -72,29 +70,12 @@ Additonal optional attributes:
7270
* msb_handleOffColour - Colour
7371
* msb_textColour - Colour
7472
* msb_barThickness - Integer
73+
* msb_rightToLeft - Integer
7574

7675
Please note that for both of these configurations, both recyclerView and lightOnTouch* must have a valid value. The recyclerView attribute should point to the id of the `recyclerView` to which you want to link the scrollbar.
7776

7877
\* lightOnTouch behaves as follows. A value of true will cause the handle to be grey until pressed, when it will become the normal accent colour (as set). A value of false will cause the handle to always have the accent colour, even when not being pressed.
7978

80-
#####Programmatically
81-
82-
Option 1
83-
84-
```java
85-
DragScrollBar materialScrollBar = new DragScrollBar(this, recyclerView, {{lightOnTouch}});
86-
```
87-
88-
or
89-
90-
Option 2
91-
92-
```java
93-
TouchScrollBar materialScrollBar = new TouchScrollBar(this, recyclerView, {{lightOnTouch}});
94-
```
95-
96-
where "recyclerView" is the object of the `recyclerView` to which you want to link the `scrollBar`. The difference between the two options is that the touch option hides after a cooldown period and touches anywhere on the track, whether on the button or not, scroll the view. The drag option on the other hand hides using the animation seen in the video and will only respond to touches on the handle. "lightOnTouch" can either be true or false. A value of true will cause the handle to be grey until pressed, when it will become the normal accent colour (as set). A value of false will cause the handle to always have the accent colour, even when not being pressed.
97-
9879
####My recyclerView elements aren't all the same size! What do I do?
9980

10081
If you are in the situation of using headers of one size and elements of another, we've developed a solution speicifcally for you. Please follow the tutorial [here](https://github.com/krimin-killr21/MaterialScrollBar/wiki/Header-Tutorial).
@@ -104,16 +85,14 @@ If you are in the situation of using headers of one size and elements of another
10485
To add an indicator, simply add the following line of code:
10586

10687
```java
107-
materialScrollBar.setIndicator({{Indicator}}, {{addSpace}});
88+
scrollBar.setIndicator({{Indicator}}, {{addSpace}});
10889
```
10990

110-
If you implemented the bar programmatically, simply get the object using `findViewById()` and then the scrollbar's id.
111-
11291
The indicator should be either `AlphatbetIndicator`, `DateAndTimeIndicator`, or `CustomIndicator`. See below for specific instructions per indicator.
11392

11493
`{{addSpace}}` is a boolean which indicates whether there should be space in between the indicator and the bar. True adds space, as in the latest version of the Google Launcher, while false adds no space, as in the Android 5.1 system scrollbars.
11594

116-
To use an indicator, you **MUST** make your 'recyclerView''s adapter implement the relevant interface. If you do not, the library will throw a runtime error informing you of your mistake. See documentation for the relevant interface.
95+
To use an indicator, you **MUST** make your `recyclerView`'s adapter implement the relevant interface. If you do not, the library will throw a runtime error informing you of your mistake. See documentation for the relevant interface.
11796

11897
####Indicators
11998
#####AlphabetIndicator

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<application
66
android:allowBackup="true"
7+
android:supportsRtl="true"
78
android:icon="@mipmap/ic_launcher"
89
android:label="@string/app_name"
910
android:theme="@style/AppTheme" >

app/src/main/java/com/turingtechnologies/materialscrollbardemo/DateActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected void onCreate(Bundle savedInstanceState) {
2020
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
2121
recyclerView.setAdapter(new DemoAdapter(this));
2222
recyclerView.setLayoutManager(new LinearLayoutManager(this));
23-
new TouchScrollBar(this, recyclerView, false).setIndicator(new DateAndTimeIndicator(this, false, true, true, true), true);
23+
((TouchScrollBar) findViewById(R.id.touchScrollBar)).setIndicator(new DateAndTimeIndicator(this, false, true, true, true), true);
2424
}
2525

2626
@Override

app/src/main/java/com/turingtechnologies/materialscrollbardemo/IconActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected void onCreate(Bundle savedInstanceState) {
3737
RecyclerView recyclerView = ((RecyclerView)findViewById(R.id.recyclerView));
3838
recyclerView.setAdapter(new IconAdapter(this));
3939
recyclerView.setLayoutManager(new GridLayoutManager(this, 4));
40-
new TouchScrollBar(this, recyclerView, true).setIndicator(new CustomIndicator(this), true);
40+
((TouchScrollBar) findViewById(R.id.touchScrollBar)).setIndicator(new CustomIndicator(this), true);
4141
}
4242

4343
@Override

app/src/main/java/com/turingtechnologies/materialscrollbardemo/NameActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected void onCreate(Bundle savedInstanceState) {
2020
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
2121
recyclerView.setAdapter(new DemoAdapter(this));
2222
recyclerView.setLayoutManager(new LinearLayoutManager(this));
23-
new TouchScrollBar(this, recyclerView, false).setIndicator(new CustomIndicator(this), true);
23+
((TouchScrollBar) findViewById(R.id.touchScrollBar)).setIndicator(new CustomIndicator(this), true);
2424
}
2525

2626
@Override

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
android:layout_height="match_parent"
1919
android:layout_alignParentTop="true"
2020
android:layout_alignParentRight="true"
21-
android:layout_alignParentEnd="false" />
21+
android:layout_alignParentEnd="true" />
2222

2323
</RelativeLayout>

app/src/main/res/layout/activity_others.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,21 @@
1818
xmlns:tools="http://schemas.android.com/tools"
1919
android:layout_width="match_parent"
2020
android:layout_height="match_parent"
21+
xmlns:app="http://schemas.android.com/apk/res-auto"
2122
tools:context=".MainActivity">
2223

2324
<android.support.v7.widget.RecyclerView
2425
android:id="@+id/recyclerView"
2526
android:layout_width="match_parent"
2627
android:layout_height="match_parent" />
2728

29+
<com.turingtechnologies.materialscrollbar.TouchScrollBar
30+
app:msb_lightOnTouch="false"
31+
app:msb_recyclerView="@id/recyclerView"
32+
android:layout_alignParentRight="true"
33+
android:layout_alignParentEnd="true"
34+
android:id="@+id/touchScrollBar"
35+
android:layout_width="wrap_content"
36+
android:layout_height="match_parent"/>
37+
2838
</RelativeLayout>

app/src/main/res/layout/item_layout.xml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,25 @@
77
android:layout_height="56dp"
88
android:focusableInTouchMode="false">
99

10-
<ImageView
11-
android:layout_width="35dp"
12-
android:layout_height="35dp"
13-
android:layout_marginTop="10.5dp"
14-
android:id="@+id/imageView"
15-
android:layout_marginLeft="16dp" />
10+
<ImageView
11+
android:layout_width="35dp"
12+
android:layout_height="35dp"
13+
android:layout_marginTop="10.5dp"
14+
android:id="@+id/imageView"
15+
android:layout_marginStart="16dp"
16+
android:layout_marginLeft="16dp" />
1617

17-
<TextView
18-
android:layout_width="wrap_content"
19-
android:layout_height="wrap_content"
20-
android:textSize="16sp"
21-
android:text="Medium Text"
22-
android:id="@+id/textView"
23-
android:textColor="#212121"
24-
android:layout_marginLeft="72dp"
25-
android:layout_centerVertical="true" />
18+
<TextView
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:textSize="16sp"
22+
android:text="Medium Text"
23+
android:id="@+id/textView"
24+
android:textColor="#212121"
25+
android:layout_toRightOf="@id/imageView"
26+
android:layout_toEndOf="@id/imageView"
27+
android:layout_marginLeft="16dp"
28+
android:layout_marginStart="16dp"
29+
android:layout_centerVertical="true" />
2630

2731
</RelativeLayout>

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 = '11.1.0'
3+
def libVersion = '11.2.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
@@ -30,6 +30,11 @@ public class DragScrollBar extends MaterialScrollBar<DragScrollBar>{
3030
float handleOffset = 0;
3131
float indicatorOffset = 0;
3232

33+
/**
34+
* @deprecated Insert via XML instead. Will be removed in future version to be published in the
35+
* month of December, 2016.
36+
*/
37+
@Deprecated
3338
public DragScrollBar(Context context, RecyclerView recyclerView, boolean lightOnTouch){
3439
super(context, recyclerView, lightOnTouch);
3540
}

0 commit comments

Comments
 (0)