Android Open Source - WebImageView Lmt Size Mem Cache






From Project

Back to project page WebImageView.

License

The source code is released under:

MIT License

If you think the Android project WebImageView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.rsv.cache;
/*from w ww .j a va 2 s.c  o  m*/
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;

/**
 * A size limited memory cache implementation
 * 
 */
public class LmtSizeMemCache<K> extends BaseMemCache<String, K> {

  private final int sizeLimit;

  public LmtSizeMemCache(int sizeLimit) {
    this.sizeLimit = sizeLimit;
  }

  @Override
  public boolean put(String key, K value) {

    if (sizeLimit > 0) {

      if (super.put(key, value)) {

        while (this.size() > sizeLimit) {
          this.removeFirst();
        }
      }

      return true;
    }

    return false;
  }

  @Override
  protected Reference<K> createReference(K value) {
    return new SoftReference<K>(value);
  }
}




Java Source Code List

com.rsv.cache.BaseFileCache.java
com.rsv.cache.BaseMemCache.java
com.rsv.cache.LmtSizeMemCache.java
com.rsv.cache.LmtSpaceFileCache.java
com.rsv.comp.IProgressListener.java
com.rsv.comp.ImageLoader.java
com.rsv.config.ConfigReader.java
com.rsv.config.Constants.java
com.rsv.utils.FileUtils.java
com.rsv.utils.HttpClientUtils.java
com.rsv.utils.IOUtils.java
com.rsv.utils.ImgUtils.java
com.rsv.utils.LogUtils.java
com.rsv.utils.OSUtils.java
com.rsv.utils.StorageUtils.java
com.rsv.widget.WebImageView.java