Skip to content

Commit 127bfcd

Browse files
committed
Version 12.0.1
- Closes #37 - Closes #59. Devs may now extend the class Indicator if they'd like.
1 parent 354e768 commit 127bfcd

File tree

5 files changed

+45
-19
lines changed

5 files changed

+45
-19
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.0'
3+
def libVersion = '12.0.1'
44

55
android {
66
compileSdkVersion 25

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,30 @@ public AlphabetIndicator (Context c){
3131
}
3232

3333
@Override
34-
String getTextElement(Integer currentSection, RecyclerView.Adapter adapter) {
34+
protected String getTextElement(Integer currentSection, RecyclerView.Adapter adapter) {
3535
Character provided = ((INameableAdapter) adapter).getCharacterForElement(currentSection);
3636
return String.valueOf(Character.toUpperCase(provided));
3737
}
3838

3939
@Override
40-
int getIndicatorHeight() {
40+
protected int getIndicatorHeight() {
4141
return 75;
4242
}
4343

4444
@Override
45-
int getIndicatorWidth() {
45+
protected int getIndicatorWidth() {
4646
return 75;
4747
}
4848

4949
@Override
50-
void testAdapter(RecyclerView.Adapter adapter) {
50+
protected void testAdapter(RecyclerView.Adapter adapter) {
5151
if(!(adapter instanceof INameableAdapter)){
5252
throw new CustomExceptions.AdapterNotSetupForIndicatorException(adapter.getClass(), "INameableAdapter");
5353
}
5454
}
5555

5656
@Override
57-
int getTextSize() {
57+
protected int getTextSize() {
5858
return 40;
5959
}
6060

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public CustomIndicator(Context context){
3434
}
3535

3636
@Override
37-
String getTextElement(Integer currentSection, RecyclerView.Adapter adapter) {
37+
protected String getTextElement(Integer currentSection, RecyclerView.Adapter adapter) {
3838
String text = ((ICustomAdapter)adapter).getCustomStringForElement(currentSection);
3939
LayoutParams layoutParams = (LayoutParams) getLayoutParams();
4040
if(layoutParams == null){
@@ -52,24 +52,24 @@ String getTextElement(Integer currentSection, RecyclerView.Adapter adapter) {
5252
}
5353

5454
@Override
55-
int getIndicatorHeight() {
55+
protected int getIndicatorHeight() {
5656
return 75;
5757
}
5858

5959
@Override
60-
int getIndicatorWidth() {
60+
protected int getIndicatorWidth() {
6161
return 0;
6262
}
6363

6464
@Override
65-
void testAdapter(RecyclerView.Adapter adapter) {
65+
protected void testAdapter(RecyclerView.Adapter adapter) {
6666
if(!(adapter instanceof ICustomAdapter)){
6767
throw new CustomExceptions.AdapterNotSetupForIndicatorException(adapter.getClass(), "ICustomAdapter");
6868
}
6969
}
7070

7171
@Override
72-
int getTextSize() {
72+
protected int getTextSize() {
7373
return textSize;
7474
}
7575

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static void initHeaderScroller(RecyclerView rv)
5959
// IHeaderAdapter - helper functions
6060
// --------------------
6161

62-
private static Integer getSpanSize(RecyclerView rv)
62+
public static Integer getSpanSize(RecyclerView rv)
6363
{
6464
final RecyclerView.LayoutManager lm = rv.getLayoutManager();
6565
if (lm != null && lm instanceof GridLayoutManager)

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

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
import android.widget.RelativeLayout;
2828
import android.widget.TextView;
2929

30-
abstract class Indicator extends RelativeLayout{
30+
/**
31+
* Devs should not normally need to extend this class. Just use {@link CustomIndicator} instead.
32+
* However, this is public to leave the option open.
33+
*/
34+
public abstract class Indicator extends RelativeLayout{
3135

3236
protected TextView textView;
3337
protected Context context;
@@ -43,7 +47,7 @@ public Indicator(Context context) {
4347
setVisibility(INVISIBLE);
4448
}
4549

46-
public void setSizeCustom(int size){
50+
void setSizeCustom(int size){
4751
if(addSpace){
4852
this.size = size + Utils.getDP(10, this);
4953
} else {
@@ -140,14 +144,36 @@ void setTextColour(int colour){
140144
textView.setTextColor(colour);
141145
}
142146

143-
abstract String getTextElement(Integer currentSection, RecyclerView.Adapter adapter);
147+
/**
148+
* @param currentSection The section that the indicator is indicating for.
149+
* @param adapter The adapter of the attached {@link RecyclerView}.
150+
* @return The text that should go in the indicator.
151+
*/
152+
protected abstract String getTextElement(Integer currentSection, RecyclerView.Adapter adapter);
144153

145-
abstract int getIndicatorHeight();
154+
/**
155+
* @return The height of the indicator in px. If it is variable return any value and resize
156+
* the view yourself.
157+
*/
158+
protected abstract int getIndicatorHeight();
146159

147-
abstract int getIndicatorWidth();
160+
/**
161+
* @return The width of the indicator in px. If it is variable return any value and resize
162+
* the view yourself.
163+
*/
164+
protected abstract int getIndicatorWidth();
148165

149-
abstract void testAdapter(RecyclerView.Adapter adapter);
166+
/**
167+
* This method should test the adapter to make sure that it implements the needed interface(s).
168+
* See {@link AlphabetIndicator#testAdapter(RecyclerView.Adapter)} for form.
169+
*
170+
* @param adapter The adapter of the attached {@link RecyclerView}.
171+
*/
172+
protected abstract void testAdapter(RecyclerView.Adapter adapter);
150173

151-
abstract int getTextSize();
174+
/**
175+
* @return The size of text in the indicator.
176+
*/
177+
protected abstract int getTextSize();
152178

153179
}

0 commit comments

Comments
 (0)