Skip to content

Commit 2d7492e

Browse files
committed
fixed bugs
1 parent 067e8e1 commit 2d7492e

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,27 @@ public class IndexFastScrollRecyclerSection extends RecyclerView.AdapterDataObse
6262
private int indexPaintPaintColor = Color.WHITE;
6363
AttributeSet attrs;
6464

65-
public IndexFastScrollRecyclerSection(Context context, IndexFastScrollRecyclerView rv) {
65+
public IndexFastScrollRecyclerSection(Context context, IndexFastScrollRecyclerView recyclerView) {
6666

67-
setIndexTextSize = rv.setIndexTextSize;
68-
setIndexbarWidth = rv.mIndexbarWidth;
69-
setIndexbarMargin = rv.mIndexbarMargin;
70-
setPreviewPadding = rv.mPreviewPadding;
71-
setPreviewTextSize = rv.mPreviewTextSize;
72-
previewBackgroundColor = rv.mPreviewBackgroudColor;
73-
previewTextColor = rv.mPreviewTextColor;
74-
previewBackgroudAlpha = convertTransparentValueToBackgroundAlpha(rv.mPreviewTransparentValue);
67+
setIndexTextSize = recyclerView.setIndexTextSize;
68+
setIndexbarWidth = recyclerView.mIndexbarWidth;
69+
setIndexbarMargin = recyclerView.mIndexbarMargin;
70+
setPreviewPadding = recyclerView.mPreviewPadding;
71+
setPreviewTextSize = recyclerView.mPreviewTextSize;
72+
previewBackgroundColor = recyclerView.mPreviewBackgroudColor;
73+
previewTextColor = recyclerView.mPreviewTextColor;
74+
previewBackgroudAlpha = convertTransparentValueToBackgroundAlpha(recyclerView.mPreviewTransparentValue);
7575

76-
setIndexBarCornerRadius = rv.mIndexBarCornerRadius;
77-
indexbarBackgroudColor = rv.mIndexbarBackgroudColor;
78-
indexbarTextColor = rv.mIndexbarTextColor;
79-
indexbarHighLightTextColor = rv.indexbarHighLightTextColor;
76+
setIndexBarCornerRadius = recyclerView.mIndexBarCornerRadius;
77+
indexbarBackgroudColor = recyclerView.mIndexbarBackgroudColor;
78+
indexbarTextColor = recyclerView.mIndexbarTextColor;
79+
indexbarHighLightTextColor = recyclerView.indexbarHighLightTextColor;
8080

81-
indexbarBackgroudAlpha = convertTransparentValueToBackgroundAlpha(rv.mIndexBarTransparentValue);
81+
indexbarBackgroudAlpha = convertTransparentValueToBackgroundAlpha(recyclerView.mIndexBarTransparentValue);
8282

8383
mDensity = context.getResources().getDisplayMetrics().density;
8484
mScaledDensity = context.getResources().getDisplayMetrics().scaledDensity;
85-
mRecyclerView = rv;
85+
mRecyclerView = recyclerView;
8686
setAdapter(mRecyclerView.getAdapter());
8787

8888
mIndexbarWidth = setIndexbarWidth * mDensity;
@@ -164,7 +164,6 @@ public void draw(Canvas canvas) {
164164
}
165165
}
166166
}
167-
168167
}
169168

170169
public boolean onTouchEvent(MotionEvent ev) {

app/src/main/java/in/myinnos/indexfastscrollrecycler/MainActivity.java

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

55
import java.util.ArrayList;
66
import java.util.List;
7+
import java.util.Objects;
78

89
import androidx.appcompat.app.AppCompatActivity;
910
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -83,5 +84,7 @@ protected void initialiseUI() {
8384
mRecyclerView.setIndexBarVisibility(true);
8485
mRecyclerView.setIndexbarHighlightTextColor("#33334c");
8586
mRecyclerView.setIndexBarHighLateTextVisibility(true);
87+
88+
Objects.requireNonNull(mRecyclerView.getLayoutManager()).scrollToPosition(0);
8689
}
8790
}

0 commit comments

Comments
 (0)