Skip to content

Commit a0da7e2

Browse files
committed
Version 8.0.0 - Enables use of the bars in XML in addition to previous options whose implementations remain unchanged.
1 parent 07b7b58 commit a0da7e2

File tree

16 files changed

+332
-58
lines changed

16 files changed

+332
-58
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class DateActivity extends AppCompatActivity {
1616
@Override
1717
protected void onCreate(Bundle savedInstanceState) {
1818
super.onCreate(savedInstanceState);
19-
setContentView(R.layout.activity_main);
19+
setContentView(R.layout.activity_others);
2020
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
2121
recyclerView.setAdapter(new DemoAdapter(this));
2222
recyclerView.setLayoutManager(new LinearLayoutManager(this));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class IconActivity extends AppCompatActivity {
3131
@Override
3232
protected void onCreate(Bundle savedInstanceState) {
3333
super.onCreate(savedInstanceState);
34-
setContentView(R.layout.activity_main);
34+
setContentView(R.layout.activity_others);
3535

3636
RecyclerView recyclerView = ((RecyclerView)findViewById(R.id.recyclerView));
3737
recyclerView.setAdapter(new IconAdapter(this));

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import android.support.v7.app.AppCompatActivity;
66
import android.support.v7.widget.LinearLayoutManager;
77
import android.support.v7.widget.RecyclerView;
8-
import android.util.TypedValue;
98
import android.view.Menu;
109
import android.view.MenuItem;
1110

@@ -22,7 +21,7 @@ protected void onCreate(Bundle savedInstanceState) {
2221
RecyclerView recyclerView = ((RecyclerView)findViewById(R.id.recyclerView));
2322
recyclerView.setAdapter(new DemoAdapter(this));
2423
recyclerView.setLayoutManager(new LinearLayoutManager(this));
25-
new DragScrollBar(this, recyclerView, false).setHandleColour(obtainStyledAttributes(new TypedValue().data, new int[] { R.attr.colorAccent }).getColor(0,0)).addIndicator(new AlphabetIndicator(this), true);
24+
((DragScrollBar)findViewById(R.id.dragScrollBar)).addIndicator(new AlphabetIndicator(this), true);
2625
}
2726

2827
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class NameActivity extends AppCompatActivity {
1616
@Override
1717
protected void onCreate(Bundle savedInstanceState) {
1818
super.onCreate(savedInstanceState);
19-
setContentView(R.layout.activity_main);
19+
setContentView(R.layout.activity_others);
2020
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
2121
recyclerView.setAdapter(new DemoAdapter(this));
2222
recyclerView.setLayoutManager(new LinearLayoutManager(this));
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
3-
android:layout_height="match_parent" tools:context=".MainActivity">
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
xmlns:app="http://schemas.android.com/apk/res-auto"
6+
tools:context=".MainActivity">
47

58
<android.support.v7.widget.RecyclerView
69
android:id="@+id/recyclerView"
710
android:layout_width="match_parent"
811
android:layout_height="match_parent" />
912

13+
<com.turingtechnologies.materialscrollbar.DragScrollBar
14+
android:id="@+id/dragScrollBar"
15+
android:layout_width="wrap_content"
16+
app:recyclerView="@id/recyclerView"
17+
app:lightOnTouch="false"
18+
android:layout_height="match_parent"
19+
android:layout_alignParentTop="true"
20+
android:layout_alignParentRight="true"
21+
android:layout_alignParentEnd="false" />
22+
1023
</RelativeLayout>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--
2+
~ Copyright © 2016, Turing Technologies, an unincorporated organisation of Wynne Plaga
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:tools="http://schemas.android.com/tools"
19+
android:layout_width="match_parent"
20+
android:layout_height="match_parent"
21+
xmlns:app="http://schemas.android.com/apk/res-auto"
22+
tools:context=".MainActivity">
23+
24+
<android.support.v7.widget.RecyclerView
25+
android:id="@+id/recyclerView"
26+
android:layout_width="match_parent"
27+
android:layout_height="match_parent" />
28+
29+
</RelativeLayout>

lib/build.gradle

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

3-
def version = '7.2.0'
3+
def version = '8.0.0'
44

55
ext {
66
bintrayRepo = 'maven'
@@ -35,7 +35,7 @@ android {
3535
defaultConfig {
3636
minSdkVersion 7
3737
targetSdkVersion 23
38-
versionCode 17
38+
versionCode 18
3939
versionName version
4040
}
4141
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int getIndicatorWidth() {
4949
@Override
5050
void testAdapter(RecyclerView.Adapter adapter) {
5151
if(!(adapter instanceof INameableAdapter)){
52-
throw new adapterNotSetupForIndicatorException("INameableAdapter");
52+
throw new CustomExceptions.AdapterNotSetupForIndicatorException("INameableAdapter");
5353
}
5454
}
5555

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,32 @@
1616

1717
package com.turingtechnologies.materialscrollbar;
1818

19-
class adapterNotSetupForIndicatorException extends RuntimeException{
19+
import java.util.ArrayList;
2020

21-
adapterNotSetupForIndicatorException(String shouldExtend) {
21+
class CustomExceptions {
22+
23+
static class AdapterNotSetupForIndicatorException extends RuntimeException {
24+
25+
AdapterNotSetupForIndicatorException(String shouldExtend){
2226
super("In order to add this indicator, the adapter for your recyclerView MUST implement " + shouldExtend + ".");
2327
}
2428

29+
}
30+
31+
static class MissingAttributesException extends RuntimeException {
32+
33+
MissingAttributesException(ArrayList<String> missing){
34+
super("You are missing the following required attributes from a scroll bar in your XML: " + missing);
35+
}
36+
37+
}
38+
39+
static class UnsupportedParentException extends RuntimeException {
40+
41+
UnsupportedParentException(){
42+
super("The recyclerView which is associated with a programmatically added scroll bar must be the child of a relative layout.");
43+
}
44+
45+
}
46+
2547
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int getIndicatorWidth() {
6363
@Override
6464
void testAdapter(RecyclerView.Adapter adapter) {
6565
if(!(adapter instanceof ICustomAdapter)){
66-
throw new adapterNotSetupForIndicatorException("ICustomAdapter");
66+
throw new CustomExceptions.AdapterNotSetupForIndicatorException("ICustomAdapter");
6767
}
6868
}
6969

0 commit comments

Comments
 (0)