Java Code Examples for android.util.SparseBooleanArray#append()
The following examples show how to use
android.util.SparseBooleanArray#append() .
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: Parcel.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void readSparseBooleanArrayInternal(SparseBooleanArray outVal, int N) { while (N > 0) { int key = readInt(); boolean value = this.readByte() == 1; //Log.i(TAG, "Unmarshalling key=" + key + " value=" + value); outVal.append(key, value); N--; } }
Example 2
Source File: TabPersistentStore.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * 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; }
Example 3
Source File: TabPersistentStore.java From 365browser with Apache License 2.0 | 4 votes |
/** * 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; }