Java Code Examples for android.util.SparseArray#clear()
The following examples show how to use
android.util.SparseArray#clear() .
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: CachedContentIndex.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public void load( HashMap<String, CachedContent> content, SparseArray<@NullableType String> idToKey) { Assertions.checkState(!changed); if (!readFile(content, idToKey)) { content.clear(); idToKey.clear(); atomicFile.delete(); } }
Example 2
Source File: AbsSpinner.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void clear() { final SparseArray<View> scrapHeap = mScrapHeap; final int count = scrapHeap.size(); for (int i = 0; i < count; i++) { final View view = scrapHeap.valueAt(i); if (view != null) { removeDetachedView(view, true); } } scrapHeap.clear(); }
Example 3
Source File: IcsAbsSpinner.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
void clear() { final SparseArray<View> scrapHeap = mScrapHeap; final int count = scrapHeap.size(); for (int i = 0; i < count; i++) { final View view = scrapHeap.valueAt(i); if (view != null) { removeDetachedView(view, true); } } scrapHeap.clear(); }
Example 4
Source File: USBMonitor.java From AndroidUSBCamera with Apache License 2.0 | 5 votes |
/** * Close device * This also close interfaces if they are opened in Java side */ public synchronized void close() { if (DEBUG) Log.i(TAG, "UsbControlBlock#close:"); if (mConnection != null) { final int n = mInterfaces.size(); for (int i = 0; i < n; i++) { final SparseArray<UsbInterface> intfs = mInterfaces.valueAt(i); if (intfs != null) { final int m = intfs.size(); for (int j = 0; j < m; j++) { final UsbInterface intf = intfs.valueAt(j); mConnection.releaseInterface(intf); } intfs.clear(); } } mInterfaces.clear(); mConnection.close(); mConnection = null; final USBMonitor monitor = mWeakMonitor.get(); if (monitor != null) { if (monitor.mOnDeviceConnectListener != null) { monitor.mOnDeviceConnectListener.onDisconnect(mWeakDevice.get(), UsbControlBlock.this); } monitor.mCtrlBlocks.remove(getDevice()); } } }
Example 5
Source File: HeaderFooterWrapperAdapter.java From OmegaRecyclerView with MIT License | 5 votes |
private <V> void copyTo(SparseArray<V> fromArray, SparseArray<V> toArray) { toArray.clear(); for (int i = 0; i < fromArray.size(); i++) { toArray.append(fromArray.keyAt(i), fromArray.valueAt(i)); } }
Example 6
Source File: IcsAbsSpinner.java From zen4android with MIT License | 5 votes |
void clear() { final SparseArray<View> scrapHeap = mScrapHeap; final int count = scrapHeap.size(); for (int i = 0; i < count; i++) { final View view = scrapHeap.valueAt(i); if (view != null) { removeDetachedView(view, true); } } scrapHeap.clear(); }
Example 7
Source File: USBMonitor.java From libcommon with Apache License 2.0 | 5 votes |
/** * デバイスを閉じる * Java内でインターフェースをopenして使う時は開いているインターフェースも閉じる */ public void close() { if (DEBUG) Log.i(TAG, "UsbControlBlock#close:"); UsbDeviceConnection connection; synchronized (this) { connection = mConnection; mConnection = null; } if (connection != null) { // 2015/01/06 closeしてからonDisconnectを呼び出すように変更 // openしているinterfaceが有れば閉じる XXX Java側でインターフェースを使う時 final int n = mInterfaces.size(); for (int i = 0; i < n; i++) { final SparseArray<UsbInterface> intfs = mInterfaces.valueAt(i); if (intfs != null) { final int m = intfs.size(); for (int j = 0; j < m; j++) { final UsbInterface intf = intfs.valueAt(j); connection.releaseInterface(intf); } intfs.clear(); } } mInterfaces.clear(); connection.close(); final USBMonitor monitor = getMonitor(); final UsbDevice device = getDevice(); if ((monitor != null) && (device != null)) { monitor.callOnDisconnect(device, this); } } }
Example 8
Source File: NotificationsService.java From ForPDA with GNU General Public License v3.0 | 5 votes |
private void handlePendingEvents(NotificationEvent.Source source) { SparseArray<NotificationEvent> pending = pendingEvents.get(source); if (pending != null && pending.size() > 0) { List<NotificationEvent> events = new ArrayList<>(); for (int i = 0; i < pending.size(); i++) { events.add(pending.valueAt(i)); } hardHandleEvent(events, source); pending.clear(); } }
Example 9
Source File: EcoGalleryAbsSpinner.java From samples with Apache License 2.0 | 5 votes |
void clear() { final SparseArray<View> scrapHeap = mScrapHeap; final int count = scrapHeap.size(); for (int i = 0; i < count; i++) { final View view = scrapHeap.valueAt(i); if (view != null) { removeDetachedView(view, true); } } scrapHeap.clear(); }
Example 10
Source File: USBMonitor.java From DeviceConnect-Android with MIT License | 5 votes |
/** * Close device * This also close interfaces if they are opened in Java side */ public synchronized void close() { if (DEBUG) Log.i(TAG, "UsbControlBlock#close:"); if (mConnection != null) { final int n = mInterfaces.size(); for (int i = 0; i < n; i++) { final SparseArray<UsbInterface> intfs = mInterfaces.valueAt(i); if (intfs != null) { final int m = intfs.size(); for (int j = 0; j < m; j++) { final UsbInterface intf = intfs.valueAt(j); mConnection.releaseInterface(intf); } intfs.clear(); } } mInterfaces.clear(); mConnection.close(); mConnection = null; final USBMonitor monitor = mWeakMonitor.get(); if (monitor != null) { if (monitor.mOnDeviceConnectListener != null) { monitor.mOnDeviceConnectListener.onDisconnect(mWeakDevice.get(), UsbControlBlock.this); } monitor.mCtrlBlocks.remove(getDevice()); } } }
Example 11
Source File: IcsAbsSpinner.java From Libraries-for-Android-Developers with MIT License | 5 votes |
void clear() { final SparseArray<View> scrapHeap = mScrapHeap; final int count = scrapHeap.size(); for (int i = 0; i < count; i++) { final View view = scrapHeap.valueAt(i); if (view != null) { removeDetachedView(view, true); } } scrapHeap.clear(); }
Example 12
Source File: CachedContentIndex.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void load( HashMap<String, CachedContent> content, SparseArray<@NullableType String> idToKey) { Assertions.checkState(!changed); if (!readFile(content, idToKey)) { content.clear(); idToKey.clear(); atomicFile.delete(); } }
Example 13
Source File: CachedContentIndex.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void load( HashMap<String, CachedContent> content, SparseArray<@NullableType String> idToKey) { Assertions.checkState(!changed); if (!readFile(content, idToKey)) { content.clear(); idToKey.clear(); atomicFile.delete(); } }
Example 14
Source File: IcsAbsSpinner.java From android-apps with MIT License | 5 votes |
void clear() { final SparseArray<View> scrapHeap = mScrapHeap; final int count = scrapHeap.size(); for (int i = 0; i < count; i++) { final View view = scrapHeap.valueAt(i); if (view != null) { removeDetachedView(view, true); } } scrapHeap.clear(); }
Example 15
Source File: CachedContentIndex.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public void load( HashMap<String, CachedContent> content, SparseArray<@NullableType String> idToKey) throws IOException { Assertions.checkState(pendingUpdates.size() == 0); try { int version = VersionTable.getVersion( databaseProvider.getReadableDatabase(), VersionTable.FEATURE_CACHE_CONTENT_METADATA, hexUid); if (version != TABLE_VERSION) { SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase(); writableDatabase.beginTransaction(); try { initializeTable(writableDatabase); writableDatabase.setTransactionSuccessful(); } finally { writableDatabase.endTransaction(); } } try (Cursor cursor = getCursor()) { while (cursor.moveToNext()) { int id = cursor.getInt(COLUMN_INDEX_ID); String key = cursor.getString(COLUMN_INDEX_KEY); byte[] metadataBytes = cursor.getBlob(COLUMN_INDEX_METADATA); ByteArrayInputStream inputStream = new ByteArrayInputStream(metadataBytes); DataInputStream input = new DataInputStream(inputStream); DefaultContentMetadata metadata = readContentMetadata(input); CachedContent cachedContent = new CachedContent(id, key, metadata); content.put(cachedContent.key, cachedContent); idToKey.put(cachedContent.id, cachedContent.key); } } } catch (SQLiteException e) { content.clear(); idToKey.clear(); throw new DatabaseIOException(e); } }
Example 16
Source File: CachedContentIndex.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public void load( HashMap<String, CachedContent> content, SparseArray<@NullableType String> idToKey) throws IOException { Assertions.checkState(pendingUpdates.size() == 0); try { int version = VersionTable.getVersion( databaseProvider.getReadableDatabase(), VersionTable.FEATURE_CACHE_CONTENT_METADATA, hexUid); if (version != TABLE_VERSION) { SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase(); writableDatabase.beginTransaction(); try { initializeTable(writableDatabase); writableDatabase.setTransactionSuccessful(); } finally { writableDatabase.endTransaction(); } } try (Cursor cursor = getCursor()) { while (cursor.moveToNext()) { int id = cursor.getInt(COLUMN_INDEX_ID); String key = cursor.getString(COLUMN_INDEX_KEY); byte[] metadataBytes = cursor.getBlob(COLUMN_INDEX_METADATA); ByteArrayInputStream inputStream = new ByteArrayInputStream(metadataBytes); DataInputStream input = new DataInputStream(inputStream); DefaultContentMetadata metadata = readContentMetadata(input); CachedContent cachedContent = new CachedContent(id, key, metadata); content.put(cachedContent.key, cachedContent); idToKey.put(cachedContent.id, cachedContent.key); } } } catch (SQLiteException e) { content.clear(); idToKey.clear(); throw new DatabaseIOException(e); } }
Example 17
Source File: Spinner.java From material with Apache License 2.0 | 4 votes |
void clear() { final SparseArray<View> scrapHeap = mScrapHeap; scrapHeap.clear(); }
Example 18
Source File: WindowCache.java From FloatUtil with MIT License | 4 votes |
public void clear(Class<? extends Context> cls) { SparseArray<Window> l2 = sWindows.remove(cls); if(l2 != null && l2.size() > 0) { l2.clear(); } }
Example 19
Source File: Spinner.java From MDPreference with Apache License 2.0 | 4 votes |
void clear() { final SparseArray<View> scrapHeap = mScrapHeap; scrapHeap.clear(); }
Example 20
Source File: CachedContentIndex.java From MediaSDK with Apache License 2.0 | 4 votes |
@Override public void load( HashMap<String, CachedContent> content, SparseArray<@NullableType String> idToKey) throws IOException { Assertions.checkState(pendingUpdates.size() == 0); try { int version = VersionTable.getVersion( databaseProvider.getReadableDatabase(), VersionTable.FEATURE_CACHE_CONTENT_METADATA, hexUid); if (version != TABLE_VERSION) { SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase(); writableDatabase.beginTransactionNonExclusive(); try { initializeTable(writableDatabase); writableDatabase.setTransactionSuccessful(); } finally { writableDatabase.endTransaction(); } } try (Cursor cursor = getCursor()) { while (cursor.moveToNext()) { int id = cursor.getInt(COLUMN_INDEX_ID); String key = cursor.getString(COLUMN_INDEX_KEY); byte[] metadataBytes = cursor.getBlob(COLUMN_INDEX_METADATA); ByteArrayInputStream inputStream = new ByteArrayInputStream(metadataBytes); DataInputStream input = new DataInputStream(inputStream); DefaultContentMetadata metadata = readContentMetadata(input); CachedContent cachedContent = new CachedContent(id, key, metadata); content.put(cachedContent.key, cachedContent); idToKey.put(cachedContent.id, cachedContent.key); } } } catch (SQLiteException e) { content.clear(); idToKey.clear(); throw new DatabaseIOException(e); } }