android.support.v4.util.Pools Java Examples

The following examples show how to use android.support.v4.util.Pools. 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: EmojiRainLayout.java    From EmojiRain with Apache License 2.0 6 votes vote down vote up
private void initEmojisPool() {
    final int emojiTypeCount = mEmojis.size();
    if (emojiTypeCount == 0) throw new IllegalStateException("There are no emojis");

    clearDirtyEmojisInPool();
    final int expectedMaxEmojiCountInScreen =
            (int) ((1 + RELATIVE_DROP_DURATION_OFFSET)
                    * mEmojiPer
                    * mDropAverageDuration
                    / ((float) mDropFrequency));
    mEmojiPool = new Pools.SynchronizedPool<>(expectedMaxEmojiCountInScreen);
    for (int i = 0; i < expectedMaxEmojiCountInScreen; i++) {
        final ImageView emoji = generateEmoji(mEmojis.get(i % emojiTypeCount));
        addView(emoji, 0);
        mEmojiPool.release(emoji);
    }
}
 
Example #2
Source File: SparseArrayBitmapPool.java    From medialibrary with Apache License 2.0 5 votes vote down vote up
/**
 * @param capacityBytes Maximum capacity of the pool in bytes.
 * @param nodePool Shared pool to use for recycling linked list nodes, or null.
 */
public SparseArrayBitmapPool(int capacityBytes, Pools.Pool<Node> nodePool) {
    mCapacityBytes = capacityBytes;
    if (nodePool == null) {
        mNodePool = new Pools.SimplePool<Node>(32);
    } else {
        mNodePool = nodePool;
    }
}
 
Example #3
Source File: BitmapPool.java    From Mupdf with Apache License 2.0 4 votes vote down vote up
private BitmapPool() {
    simplePool = new Pools.SimplePool<>(16);
}