Commit 90930b84 authored by Ryan Landay's avatar Ryan Landay Committed by Commit Bot

Change StackLayout#flingStacks() to take an int

StackLayout#flingStacks() currently takes a boolean: true if we should scroll over to the incognito
tab stack, and false if we should scroll over to the normal tab stack.

This CL is a straightforward change to make this method instead take an integer value representing
the index of the new tab stack. This is necessary to enable StackLayout to support more than two
tab stacks.

Bug: 648314
Change-Id: I4e58707c1e389638fca1c6a013abf022a8d248bc
Reviewed-on: https://chromium-review.googlesource.com/957425Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Ryan Landay <rlanday@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542234}
parent 98a3bb30
......@@ -232,7 +232,9 @@ public class StackLayout extends Layout implements Animatable<StackLayout.Proper
if (stackIndexDeltaAt == 0) {
mStacks.get(getTabStackIndex()).click(time(), x, y);
} else {
flingStacks(getTabStackIndex() == 0);
final int newStackIndex = getTabStackIndex() + stackIndexDeltaAt;
if (newStackIndex < 0 || newStackIndex >= mStacks.size()) return;
flingStacks(newStackIndex);
}
requestStackUpdate();
}
......@@ -569,7 +571,7 @@ public class StackLayout extends Layout implements Animatable<StackLayout.Proper
@Override
public void onTabModelSwitched(boolean toIncognitoTabModel) {
flingStacks(toIncognitoTabModel);
flingStacks(toIncognitoTabModel ? INCOGNITO_STACK_INDEX : NORMAL_STACK_INDEX);
mFlingFromModelChange = true;
}
......@@ -751,7 +753,7 @@ public class StackLayout extends Layout implements Animatable<StackLayout.Proper
}
startMarginAnimation(true);
startYOffsetAnimation(true);
flingStacks(getTabStackIndex() == 1);
flingStacks(getTabStackIndex());
if (!animate) onUpdateAnimation(time, true);
......@@ -1072,9 +1074,14 @@ public class StackLayout extends Layout implements Animatable<StackLayout.Proper
requestStackUpdate();
}
private void flingStacks(boolean toIncognito) {
/**
* Scrolls over to the tab stack at the specified index, and records that it's now the current
* tab stack.
* @param index The index of the newly-selected tab stack.
*/
private void flingStacks(int index) {
// velocityX is measured in pixel per second.
setActiveStackState(toIncognito);
setActiveStackState(index == INCOGNITO_STACK_INDEX);
finishScrollStacks();
requestStackUpdate();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment