Skip to content

Commit a605907

Browse files
authored
Update IndexFastScrollRecyclerView.java
typedArray is never null, fixed value not updating from XML
1 parent 2b9b4bd commit a605907

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

alphabetsindexfastscrollrecycler/src/main/java/in/myinnos/alphabetsindexfastscrollrecycler/IndexFastScrollRecyclerView.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,10 @@ public IndexFastScrollRecyclerView(Context context, AttributeSet attrs, int defS
6464

6565

6666
private void init(Context context, AttributeSet attrs) {
67-
mScroller = new IndexFastScrollRecyclerSection(context, this);
68-
67+
6968
if (attrs != null) {
70-
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.IndexFastScrollRecyclerView, 0, 0);
71-
72-
if (typedArray != null) {
69+
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.IndexFastScrollRecyclerView);
70+
7371
try {
7472
setIndexTextSize = typedArray.getInt(R.styleable.IndexFastScrollRecyclerView_setIndexTextSize, setIndexTextSize);
7573
mIndexbarWidth = typedArray.getFloat(R.styleable.IndexFastScrollRecyclerView_setIndexbarWidth, mIndexbarWidth);
@@ -124,7 +122,9 @@ private void init(Context context, AttributeSet attrs) {
124122
} finally {
125123
typedArray.recycle();
126124
}
127-
}
125+
126+
// This line here is neccesary else the attributes won't be updated if a value is passed from XML
127+
mScroller = new IndexFastScrollRecyclerSection(context, this);
128128
}
129129
}
130130

@@ -369,4 +369,4 @@ public void setIndexBarHighLightTextVisibility(boolean shown) {
369369
public void updateSections() {
370370
mScroller.updateSections();
371371
}
372-
}
372+
}

0 commit comments

Comments
 (0)