Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates and fixes #111

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ android:
components:
- tools
- platform-tools
- build-tools-28.0.3
- android-28
- build-tools-29.0.3
- android-29
- extra-android-support
- extra-android-m2repository
- extra-google-m2repository
Expand All @@ -14,11 +14,11 @@ android:
script:
- ./gradlew build connectedCheck
before_install:
- yes | sdkmanager "platforms;android-28"
- yes | sdkmanager "platforms;android-29"
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
- echo y | android update sdk --no-ui --all --filter build-tools-28.0.3
- echo y | android update sdk --no-ui --all --filter build-tools-29.0.3
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.3.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
8 changes: 6 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
#Fri Feb 08 13:50:42 AEDT 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2-all.zip
#Tue Mar 17 10:21:34 COT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
2 changes: 1 addition & 1 deletion recyclerview-fastscroll/bintray.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#

group = com.simplecityapps
version = 2.0.1
version = 2.0.2

repo = maven
pkgName = recyclerview-fastscroll
Expand Down
4 changes: 2 additions & 2 deletions recyclerview-fastscroll/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
minSdkVersion 14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,16 @@ public Rect updateFastScrollerBounds(FastScrollRecyclerView recyclerView, int th
mBgBounds.right = recyclerView.getWidth() - (2 * recyclerView.getScrollBarWidth());
mBgBounds.left = mBgBounds.right - bgWidth;
}
mBgBounds.top = recyclerView.getPaddingTop() - recyclerView.getPaddingBottom() + thumbOffsetY - bgHeight + recyclerView.getScrollBarThumbHeight() / 2;
mBgBounds.top = Math.max(recyclerView.getPaddingTop() + edgePadding, Math.min(mBgBounds.top, recyclerView.getPaddingTop() + recyclerView.getHeight() - edgePadding - bgHeight));
if (mRecyclerView.getClipToPadding()) {
mBgBounds.top = recyclerView.getPaddingTop() - recyclerView.getPaddingBottom() +
thumbOffsetY - bgHeight + recyclerView.getScrollBarThumbHeight() / 2;
mBgBounds.top = Math.max(recyclerView.getPaddingTop() + edgePadding,
Math.min(mBgBounds.top, recyclerView.getPaddingTop() +
recyclerView.getHeight() - edgePadding - bgHeight));
} else {
mBgBounds.top = thumbOffsetY - bgHeight + recyclerView.getScrollBarThumbHeight() / 2;
mBgBounds.top = Math.max(edgePadding, Math.min(mBgBounds.top, recyclerView.getHeight() - edgePadding - bgHeight));
}
}
mBgBounds.bottom = mBgBounds.top + bgHeight;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public void onTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent ev) {
* it is already showing).
*/
private boolean handleTouchEvent(MotionEvent ev) {
if (!mFastScrollEnabled) return false;
int action = ev.getAction();
int x = (int) ev.getX();
int y = (int) ev.getY();
Expand Down Expand Up @@ -176,7 +177,8 @@ public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
*/
protected int getAvailableScrollHeight(int adapterHeight, int yOffset) {
int visibleHeight = getHeight();
int scrollHeight = getPaddingTop() + yOffset + adapterHeight + getPaddingBottom();
int scrollHeight = yOffset + adapterHeight;
if (getClipToPadding()) scrollHeight += getPaddingTop() + getPaddingBottom();
return scrollHeight - visibleHeight;
}

Expand Down Expand Up @@ -238,9 +240,9 @@ protected void updateThumbPosition(ScrollPositionState scrollPosState, int rowCo
}
int scrollBarY = (int) (((float) scrollY / availableScrollHeight) * availableScrollBarHeight);
if (isLayoutManagerReversed()) {
scrollBarY = availableScrollBarHeight - scrollBarY + getPaddingBottom();
scrollBarY = availableScrollBarHeight - scrollBarY + (getClipToPadding() ? getPaddingBottom() : 0);
} else {
scrollBarY += getPaddingTop();
scrollBarY += (getClipToPadding() ? getPaddingTop() : 0);
}

// Calculate the position and size of the scroll bar
Expand Down Expand Up @@ -295,8 +297,9 @@ public String scrollToPositionAtProgress(float touchFraction) {
//The offset used here is kind of hard to explain.
//If the position we wish to scroll to is, say, position 10.5, we scroll to position 10,
//and then offset by 0.5 * rowHeight. This is how we achieve smooth scrolling.
scrollPosition = spanCount * exactItemPos / mScrollPosState.rowHeight;
scrollOffset = -(exactItemPos % mScrollPosState.rowHeight);
int rowHeight = mScrollPosState.rowHeight > 0 ? mScrollPosState.rowHeight : 1;
scrollPosition = spanCount * exactItemPos / rowHeight;
scrollOffset = -(exactItemPos % rowHeight);
}

LinearLayoutManager layoutManager = ((LinearLayoutManager) getLayoutManager());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,14 @@ public void draw(Canvas canvas) {
return;
}

int rvPaddingTop = mRecyclerView.getClipToPadding() ? mRecyclerView.getPaddingTop() : 0;
int rvPaddingBottom = mRecyclerView.getClipToPadding() ? mRecyclerView.getPaddingBottom() : 0;

//Background
rect.set(mThumbPosition.x + mOffset.x + (mThumbWidth - mTrackWidth),
mOffset.y + mRecyclerView.getPaddingTop(),
mOffset.y + rvPaddingTop,
mThumbPosition.x + mOffset.x + mTrackWidth + (mThumbWidth - mTrackWidth),
mRecyclerView.getHeight() + mOffset.y - mRecyclerView.getPaddingBottom());
mRecyclerView.getHeight() + mOffset.y - rvPaddingBottom);
canvas.drawRoundRect(rect,
mTrackWidth,
mTrackWidth,
Expand Down
6 changes: 3 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileSdkVersion 29
buildToolsVersion '29.0.3'

defaultConfig {
applicationId "com.simplecityapps.recyclerview_fastscroll.sample"
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
Expand Down