Skip to content

Commit 6e3cccf

Browse files
committed
[Feature] Allow using CharSequence for popup text.
Fixes: #52
1 parent 708c99e commit 6e3cccf

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

library/src/main/java/me/zhanghai/android/fastscroll/FastScroller.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private void onPreDraw() {
195195
layoutView(mThumbView, thumbLeft, thumbTop, thumbLeft + mThumbWidth,
196196
thumbTop + mThumbHeight);
197197

198-
String popupText = mViewHelper.getPopupText();
198+
CharSequence popupText = mViewHelper.getPopupText();
199199
boolean hasPopup = !TextUtils.isEmpty(popupText);
200200
mPopupView.setVisibility(hasPopup ? View.VISIBLE : View.INVISIBLE);
201201
if (hasPopup) {
@@ -443,7 +443,7 @@ public interface ViewHelper {
443443
void scrollTo(int offset);
444444

445445
@Nullable
446-
default String getPopupText() {
446+
default CharSequence getPopupText() {
447447
return null;
448448
}
449449
}

library/src/main/java/me/zhanghai/android/fastscroll/PopupTextProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
public interface PopupTextProvider {
2222

2323
@NonNull
24-
String getPopupText(int position);
24+
CharSequence getPopupText(int position);
2525
}

library/src/main/java/me/zhanghai/android/fastscroll/RecyclerViewHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void scrollTo(int offset) {
118118

119119
@Nullable
120120
@Override
121-
public String getPopupText() {
121+
public CharSequence getPopupText() {
122122
PopupTextProvider popupTextProvider = mPopupTextProvider;
123123
if (popupTextProvider == null) {
124124
RecyclerView.Adapter<?> adapter = mView.getAdapter();

sample/src/main/java/me/zhanghai/android/fastscroll/sample/LocaleListAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
8080

8181
@NonNull
8282
@Override
83-
public String getPopupText(int position) {
83+
public CharSequence getPopupText(int position) {
8484
Locale locale = getItem(position);
8585
return locale.toString().substring(0, 1).toUpperCase(Locale.getDefault());
8686
}

0 commit comments

Comments
 (0)