org.chromium.chrome.browser.compositor.layouts.phone.stack.StackTab Java Examples

The following examples show how to use org.chromium.chrome.browser.compositor.layouts.phone.stack.StackTab. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StackLayout.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the {@link LayoutTab} a few at a time. This function is to be called once a
 * frame.
 * The logic of that function is not as trivial as it should be because the input array we want
 * to initialize the tab from keeps getting reordered from calls to call. This is needed to
 * get the highest priority tab initialized first.
 *
 * @param sortedPriorityArray The array of all the {@link StackTab} sorted by priority.
 */
private void updateDelayedLayoutTabInit(StackTab[] sortedPriorityArray) {
    if (!mDelayedLayoutTabInitRequired) return;

    int initialized = 0;
    final int count = sortedPriorityArray.length;
    for (int i = 0; i < count; i++) {
        if (initialized >= LAYOUTTAB_ASYNCHRONOUS_INITIALIZATION_BATCH_SIZE) return;

        LayoutTab layoutTab = sortedPriorityArray[i].getLayoutTab();
        // The actual initialization is done by the parent class.
        if (super.initLayoutTabFromHost(layoutTab)) {
            initialized++;
        }
    }
    if (initialized == 0) mDelayedLayoutTabInitRequired = false;
}
 
Example #2
Source File: StackLayout.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the {@link LayoutTab} a few at a time. This function is to be called once a
 * frame.
 * The logic of that function is not as trivial as it should be because the input array we want
 * to initialize the tab from keeps getting reordered from calls to call. This is needed to
 * get the highest priority tab initialized first.
 *
 * @param sortedPriorityArray The array of all the {@link StackTab} sorted by priority.
 */
private void updateDelayedLayoutTabInit(StackTab[] sortedPriorityArray) {
    if (!mDelayedLayoutTabInitRequired) return;

    int initialized = 0;
    final int count = sortedPriorityArray.length;
    for (int i = 0; i < count; i++) {
        if (initialized >= LAYOUTTAB_ASYNCHRONOUS_INITIALIZATION_BATCH_SIZE) return;

        LayoutTab layoutTab = sortedPriorityArray[i].getLayoutTab();
        // The actual initialization is done by the parent class.
        if (super.initLayoutTabFromHost(layoutTab)) {
            initialized++;
        }
    }
    if (initialized == 0) mDelayedLayoutTabInitRequired = false;
}
 
Example #3
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the {@link LayoutTab} a few at a time. This function is to be called once a
 * frame.
 * The logic of that function is not as trivial as it should be because the input array we want
 * to initialize the tab from keeps getting reordered from calls to call. This is needed to
 * get the highest priority tab initialized first.
 *
 * @param sortedPriorityArray The array of all the {@link StackTab} sorted by priority.
 */
private void updateDelayedLayoutTabInit(StackTab[] sortedPriorityArray) {
    if (!mDelayedLayoutTabInitRequired) return;

    int initialized = 0;
    final int count = sortedPriorityArray.length;
    for (int i = 0; i < count; i++) {
        if (initialized >= LAYOUTTAB_ASYNCHRONOUS_INITIALIZATION_BATCH_SIZE) return;

        LayoutTab layoutTab = sortedPriorityArray[i].getLayoutTab();
        // The actual initialization is done by the parent class.
        if (super.initLayoutTabFromHost(layoutTab)) {
            initialized++;
        }
    }
    if (initialized == 0) mDelayedLayoutTabInitRequired = false;
}
 
Example #4
Source File: StackLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
private int appendVisibleLayoutTabs(long time, int stackIndex, LayoutTab[] tabs, int tabIndex) {
    final StackTab[] stackTabs = mStacks[stackIndex].getTabs();
    if (stackTabs != null) {
        for (int i = 0; i < stackTabs.length; i++) {
            LayoutTab t = stackTabs[i].getLayoutTab();
            if (t.isVisible()) tabs[tabIndex++] = t;
        }
    }
    return tabIndex;
}
 
Example #5
Source File: StackLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the list of visible tab Id that the tab content manager is suppose to serve. The list
 * is ordered by priority. The first ones must be in the manager, then the remaining ones should
 * have at least approximations if possible.
 *
 * @param sortedPriorityArray The array of all the {@link StackTab} sorted by priority.
 */
private void updateTabsVisibility(StackTab[] sortedPriorityArray) {
    mVisibilityArray.clear();
    for (int i = 0; i < sortedPriorityArray.length; i++) {
        mVisibilityArray.add(sortedPriorityArray[i].getId());
    }
    updateCacheVisibleIds(mVisibilityArray);
}
 
Example #6
Source File: StackLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private boolean updateSortedPriorityArray(Comparator<StackTab> comparator) {
    final int allTabsCount = mStacks[0].getCount() + mStacks[1].getCount();
    if (allTabsCount == 0) return false;
    if (mSortedPriorityArray == null || mSortedPriorityArray.length != allTabsCount) {
        mSortedPriorityArray = new StackTab[allTabsCount];
    }
    int sortedOffset = 0;
    sortedOffset = addAllTabs(mStacks[0], mSortedPriorityArray, sortedOffset);
    sortedOffset = addAllTabs(mStacks[1], mSortedPriorityArray, sortedOffset);
    assert sortedOffset == mSortedPriorityArray.length;
    Arrays.sort(mSortedPriorityArray, comparator);
    return true;
}
 
Example #7
Source File: StackLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #8
Source File: StackLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private int appendVisibleLayoutTabs(long time, int stackIndex, LayoutTab[] tabs, int tabIndex) {
    final StackTab[] stackTabs = mStacks[stackIndex].getTabs();
    if (stackTabs != null) {
        for (int i = 0; i < stackTabs.length; i++) {
            LayoutTab t = stackTabs[i].getLayoutTab();
            if (t.isVisible()) tabs[tabIndex++] = t;
        }
    }
    return tabIndex;
}
 
Example #9
Source File: StackLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void contextChanged(Context context) {
    super.contextChanged(context);
    StackTab.resetDimensionConstants(context);
    mStacks[0].contextChanged(context);
    mStacks[1].contextChanged(context);
    requestStackUpdate();
}
 
Example #10
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the list of visible tab Id that the tab content manager is suppose to serve. The list
 * is ordered by priority. The first ones must be in the manager, then the remaining ones should
 * have at least approximations if possible.
 *
 * @param sortedPriorityArray The array of all the {@link StackTab} sorted by priority.
 */
private void updateTabsVisibility(StackTab[] sortedPriorityArray) {
    mVisibilityArray.clear();
    for (int i = 0; i < sortedPriorityArray.length; i++) {
        mVisibilityArray.add(sortedPriorityArray[i].getId());
    }
    updateCacheVisibleIds(mVisibilityArray);
}
 
Example #11
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private boolean updateSortedPriorityArray(Comparator<StackTab> comparator) {
    final int allTabsCount = mStacks[0].getCount() + mStacks[1].getCount();
    if (allTabsCount == 0) return false;
    if (mSortedPriorityArray == null || mSortedPriorityArray.length != allTabsCount) {
        mSortedPriorityArray = new StackTab[allTabsCount];
    }
    int sortedOffset = 0;
    sortedOffset = addAllTabs(mStacks[0], mSortedPriorityArray, sortedOffset);
    sortedOffset = addAllTabs(mStacks[1], mSortedPriorityArray, sortedOffset);
    assert sortedOffset == mSortedPriorityArray.length;
    Arrays.sort(mSortedPriorityArray, comparator);
    return true;
}
 
Example #12
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private int appendVisibleLayoutTabs(long time, int stackIndex, LayoutTab[] tabs, int tabIndex) {
    final StackTab[] stackTabs = mStacks[stackIndex].getTabs();
    if (stackTabs != null) {
        for (int i = 0; i < stackTabs.length; i++) {
            LayoutTab t = stackTabs[i].getLayoutTab();
            if (t.isVisible()) tabs[tabIndex++] = t;
        }
    }
    return tabIndex;
}
 
Example #14
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void contextChanged(Context context) {
    super.contextChanged(context);
    StackTab.resetDimensionConstants(context);
    mStacks[0].contextChanged(context);
    mStacks[1].contextChanged(context);
    requestStackUpdate();
}
 
Example #15
Source File: StackLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the list of visible tab Id that the tab content manager is suppose to serve. The list
 * is ordered by priority. The first ones must be in the manager, then the remaining ones should
 * have at least approximations if possible.
 *
 * @param sortedPriorityArray The array of all the {@link StackTab} sorted by priority.
 */
private void updateTabsVisibility(StackTab[] sortedPriorityArray) {
    mVisibilityArray.clear();
    for (int i = 0; i < sortedPriorityArray.length; i++) {
        mVisibilityArray.add(sortedPriorityArray[i].getId());
    }
    updateCacheVisibleIds(mVisibilityArray);
}
 
Example #16
Source File: StackLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
private boolean updateSortedPriorityArray(Comparator<StackTab> comparator) {
    final int allTabsCount = mStacks[0].getCount() + mStacks[1].getCount();
    if (allTabsCount == 0) return false;
    if (mSortedPriorityArray == null || mSortedPriorityArray.length != allTabsCount) {
        mSortedPriorityArray = new StackTab[allTabsCount];
    }
    int sortedOffset = 0;
    sortedOffset = addAllTabs(mStacks[0], mSortedPriorityArray, sortedOffset);
    sortedOffset = addAllTabs(mStacks[1], mSortedPriorityArray, sortedOffset);
    assert sortedOffset == mSortedPriorityArray.length;
    Arrays.sort(mSortedPriorityArray, comparator);
    return true;
}
 
Example #17
Source File: StackLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #18
Source File: StackLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void contextChanged(Context context) {
    super.contextChanged(context);
    StackTab.resetDimensionConstants(context);
    mStacks[0].contextChanged(context);
    mStacks[1].contextChanged(context);
    requestStackUpdate();
}
 
Example #19
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(StackTab tab1, StackTab tab2) {
    return (int) (tab2.getVisiblitySortingValue() - tab1.getVisiblitySortingValue());
}
 
Example #20
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(StackTab tab1, StackTab tab2) {
    return tab1.getOrderSortingValue() - tab2.getOrderSortingValue();
}
 
Example #21
Source File: StackLayout.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(StackTab tab1, StackTab tab2) {
    return tab1.getOrderSortingValue() - tab2.getOrderSortingValue();
}
 
Example #22
Source File: StackLayout.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(StackTab tab1, StackTab tab2) {
    return (int) (tab2.getVisiblitySortingValue() - tab1.getVisiblitySortingValue());
}
 
Example #23
Source File: StackLayout.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(StackTab tab1, StackTab tab2) {
    return tab1.getOrderSortingValue() - tab2.getOrderSortingValue();
}
 
Example #24
Source File: StackLayout.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(StackTab tab1, StackTab tab2) {
    return (int) (tab2.getVisiblitySortingValue() - tab1.getVisiblitySortingValue());
}