Java源码示例:org.chromium.chrome.browser.compositor.layouts.phone.stack.Stack

示例1
/**
 * @param context     The current Android's context.
 * @param updateHost  The {@link LayoutUpdateHost} view for this layout.
 * @param renderHost  The {@link LayoutRenderHost} view for this layout.
 * @param eventFilter The {@link EventFilter} that is needed for this view.
 */
public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost,
        EventFilter eventFilter) {
    super(context, updateHost, renderHost, eventFilter);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mMinDirectionThreshold = configuration.getScaledTouchSlop();
    mMinShortPressThresholdSqr =
            configuration.getScaledPagingTouchSlop() * configuration.getScaledPagingTouchSlop();

    mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5);
    mFlingSpeed = FLING_SPEED_DP;
    mStacks = new Stack[2];
    mStacks[0] = new Stack(context, this);
    mStacks[1] = new Stack(context, this);
    mStackRects = new RectF[2];
    mStackRects[0] = new RectF();
    mStackRects[1] = new RectF();

    mViewContainer = new FrameLayout(getContext());
    mSceneLayer = new TabListSceneLayer();
}
 
示例2
/**
 * @param context     The current Android's context.
 * @param updateHost  The {@link LayoutUpdateHost} view for this layout.
 * @param renderHost  The {@link LayoutRenderHost} view for this layout.
 * @param eventFilter The {@link EventFilter} that is needed for this view.
 */
public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost,
        EventFilter eventFilter) {
    super(context, updateHost, renderHost, eventFilter);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mMinDirectionThreshold = configuration.getScaledTouchSlop();
    mMinShortPressThresholdSqr =
            configuration.getScaledPagingTouchSlop() * configuration.getScaledPagingTouchSlop();

    mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5);
    mFlingSpeed = FLING_SPEED_DP;
    mStacks = new Stack[2];
    mStacks[0] = new Stack(context, this);
    mStacks[1] = new Stack(context, this);
    mStackRects = new RectF[2];
    mStackRects[0] = new RectF();
    mStackRects[1] = new RectF();

    mViewContainer = new FrameLayout(getContext());
    mSceneLayer = new TabListSceneLayer();
}
 
示例3
/**
 * @param context     The current Android's context.
 * @param updateHost  The {@link LayoutUpdateHost} view for this layout.
 * @param renderHost  The {@link LayoutRenderHost} view for this layout.
 * @param eventFilter The {@link EventFilter} that is needed for this view.
 */
public StackLayout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost) {
    super(context, updateHost, renderHost);

    mGestureHandler = new StackLayoutGestureHandler();
    mGestureEventFilter = new GestureEventFilter(context, mGestureHandler);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mMinDirectionThreshold = configuration.getScaledTouchSlop();
    mMinShortPressThresholdSqr =
            configuration.getScaledPagingTouchSlop() * configuration.getScaledPagingTouchSlop();

    mMinMaxInnerMargin = (int) (MIN_INNER_MARGIN_PERCENT_DP + 0.5);
    mFlingSpeed = FLING_SPEED_DP;
    mStacks = new Stack[2];
    mStacks[0] = new Stack(context, this);
    mStacks[1] = new Stack(context, this);
    mStackRects = new RectF[2];
    mStackRects[0] = new RectF();
    mStackRects[1] = new RectF();

    mViewContainer = new FrameLayout(getContext());
    mSceneLayer = new TabListSceneLayer();
}
 
示例4
/**
 * Updates the position, scale, rotation and alpha values of mAnimatedTab.
 *
 * @param discard The value that specify how far along are we in the discard animation. 0 is
 *                filling the screen. Valid values are [-range .. range] where range is
 *                computed by {@link SimpleAnimationLayout#getDiscardRange()}.
 */
private void setDiscardAmount(float discard) {
    if (mAnimatedTab != null) {
        final float range = getDiscardRange();
        final float scale = Stack.computeDiscardScale(discard, range, true);

        final float deltaX = mAnimatedTab.getOriginalContentWidth();
        final float deltaY = mAnimatedTab.getOriginalContentHeight() / 2.f;
        mAnimatedTab.setX(deltaX * (1.f - scale));
        mAnimatedTab.setY(deltaY * (1.f - scale));
        mAnimatedTab.setScale(scale);
        mAnimatedTab.setBorderScale(scale);
        mAnimatedTab.setAlpha(Stack.computeDiscardAlpha(discard, range));
    }
}
 
示例5
@Override
public void onTabClosing(long time, int id) {
    Stack stack = getTabStack(id);
    if (stack == null) return;
    stack.tabClosingEffect(time, id);

    // Just in case we closed the last tab of a stack we need to trigger the overlap animation.
    startMarginAnimation(true);

    // Animate the stack to leave incognito mode.
    if (!mStacks[1].isDisplayable()) uiPreemptivelySelectTabModel(false);
}
 
示例6
/**
 * Extracts the tabs from a stack and append them into a list.
 * @param stack     The stack that contains the tabs.
 * @param outList   The output list where will be the tabs from the stack.
 * @param index     The current number of item in the outList.
 * @return The updated index incremented by the number of tabs in the stack.
 */
private static int addAllTabs(Stack stack, StackTab[] outList, int index) {
    StackTab[] stackTabs = stack.getTabs();
    if (stackTabs != null) {
        for (int i = 0; i < stackTabs.length; ++i) {
            outList[index++] = stackTabs[i];
        }
    }
    return index;
}
 
示例7
/**
 * Updates the position, scale, rotation and alpha values of mAnimatedTab.
 *
 * @param discard The value that specify how far along are we in the discard animation. 0 is
 *                filling the screen. Valid values are [-range .. range] where range is
 *                computed by {@link SimpleAnimationLayout#getDiscardRange()}.
 */
private void setDiscardAmount(float discard) {
    if (mAnimatedTab != null) {
        final float range = getDiscardRange();
        final float scale = Stack.computeDiscardScale(discard, range, true);

        final float deltaX = mAnimatedTab.getOriginalContentWidth();
        final float deltaY = mAnimatedTab.getOriginalContentHeight() / 2.f;
        mAnimatedTab.setX(deltaX * (1.f - scale));
        mAnimatedTab.setY(deltaY * (1.f - scale));
        mAnimatedTab.setScale(scale);
        mAnimatedTab.setBorderScale(scale);
        mAnimatedTab.setAlpha(Stack.computeDiscardAlpha(discard, range));
    }
}
 
示例8
@Override
public void onTabClosing(long time, int id) {
    Stack stack = getTabStack(id);
    if (stack == null) return;
    stack.tabClosingEffect(time, id);

    // Just in case we closed the last tab of a stack we need to trigger the overlap animation.
    startMarginAnimation(true);

    // Animate the stack to leave incognito mode.
    if (!mStacks[1].isDisplayable()) uiPreemptivelySelectTabModel(false);
}
 
示例9
/**
 * Extracts the tabs from a stack and append them into a list.
 * @param stack     The stack that contains the tabs.
 * @param outList   The output list where will be the tabs from the stack.
 * @param index     The current number of item in the outList.
 * @return The updated index incremented by the number of tabs in the stack.
 */
private static int addAllTabs(Stack stack, StackTab[] outList, int index) {
    StackTab[] stackTabs = stack.getTabs();
    if (stackTabs != null) {
        for (int i = 0; i < stackTabs.length; ++i) {
            outList[index++] = stackTabs[i];
        }
    }
    return index;
}
 
示例10
/**
 * Updates the position, scale, rotation and alpha values of mAnimatedTab.
 *
 * @param discard The value that specify how far along are we in the discard animation. 0 is
 *                filling the screen. Valid values are [-range .. range] where range is
 *                computed by {@link SimpleAnimationLayout#getDiscardRange()}.
 */
private void setDiscardAmount(float discard) {
    if (mAnimatedTab != null) {
        final float range = getDiscardRange();
        final float scale = Stack.computeDiscardScale(discard, range, true);

        final float deltaX = mAnimatedTab.getOriginalContentWidth();
        final float deltaY = mAnimatedTab.getOriginalContentHeight() / 2.f;
        mAnimatedTab.setX(deltaX * (1.f - scale));
        mAnimatedTab.setY(deltaY * (1.f - scale));
        mAnimatedTab.setScale(scale);
        mAnimatedTab.setBorderScale(scale);
        mAnimatedTab.setAlpha(Stack.computeDiscardAlpha(discard, range));
    }
}
 
示例11
@Override
public void onTabClosing(long time, int id) {
    Stack stack = getTabStack(id);
    if (stack == null) return;
    stack.tabClosingEffect(time, id);

    // Just in case we closed the last tab of a stack we need to trigger the overlap animation.
    startMarginAnimation(true);

    // Animate the stack to leave incognito mode.
    if (!mStacks[1].isDisplayable()) uiPreemptivelySelectTabModel(false);
}
 
示例12
/**
 * Extracts the tabs from a stack and append them into a list.
 * @param stack     The stack that contains the tabs.
 * @param outList   The output list where will be the tabs from the stack.
 * @param index     The current number of item in the outList.
 * @return The updated index incremented by the number of tabs in the stack.
 */
private static int addAllTabs(Stack stack, StackTab[] outList, int index) {
    StackTab[] stackTabs = stack.getTabs();
    if (stackTabs != null) {
        for (int i = 0; i < stackTabs.length; ++i) {
            outList[index++] = stackTabs[i];
        }
    }
    return index;
}
 
示例13
/**
 * @return The range of the discard amount.
 */
private float getDiscardRange() {
    return Math.min(getWidth(), getHeight()) * Stack.DISCARD_RANGE_SCREEN;
}
 
示例14
/**
 * @return The range of the discard amount.
 */
private float getDiscardRange() {
    return Math.min(getWidth(), getHeight()) * Stack.DISCARD_RANGE_SCREEN;
}
 
示例15
/**
 * @return The range of the discard amount.
 */
private float getDiscardRange() {
    return Math.min(getWidth(), getHeight()) * Stack.DISCARD_RANGE_SCREEN;
}
 
示例16
/**
 * Get the tab stack state for the specified mode.
 *
 * @param incognito Whether the TabStackState to be returned should be the one for incognito.
 * @return The tab stack state for the given mode.
 * @VisibleForTesting
 */
public Stack getTabStack(boolean incognito) {
    return mStacks[incognito ? 1 : 0];
}
 
示例17
/**
 * Get the tab stack state for the specified tab id.
 *
 * @param tabId The id of the tab to lookup.
 * @return The tab stack state for the given tab id.
 * @VisibleForTesting
 */
protected Stack getTabStack(int tabId) {
    return mStacks[getTabStackIndex(tabId)];
}
 
示例18
/**
 * Get the tab stack state for the specified mode.
 *
 * @param incognito Whether the TabStackState to be returned should be the one for incognito.
 * @return The tab stack state for the given mode.
 * @VisibleForTesting
 */
public Stack getTabStack(boolean incognito) {
    return mStacks[incognito ? 1 : 0];
}
 
示例19
/**
 * Get the tab stack state for the specified tab id.
 *
 * @param tabId The id of the tab to lookup.
 * @return The tab stack state for the given tab id.
 * @VisibleForTesting
 */
protected Stack getTabStack(int tabId) {
    return mStacks[getTabStackIndex(tabId)];
}
 
示例20
/**
 * Get the tab stack state for the specified mode.
 *
 * @param incognito Whether the TabStackState to be returned should be the one for incognito.
 * @return The tab stack state for the given mode.
 * @VisibleForTesting
 */
public Stack getTabStack(boolean incognito) {
    return mStacks[incognito ? 1 : 0];
}
 
示例21
/**
 * Get the tab stack state for the specified tab id.
 *
 * @param tabId The id of the tab to lookup.
 * @return The tab stack state for the given tab id.
 * @VisibleForTesting
 */
protected Stack getTabStack(int tabId) {
    return mStacks[getTabStackIndex(tabId)];
}