Skip to content

Commit

Permalink
Merge pull request lsjwzh#162 from dilix/master
Browse files Browse the repository at this point in the history
Fir issue when onpage changed was not fired
  • Loading branch information
lsjwzh authored May 19, 2017
2 parents f426828 + b1abe93 commit f7dd9c9
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 28 deletions.
17 changes: 10 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ repositories {
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 25
buildToolsVersion "25.0.3"

defaultConfig {
applicationId "com.lsjwzh.widget.recyclerviewpagerdeomo"
minSdkVersion 11
targetSdkVersion 22
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
Expand All @@ -33,9 +33,12 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':lib')
compile project(':tablayoutsupport')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:support-v13:25.3.1'

compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:2.3.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 27 11:07:47 IDT 2016
#Fri Apr 28 13:11:28 MSK 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
12 changes: 7 additions & 5 deletions lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 7
targetSdkVersion 23
minSdkVersion 9
targetSdkVersion 25
versionCode 27
versionName "1.0.12"
}
Expand All @@ -25,5 +25,7 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,21 @@ protected void onTargetFound(View targetView, RecyclerView.State state, Action a
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return mMillisecondsPerInch / displayMetrics.densityDpi;
}

@Override
protected void onStop() {
super.onStop();
if (mOnPageChangedListeners != null) {
for (OnPageChangedListener onPageChangedListener : mOnPageChangedListeners) {
if (onPageChangedListener != null) {
onPageChangedListener.OnPageChanged(mPositionBeforeScroll, mSmoothScrollTargetPosition);
}
}
}
mHasCalledOnPageChanged = true;
}
};

linearSmoothScroller.setTargetPosition(position);
if (position == RecyclerView.NO_POSITION) {
return;
Expand Down Expand Up @@ -535,14 +549,6 @@ public void onScrollStateChanged(int state) {
if (DEBUG) {
Log.d("@", "onPageChanged:" + mSmoothScrollTargetPosition);
}
if (mOnPageChangedListeners != null) {
for (OnPageChangedListener onPageChangedListener : mOnPageChangedListeners) {
if (onPageChangedListener != null) {
onPageChangedListener.OnPageChanged(mPositionBeforeScroll, mSmoothScrollTargetPosition);
}
}
}
mHasCalledOnPageChanged = true;
mPositionBeforeScroll = mSmoothScrollTargetPosition;
}
// reset
Expand Down Expand Up @@ -582,6 +588,11 @@ private int safeTargetPosition(int position, int count) {
}

public interface OnPageChangedListener {
/**
* Fires when viewpager changes it's page
* @param oldPosition old position
* @param newPosition new position
*/
void OnPageChanged(int oldPosition, int newPosition);
}

Expand Down
10 changes: 5 additions & 5 deletions tablayoutsupport/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 25
buildToolsVersion "25.0.3"

defaultConfig {
minSdkVersion 7
targetSdkVersion 23
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
Expand All @@ -19,6 +19,6 @@ android {
}

dependencies {
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:design:25.3.1'
compile project(':lib')
}

0 comments on commit f7dd9c9

Please sign in to comment.