当前位置: 首页>>代码示例>>Java>>正文


Java SparseBooleanArray.append方法代码示例

本文整理汇总了Java中android.util.SparseBooleanArray.append方法的典型用法代码示例。如果您正苦于以下问题:Java SparseBooleanArray.append方法的具体用法?Java SparseBooleanArray.append怎么用?Java SparseBooleanArray.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.util.SparseBooleanArray的用法示例。


在下文中一共展示了SparseBooleanArray.append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCheckedItemPositions

import android.util.SparseBooleanArray; //导入方法依赖的package包/类
/**
 * Gets all locations of checked items in the RecyclerGrid
 *
 * @return SparseBooleanArray containing key-value pairs of locations where checked == true
 */
public SparseBooleanArray getCheckedItemPositions() {
    SparseBooleanArray checkedLocations = new SparseBooleanArray();

    // Loop through all SetGameCardViews in the adapter and add locations and values for
    // those that are checked
    for (int i = 0; i < mRecyclerGridView.getChildCount(); i++) {
        SetGameCardView cardView = (SetGameCardView) mRecyclerGridView.getChildAt(i);
        if (cardView.isChecked()) {
            checkedLocations.append(i, true);
        }
    }
    return checkedLocations;
}
 
开发者ID:jaysondc,项目名称:TripleTap,代码行数:19,代码来源:GameFragment.java

示例2: readSavedStateFile

import android.util.SparseBooleanArray; //导入方法依赖的package包/类
/**
 * Extracts the tab information from a given tab state stream.
 *
 * @param stream   The stream pointing to the tab state file to be parsed.
 * @param callback A callback to be streamed updates about the tab state information being read.
 * @param tabIds   A mapping of tab ID to whether the tab is an off the record tab.
 * @param forMerge Whether this state file was read as part of a merge.
 * @return The next available tab ID based on the maximum ID referenced in this state file.
 */
public static int readSavedStateFile(
        DataInputStream stream, @Nullable OnTabStateReadCallback callback,
        @Nullable SparseBooleanArray tabIds, boolean forMerge) throws IOException {
    if (stream == null) return 0;
    long time = SystemClock.uptimeMillis();
    int nextId = 0;
    boolean skipUrlRead = false;
    boolean skipIncognitoCount = false;
    final int version = stream.readInt();
    if (version != SAVED_STATE_VERSION) {
        // We don't support restoring Tab data from before M18.
        if (version < 3) return 0;
        // Older versions are missing newer data.
        if (version < 5) skipIncognitoCount = true;
        if (version < 4) skipUrlRead = true;
    }

    final int count = stream.readInt();
    final int incognitoCount = skipIncognitoCount ? -1 : stream.readInt();
    final int incognitoActiveIndex = stream.readInt();
    final int standardActiveIndex = stream.readInt();
    if (count < 0 || incognitoActiveIndex >= count || standardActiveIndex >= count) {
        throw new IOException();
    }

    for (int i = 0; i < count; i++) {
        int id = stream.readInt();
        String tabUrl = skipUrlRead ? "" : stream.readUTF();
        if (id >= nextId) nextId = id + 1;
        if (tabIds != null) tabIds.append(id, true);

        Boolean isIncognito = (incognitoCount < 0) ? null : i < incognitoCount;
        if (callback != null) {
            callback.onDetailsRead(i, id, tabUrl, isIncognito,
                    i == standardActiveIndex, i == incognitoActiveIndex);
        }
    }

    if (forMerge) {
        logExecutionTime("ReadMergedStateTime", time);
        int tabCount = count + ((incognitoCount > 0) ? incognitoCount : 0);
        RecordHistogram.recordLinearCountHistogram(
                "Android.TabPersistentStore.MergeStateTabCount",
                tabCount, 1, 200, 200);
    }

    logExecutionTime("ReadSavedStateTime", time);

    return nextId;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:60,代码来源:TabPersistentStore.java


注:本文中的android.util.SparseBooleanArray.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。