Skip to content

Commit

Permalink
Fixed small glitch when finishing the intro really fast
Browse files Browse the repository at this point in the history
  • Loading branch information
heinrichreimer committed Jun 23, 2016
1 parent 5aebbcc commit 2facd23
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,14 @@ private boolean canGoBackward(int position, boolean notifyListeners) {
return canGoBackward;
}

private void finishIfNeeded() {
private boolean finishIfNeeded() {
if (positionOffset == 0 && position == adapter.getCount()) {
setResult(RESULT_OK);
finish();
overridePendingTransition(0, 0);
return true;
}
return false;
}

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

if (finishIfNeeded())
return;

//Lock while scrolling a slide near its edges to lock (uncommon) multiple page swipes
if (Math.abs(positionOffset) < 0.1f) {
lockSwipeIfNeeded();
Expand All @@ -1099,8 +1104,6 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
if (position != getCount())
updateParallax();
updateFullscreen();

finishIfNeeded();
}

@Override
Expand Down

0 comments on commit 2facd23

Please sign in to comment.