當前位置: 首頁>>代碼示例>>Java>>正文


Java Pools類代碼示例

本文整理匯總了Java中android.support.v4.util.Pools的典型用法代碼示例。如果您正苦於以下問題:Java Pools類的具體用法?Java Pools怎麽用?Java Pools使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Pools類屬於android.support.v4.util包,在下文中一共展示了Pools類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: EngineJob

import android.support.v4.util.Pools; //導入依賴的package包/類
EngineJob(
    GlideExecutor diskCacheExecutor,
    GlideExecutor sourceExecutor,
    GlideExecutor sourceUnlimitedExecutor,
    GlideExecutor animationExecutor,
    EngineJobListener listener,
    Pools.Pool<EngineJob<?>> pool) {
  this(
      diskCacheExecutor,
      sourceExecutor,
      sourceUnlimitedExecutor,
      animationExecutor,
      listener,
      pool,
      DEFAULT_FACTORY);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:EngineJob.java

示例2: buildPlatformDecoder

import android.support.v4.util.Pools; //導入依賴的package包/類
/**
 * Provide the implementation of the PlatformDecoder for the current platform using the
 * provided PoolFactory
 *
 * @param poolFactory The PoolFactory
 * @return The PlatformDecoder implementation
 */
public static PlatformDecoder buildPlatformDecoder(
    PoolFactory poolFactory,
    boolean directWebpDirectDecodingEnabled) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    int maxNumThreads = poolFactory.getFlexByteArrayPoolMaxNumThreads();
    return new ArtDecoder(
        poolFactory.getBitmapPool(),
        maxNumThreads,
        new Pools.SynchronizedPool<>(maxNumThreads));
  } else {
    if (directWebpDirectDecodingEnabled
        && Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
      return new GingerbreadPurgeableDecoder();
    } else {
      return new KitKatPurgeableDecoder(poolFactory.getFlexByteArrayPool());
    }
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:ImagePipelineFactory.java

示例3: detach

import android.support.v4.util.Pools; //導入依賴的package包/類
public void detach(int count) {
    int childCount = mViews.size();
    while (childCount > 0 && count > 0) {
        V view = mViews.remove(childCount - 1);
        if (mCachePool == null) {
            mCachePool = new Pools.SimplePool<>(12);
        }

        // 做簡單cache,如果V需要動態添加子view,則業務保證不做cache
        Object notCacheTag = view.getTag(R.id.qmui_view_can_not_cache_tag);
        if (notCacheTag == null || !(boolean) notCacheTag) {
            try {
                mCachePool.release(view);
            } catch (Exception e) {
            }
        }

        mParentView.removeView(view);
        childCount--;
        count--;
    }
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:23,代碼來源:QMUIItemViewsAdapter.java

示例4: detach

import android.support.v4.util.Pools; //導入依賴的package包/類
public void detach(int count) {
    int childCount = mViews.size();
    while (childCount > 0 && count > 0) {
        V view = mViews.remove(childCount - 1);
        if (mCachePool == null) {
            mCachePool = new Pools.SimplePool<>(12);
        }

        // 做簡單cache,如果V需要動態添加子view,則業務保證不做cache
        Object notCacheTag = view.getTag(R.id.qmui_view_can_not_cache_tag);
        if (notCacheTag == null || !(boolean) notCacheTag) {
            try {
                mCachePool.release(view);
            } catch (Exception ignored) {
            }
        }

        mParentView.removeView(view);
        childCount--;
        count--;
    }
}
 
開發者ID:QMUI,項目名稱:QMUI_Android,代碼行數:23,代碼來源:QMUIItemViewsAdapter.java

示例5: TaskPool

import android.support.v4.util.Pools; //導入依賴的package包/類
TaskPool(Looper mainLooper, final String name, int maxThreads, List<TaskInterceptor> interceptors) {
    this.name = name;
    TASK_POOLS.put(name, this);
    this.interceptors = interceptors;
    handler = new Handler(mainLooper, this);
    BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(128);
    taskRunnablePool = new Pools.SimplePool<>(maxThreads);
    taskQueues = new Pools.SimplePool<>(10);
    maxThreads = Math.max(CORE_POOL_SIZE, maxThreads);
    poolExecutor = new ThreadPoolExecutor(CORE_POOL_SIZE, maxThreads, 1,
            TimeUnit.SECONDS, workQueue, new ThreadFactory() {
        private final AtomicInteger mCount = new AtomicInteger(1);
        @Override
        public Thread newThread(@NonNull Runnable r) {
            return new Thread(r, name + " #" + mCount.incrementAndGet());
        }
    });

    if (LISTENER != null)
        LISTENER.onCreated(this);
}
 
開發者ID:lifechurch,項目名稱:nuclei-android,代碼行數:22,代碼來源:TaskPool.java

示例6: initEmojisPool

import android.support.v4.util.Pools; //導入依賴的package包/類
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);
    }
}
 
開發者ID:Luolc,項目名稱:EmojiRain,代碼行數:18,代碼來源:EmojiRainLayout.java

示例7: EngineJob

import android.support.v4.util.Pools; //導入依賴的package包/類
EngineJob(GlideExecutor diskCacheExecutor, GlideExecutor sourceExecutor,
    GlideExecutor sourceUnlimitedExecutor,
    EngineJobListener listener, Pools.Pool<EngineJob<?>> pool,
    EngineResourceFactory engineResourceFactory) {
  this.diskCacheExecutor = diskCacheExecutor;
  this.sourceExecutor = sourceExecutor;
  this.sourceUnlimitedExecutor = sourceUnlimitedExecutor;
  this.listener = listener;
  this.pool = pool;
  this.engineResourceFactory = engineResourceFactory;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:EngineJob.java

示例8: setUp

import android.support.v4.util.Pools; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
  final Random random = new Random();
  random.setSeed(RANDOM_SEED);
  mEncodedBytes = new byte[ENCODED_BYTES_LENGTH];
  random.nextBytes(mEncodedBytes);

  mPooledByteBuffer = new TrivialPooledByteBuffer(mEncodedBytes);
  mBitmapPool = mock(BitmapPool.class);
  mArtDecoder = new ArtDecoder(mBitmapPool, 1, new Pools.SynchronizedPool(1));

  mByteBufferRef = CloseableReference.of(mPooledByteBuffer);
  mEncodedImage = new EncodedImage(mByteBufferRef);
  mEncodedImage.setImageFormat(DefaultImageFormats.JPEG);
  mBitmap = MockBitmapFactory.create();
  doReturn(mBitmap).when(mBitmapPool).get(MockBitmapFactory.DEFAULT_BITMAP_SIZE);

  mBitmapFactoryDefaultAnswer = new Answer<Bitmap>() {
    @Override
    public Bitmap answer(InvocationOnMock invocation) throws Throwable {
      final BitmapFactory.Options options = (BitmapFactory.Options) invocation.getArguments()[2];
      options.outWidth = MockBitmapFactory.DEFAULT_BITMAP_WIDTH;
      options.outHeight = MockBitmapFactory.DEFAULT_BITMAP_HEIGHT;
      verifyBitmapFactoryOptions(options);
      return options.inJustDecodeBounds ? null : mBitmap;
    }
  };
  whenBitmapFactoryDecodeStream().thenAnswer(mBitmapFactoryDefaultAnswer);

  mBitmapRegionDecoder = mock(BitmapRegionDecoder.class);
  whenBitmapRegionDecoderNewInstance().thenReturn(mBitmapRegionDecoder);

  ByteBuffer buf = mArtDecoder.mDecodeBuffers.acquire();
  mTempStorage = buf.array();
  mArtDecoder.mDecodeBuffers.release(buf);

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:38,代碼來源:ArtDecoderTest.java

示例9: SparseArrayBitmapPool

import android.support.v4.util.Pools; //導入依賴的package包/類
/**
 * @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;
    }
}
 
開發者ID:mayurkaul,項目名稱:medialibrary,代碼行數:13,代碼來源:SparseArrayBitmapPool.java

示例10: generateALineItem

import android.support.v4.util.Pools; //導入依賴的package包/類
private LineItemPosRecord generateALineItem(FlowDragLayoutManager layoutManager) {
        if (rectSimplePool == null) {
            rectSimplePool = new Pools.SimplePool<>(layoutManager.getChildCount());
        }
        LineItemPosRecord out = rectSimplePool.acquire();
        if (out == null) {
//            DebugUtil.debugFormat("FlowDragLayoutManager out come from new");
            out = new LineItemPosRecord();
        }else {
//            DebugUtil.debugFormat("FlowDragLayoutManager out come from pool");
        }
        return out;
    }
 
開發者ID:jay16,項目名稱:shengyiplus-android,代碼行數:14,代碼來源:LayoutHelperImpl.java

示例11: obtain

import android.support.v4.util.Pools; //導入依賴的package包/類
/**
 * Retriever an instance from the pool
 *
 * @param itemClass item class
 * @return animator holder
 */
public static AnimatorHolder obtain(Class<? extends AnimatorItem> itemClass){
    Pools.SynchronizedPool<AnimatorHolder> pool = sPoolMap.get(itemClass);
    if (pool == null){
        pool = new Pools.SynchronizedPool<>(MAX_POOL_SIZE);
        sPoolMap.put(itemClass, pool);
    }
    AnimatorHolder holder = pool.acquire();
    if (holder != null && holder.mItemClass.equals(itemClass)){
        holder.reset();
        return holder;
    } else {
        return new AnimatorHolder(itemClass);
    }
}
 
開發者ID:iwhys,項目名稱:to-animator,代碼行數:21,代碼來源:AnimatorHolder.java

示例12: destroyAll

import android.support.v4.util.Pools; //導入依賴的package包/類
/**
 * destroy the pools
 */
public static void destroyAll(){
    Set<Class> keys = sPoolMap.keySet();
    for (Class key : keys) {
        Pools.SynchronizedPool<AnimatorHolder> pool = sPoolMap.get(key);
        if (pool != null){
            AnimatorHolder holder = pool.acquire();
            for (; holder != null; holder = pool.acquire()){
                holder.destroy();
            }
        }
    }
    sPoolMap.clear();
}
 
開發者ID:iwhys,項目名稱:to-animator,代碼行數:17,代碼來源:AnimatorHolder.java

示例13: DecodeJob

import android.support.v4.util.Pools; //導入依賴的package包/類
DecodeJob(DiskCacheProvider diskCacheProvider, Pools.Pool<DecodeJob<?>> pool) {
  this.diskCacheProvider = diskCacheProvider;
  this.pool = pool;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:DecodeJob.java

示例14: recycle

import android.support.v4.util.Pools; //導入依賴的package包/類
/**
 * Put current object into the pool
 */
public void recycle(){
    Pools.SynchronizedPool<AnimatorHolder> pool = sPoolMap.get(mItemClass);
    pool.release(this);
}
 
開發者ID:iwhys,項目名稱:to-animator,代碼行數:8,代碼來源:AnimatorHolder.java


注:本文中的android.support.v4.util.Pools類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。