diff --git a/README.md b/README.md index 824e6d9..7d1d1b9 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,13 @@ A custom LayoutManager to build a Gallery or a ViewPager like RecyclerView that #### Gradle ```java -compile 'github.hellocsl:GalleryLayoutManager:{lastest-version}' +compile 'github.hellocsl:GalleryLayoutManager:{lastest-release-version}' ``` > Be care :if you have used `RecyclerView` in your project , maybe your should use this library as below and your recyclerview-v7 requires API level 24.2.0 or higher ```java -compile ('github.hellocsl:GalleryLayoutManager:1.0.4'){ +compile ('github.hellocsl:GalleryLayoutManager:{lastest-release-version}'){ exclude group: 'com.android.support', module:'recyclerview-v7' } ``` diff --git a/README_CN.md b/README_CN.md index 388ebb2..641bdea 100644 --- a/README_CN.md +++ b/README_CN.md @@ -17,13 +17,13 @@ #### Gradle ```java -compile 'github.hellocsl:GalleryLayoutManager:{lastest-version}' +compile 'github.hellocsl:GalleryLayoutManager:{lastest-release-version}' ``` > 注意:如果你的项目已经引用了 `RecyclerView` ,那么应该这样引用,而且你的 `RecyclerView` 的引用版本必须大于 24.2.0 ```java -compile ('github.hellocsl:GalleryLayoutManager:1.0.4'){ +compile ('github.hellocsl:GalleryLayoutManager:{lastest-release-version}'){ exclude group: 'com.android.support', module:'recyclerview-v7' } ``` diff --git a/library/build.gradle b/library/build.gradle index e36799e..646e97e 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -34,7 +34,7 @@ publish { userOrg = 'bcsl' groupId = 'github.hellocsl' artifactId = 'GalleryLayoutManager' - publishVersion = '1.0.5' + publishVersion = '1.0.6' desc = 'A custom LayoutManager to build a Gallery or a ViewPager like widget with RecycleView in Android and ' + 'support both HORIZONTAL and VERTICAL scroll.' website = 'https://github.com/BCsl/GalleryLayoutManager' diff --git a/library/src/main/java/github/hellocsl/layoutmanager/gallery/GalleryLayoutManager.java b/library/src/main/java/github/hellocsl/layoutmanager/gallery/GalleryLayoutManager.java index 7df23b1..0e5c0dd 100644 --- a/library/src/main/java/github/hellocsl/layoutmanager/gallery/GalleryLayoutManager.java +++ b/library/src/main/java/github/hellocsl/layoutmanager/gallery/GalleryLayoutManager.java @@ -136,11 +136,11 @@ private void reset() { if (mState != null) { mState.mItemsFrames.clear(); } + //when data set update keep the last selected position if (mCurSelectedPosition != -1) { mInitialSelectedPosition = mCurSelectedPosition; - } else { - mInitialSelectedPosition = 0; } + mInitialSelectedPosition = Math.min(Math.max(0, mInitialSelectedPosition), getItemCount() - 1); mFirstVisiblePosition = mInitialSelectedPosition; mLastVisiblePos = mInitialSelectedPosition; mCurSelectedPosition = -1;