Skip to content

Commit 2facd23

Browse files
Fixed small glitch when finishing the intro really fast
1 parent 5aebbcc commit 2facd23

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

library/src/main/java/com/heinrichreimersoftware/materialintro/app/IntroActivity.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,14 @@ private boolean canGoBackward(int position, boolean notifyListeners) {
366366
return canGoBackward;
367367
}
368368

369-
private void finishIfNeeded() {
369+
private boolean finishIfNeeded() {
370370
if (positionOffset == 0 && position == adapter.getCount()) {
371371
setResult(RESULT_OK);
372372
finish();
373373
overridePendingTransition(0, 0);
374+
return true;
374375
}
376+
return false;
375377
}
376378

377379
private Pair<CharSequence, ? extends View.OnClickListener> getButtonCta(int position) {
@@ -1089,6 +1091,9 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
10891091
IntroActivity.this.position = (int) Math.floor(position + positionOffset);
10901092
IntroActivity.this.positionOffset = (((position + positionOffset) % 1) + 1) % 1;
10911093

1094+
if (finishIfNeeded())
1095+
return;
1096+
10921097
//Lock while scrolling a slide near its edges to lock (uncommon) multiple page swipes
10931098
if (Math.abs(positionOffset) < 0.1f) {
10941099
lockSwipeIfNeeded();
@@ -1099,8 +1104,6 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
10991104
if (position != getCount())
11001105
updateParallax();
11011106
updateFullscreen();
1102-
1103-
finishIfNeeded();
11041107
}
11051108

11061109
@Override

0 commit comments

Comments
 (0)