示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Pulser.Android.Collections.ReuseBitmapDrawableCache"/> class.
        /// </summary>
        /// <param name="highWatermark">Maximum size of cache in bytes before evictions start.</param>
        /// <param name="lowWatermark">Size in bytes to drain the cache down to after the high watermark has been exceeded.</param>
        /// <param name="debugDump">If set to <c>true</c> dump stats to log every 10 seconds.</param>
        public BitmapDrawableCache(long highWatermark, long lowWatermark, bool debugDump = false)
        {
            var lruCache = new ByteBoundStrongLruCache <Uri, SelfDisposingBitmapDrawable>(highWatermark, lowWatermark);

            lruCache.EntryRemoved += OnLruEviction;
            displayed_cache        = lruCache;

            if (debugDump)
            {
                main_thread_handler = new Handler();
                DebugDumpStats();
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Pulser.Android.Collections.AndroidBitmapDrawableCache"/> class.
        /// </summary>
        /// <param name="highWatermark">Maximum number of bytes the reuse pool will hold before starting evictions.
        /// <param name="lowWatermark">Number of bytes the reuse pool will be drained down to after the high watermark is exceeded.</param>
        /// On Honeycomb and higher this value is used for the reuse pool size.</param>
        /// <param name="gcThreshold">Threshold in bytes that triggers a System.GC.Collect (Honeycomb+ only).</param>
        /// <param name="debugDump">If set to <c>true</c> dump stats to log every 10 seconds.</param>
        public ReuseBitmapDrawableCache(long highWatermark, long lowWatermark, long gcThreshold = 2 * 1024 * 1024, bool debugDump = false)
        {
            low_watermark  = lowWatermark;
            high_watermark = highWatermark;

            gc_threshold             = gcThreshold;
            displayed_cache          = new Dictionary <Uri, SelfDisposingBitmapDrawable>();
            reuse_pool               = new ByteBoundStrongLruCache <Uri, SelfDisposingBitmapDrawable>(highWatermark, lowWatermark);
            reuse_pool.EntryRemoved += OnEntryRemovedFromReusePool;

            if (debugDump)
            {
                main_thread_handler = new Handler();
                DebugDumpStats();
            }
        }