Skip to content

Commit

Permalink
Merge pull request #222 from plastiv/master
Browse files Browse the repository at this point in the history
added fastScrollAlwaysVisible attr
  • Loading branch information
emilsjolander committed Oct 25, 2013
2 parents 2e6633f + 7123150 commit 89905bd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions library/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<attr name="android:choiceMode" />
<attr name="android:drawSelectorOnTop" />
<attr name="android:fastScrollEnabled" />
<attr name="android:fastScrollAlwaysVisible" />
<attr name="android:listSelector" />
<attr name="android:scrollingCache" />
<attr name="android:scrollbarStyle" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ public StickyListHeadersListView(Context context, AttributeSet attrs,
.getBoolean(
R.styleable.StickyListHeadersListView_android_fastScrollEnabled,
mList.isFastScrollEnabled()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mList.setFastScrollAlwaysVisible(a
.getBoolean(
R.styleable.StickyListHeadersListView_android_fastScrollAlwaysVisible,
mList.isFastScrollAlwaysVisible()));
}
mList.setScrollBarStyle(a
.getInt(R.styleable.StickyListHeadersListView_android_scrollbarStyle,
0));
Expand Down Expand Up @@ -866,6 +872,30 @@ public void setFastScrollEnabled(boolean fastScrollEnabled) {
mList.setFastScrollEnabled(fastScrollEnabled);
}

/**
* @see android.widget.AbsListView#setFastScrollAlwaysVisible(boolean)
* @throws ApiLevelTooLowException on pre-Honeycomb device.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void setFastScrollAlwaysVisible(boolean alwaysVisible) {
requireSdkVersion(Build.VERSION_CODES.HONEYCOMB);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mList.setFastScrollAlwaysVisible(alwaysVisible);
}
}

/**
* @see android.widget.AbsListView#isFastScrollAlwaysVisible()
* @return true if the fast scroller will always show. False on pre-Honeycomb devices.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean isFastScrollAlwaysVisible(){
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
return false;
}
return mList.isFastScrollAlwaysVisible();
}

private void requireSdkVersion(int versionCode) {
if (Build.VERSION.SDK_INT < versionCode) {
throw new ApiLevelTooLowException(versionCode);
Expand Down

0 comments on commit 89905bd

Please sign in to comment.