com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator Java Examples

The following examples show how to use com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator. 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: DefaultConfigurationFactory.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
/**
 * Creates default implementation of {@link DiskCache} depends on incoming parameters
 */
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator,
		long diskCacheSize, int diskCacheFileCount) {
	File reserveCacheDir = createReserveDiskCacheDir(context);
	if (diskCacheSize > 0 || diskCacheFileCount > 0) {
		File individualCacheDir = StorageUtils.getIndividualCacheDirectory(context);
		try {
			return new LruDiscCache(individualCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize,
					diskCacheFileCount);
		} catch (IOException e) {
			L.e(e);
			// continue and create unlimited cache
		}
	}
	File cacheDir = StorageUtils.getCacheDirectory(context);
	return new UnlimitedDiscCache(cacheDir, reserveCacheDir, diskCacheFileNameGenerator);
}
 
Example #2
Source File: DefaultConfigurationFactory.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 6 votes vote down vote up
/**
 * 默认图片 本地路径缓存
 * Creates default implementation of {@link DiskCache} depends on incoming parameters
 */
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator,
		long diskCacheSize, int diskCacheFileCount) {
	//创建备用缓存文件
	File reserveCacheDir = createReserveDiskCacheDir(context);
	if (diskCacheSize > 0 || diskCacheFileCount > 0) {
		File individualCacheDir = StorageUtils.getIndividualCacheDirectory(context);
		try {
			//创建本地文件系统缓存器
			return new LruDiskCache(individualCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize,
					diskCacheFileCount);
		} catch (IOException e) {
			L.e(e);
			// continue and create unlimited cache
		}
	}
	//创建无限制的文件缓存器
	File cacheDir = StorageUtils.getCacheDirectory(context);
	return new UnlimitedDiskCache(cacheDir, reserveCacheDir, diskCacheFileNameGenerator);
}
 
Example #3
Source File: BaseDiscCache.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public BaseDiscCache(File file, File file1, FileNameGenerator filenamegenerator)
{
    bufferSize = 32768;
    compressFormat = DEFAULT_COMPRESS_FORMAT;
    compressQuality = 100;
    if (file == null)
    {
        throw new IllegalArgumentException("cacheDir argument must be not null");
    }
    if (filenamegenerator == null)
    {
        throw new IllegalArgumentException("fileNameGenerator argument must be not null");
    } else
    {
        cacheDir = file;
        reserveCacheDir = file1;
        fileNameGenerator = filenamegenerator;
        return;
    }
}
 
Example #4
Source File: DefaultConfigurationFactory.java    From WliveTV with Apache License 2.0 6 votes vote down vote up
/**
 * Creates default implementation of {@link DiskCache} depends on incoming parameters
 */
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator,
		long diskCacheSize, int diskCacheFileCount) {
	File reserveCacheDir = createReserveDiskCacheDir(context);
	if (diskCacheSize > 0 || diskCacheFileCount > 0) {
		File individualCacheDir = StorageUtils.getIndividualCacheDirectory(context);
		try {
			return new LruDiskCache(individualCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize,
					diskCacheFileCount);
		} catch (IOException e) {
			L.e(e);
			// continue and create unlimited cache
		}
	}
	File cacheDir = StorageUtils.getCacheDirectory(context);
	return new UnlimitedDiskCache(cacheDir, reserveCacheDir, diskCacheFileNameGenerator);
}
 
Example #5
Source File: DefaultConfigurationFactory.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
/**
 * Creates default implementation of {@link DiskCache} depends on incoming parameters
 */
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator,
		long diskCacheSize, int diskCacheFileCount) {
	File reserveCacheDir = createReserveDiskCacheDir(context);
	if (diskCacheSize > 0 || diskCacheFileCount > 0) {
		File individualCacheDir = StorageUtils.getIndividualCacheDirectory(context);
		try {
			return new LruDiscCache(individualCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize,
					diskCacheFileCount);
		} catch (IOException e) {
			L.e(e);
			// continue and create unlimited cache
		}
	}
	File cacheDir = StorageUtils.getCacheDirectory(context);
	return new UnlimitedDiscCache(cacheDir, reserveCacheDir, diskCacheFileNameGenerator);
}
 
Example #6
Source File: LruDiscCache.java    From letv with Apache License 2.0 6 votes vote down vote up
public LruDiscCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator, long cacheMaxSize, int cacheMaxFileCount) throws IOException {
    this.bufferSize = 32768;
    this.compressFormat = DEFAULT_COMPRESS_FORMAT;
    this.compressQuality = 100;
    if (cacheDir == null) {
        throw new IllegalArgumentException("cacheDir argument must be not null");
    } else if (cacheMaxSize < 0) {
        throw new IllegalArgumentException("cacheMaxSize argument must be positive number");
    } else if (cacheMaxFileCount < 0) {
        throw new IllegalArgumentException("cacheMaxFileCount argument must be positive number");
    } else if (fileNameGenerator == null) {
        throw new IllegalArgumentException("fileNameGenerator argument must be not null");
    } else {
        if (cacheMaxSize == 0) {
            cacheMaxSize = Long.MAX_VALUE;
        }
        if (cacheMaxFileCount == 0) {
            cacheMaxFileCount = Integer.MAX_VALUE;
        }
        this.reserveCacheDir = reserveCacheDir;
        this.fileNameGenerator = fileNameGenerator;
        initCache(cacheDir, reserveCacheDir, cacheMaxSize, cacheMaxFileCount);
    }
}
 
Example #7
Source File: DefaultConfigurationFactory.java    From candybar with Apache License 2.0 6 votes vote down vote up
/**
 * Creates default implementation of {@link DiskCache} depends on incoming parameters
 */
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator,
                                        long diskCacheSize, int diskCacheFileCount) {
    File reserveCacheDir = createReserveDiskCacheDir(context);
    if (diskCacheSize > 0 || diskCacheFileCount > 0) {
        File individualCacheDir = StorageUtils.getIndividualCacheDirectory(context);
        try {
            return new LruDiskCache(individualCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize,
                    diskCacheFileCount);
        } catch (IOException e) {
            L.e(e);
            // continue and create unlimited cache
        }
    }
    File cacheDir = StorageUtils.getCacheDirectory(context);
    return new UnlimitedDiskCache(cacheDir, reserveCacheDir, diskCacheFileNameGenerator);
}
 
Example #8
Source File: DefaultConfigurationFactory.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
/**
 * Creates default implementation of {@link DiskCache} depends on incoming parameters
 */
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator,
		long diskCacheSize, int diskCacheFileCount) {
	File reserveCacheDir = createReserveDiskCacheDir(context);
	if (diskCacheSize > 0 || diskCacheFileCount > 0) {
		File individualCacheDir = StorageUtils.getIndividualCacheDirectory(context);
		try {
			return new LruDiskCache(individualCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize,
					diskCacheFileCount);
		} catch (IOException e) {
			L.e(e);
			// continue and create unlimited cache
		}
	}
	File cacheDir = StorageUtils.getCacheDirectory(context);
	return new UnlimitedDiskCache(cacheDir, reserveCacheDir, diskCacheFileNameGenerator);
}
 
Example #9
Source File: BaseDiskCache.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
/**
 * 构造方法   传入缓存文件夹 以及备用缓存文件夹,缓存文件命名方式
 * @param cacheDir          Directory for file caching
 * @param reserveCacheDir   null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
 * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
 *                          Name generator} for cached files
 */
public BaseDiskCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator) {
	if (cacheDir == null) {
		throw new IllegalArgumentException("cacheDir" + ERROR_ARG_NULL);
	}
	if (fileNameGenerator == null) {
		throw new IllegalArgumentException("fileNameGenerator" + ERROR_ARG_NULL);
	}

	this.cacheDir = cacheDir;
	this.reserveCacheDir = reserveCacheDir;
	this.fileNameGenerator = fileNameGenerator;
}
 
Example #10
Source File: ImageLoaderConfiguration.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
/**
 * 设置本地文件缓存器中 缓存文件名生成器
 * Sets name generator for files cached in disk cache.<br />
 * Default value -
 * {@link com.nostra13.universalimageloader.core.DefaultConfigurationFactory#createFileNameGenerator()
 * DefaultConfigurationFactory.createFileNameGenerator()}
 */
public Builder diskCacheFileNameGenerator(FileNameGenerator fileNameGenerator) {
	if (diskCache != null) {
		L.w(WARNING_OVERLAP_DISK_CACHE_NAME_GENERATOR);
	}

	this.diskCacheFileNameGenerator = fileNameGenerator;
	return this;
}
 
Example #11
Source File: LruDiskCache.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
/**
 * LruDiskCache 图片本地文件缓存器初始化
 * @param cacheDir          Directory for file caching
 * @param reserveCacheDir   null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
 * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
 *                          Name generator} for cached files. Generated names must match the regex
 *                          <strong>[a-z0-9_-]{1,64}</strong>
 * @param cacheMaxSize      Max cache size in bytes. <b>0</b> means cache size is unlimited.
 * @param cacheMaxFileCount Max file count in cache. <b>0</b> means file count is unlimited.
 * @throws IOException if cache can't be initialized (e.g. "No space left on device")
 */
public LruDiskCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator, long cacheMaxSize,
		int cacheMaxFileCount) throws IOException {
	if (cacheDir == null) {
		throw new IllegalArgumentException("cacheDir" + ERROR_ARG_NULL);
	}
	if (cacheMaxSize < 0) {
		throw new IllegalArgumentException("cacheMaxSize" + ERROR_ARG_NEGATIVE);
	}
	if (cacheMaxFileCount < 0) {
		throw new IllegalArgumentException("cacheMaxFileCount" + ERROR_ARG_NEGATIVE);
	}
	if (fileNameGenerator == null) {
		throw new IllegalArgumentException("fileNameGenerator" + ERROR_ARG_NULL);
	}
       //如果传入最大缓存大小为0 ,那么设置Long的最大值
	if (cacheMaxSize == 0) {
		cacheMaxSize = Long.MAX_VALUE;
	}
	//如果传入最大缓存文件数量为0 ,那么设置Integer的最大值
	if (cacheMaxFileCount == 0) {
		cacheMaxFileCount = Integer.MAX_VALUE;
	}

	this.reserveCacheDir = reserveCacheDir;
	this.fileNameGenerator = fileNameGenerator;
	//初始化缓存
	initCache(cacheDir, reserveCacheDir, cacheMaxSize, cacheMaxFileCount);
}
 
Example #12
Source File: LruDiscCache.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
 * @param cacheDir          Directory for file caching
 * @param reserveCacheDir   null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
 * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
 *                          Name generator} for cached files. Generated names must match the regex
 *                          <strong>[a-z0-9_-]{1,64}</strong>
 * @param cacheMaxSize      Max cache size in bytes. <b>0</b> means cache size is unlimited.
 * @param cacheMaxFileCount Max file count in cache. <b>0</b> means file count is unlimited.
 * @throws java.io.IOException if cache can't be initialized (e.g. "No space left on device")
 */
public LruDiscCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator, long cacheMaxSize,
		int cacheMaxFileCount) throws IOException {
	if (cacheDir == null) {
		throw new IllegalArgumentException("cacheDir" + ERROR_ARG_NULL);
	}
	if (cacheMaxSize < 0) {
		throw new IllegalArgumentException("cacheMaxSize" + ERROR_ARG_NEGATIVE);
	}
	if (cacheMaxFileCount < 0) {
		throw new IllegalArgumentException("cacheMaxFileCount" + ERROR_ARG_NEGATIVE);
	}
	if (fileNameGenerator == null) {
		throw new IllegalArgumentException("fileNameGenerator" + ERROR_ARG_NULL);
	}

	if (cacheMaxSize == 0) {
		cacheMaxSize = Long.MAX_VALUE;
	}
	if (cacheMaxFileCount == 0) {
		cacheMaxFileCount = Integer.MAX_VALUE;
	}

	this.reserveCacheDir = reserveCacheDir;
	this.fileNameGenerator = fileNameGenerator;
	initCache(cacheDir, reserveCacheDir, cacheMaxSize, cacheMaxFileCount);
}
 
Example #13
Source File: ImageLoaderConfiguration.java    From letv with Apache License 2.0 5 votes vote down vote up
public Builder diskCacheFileNameGenerator(FileNameGenerator fileNameGenerator) {
    if (this.diskCache != null) {
        L.w(WARNING_OVERLAP_DISK_CACHE_NAME_GENERATOR, new Object[0]);
    }
    this.diskCacheFileNameGenerator = fileNameGenerator;
    return this;
}
 
Example #14
Source File: BaseDiskCache.java    From candybar with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheDir          Directory for file caching
 * @param reserveCacheDir   null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
 * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
 *                          Name generator} for cached files
 */
public BaseDiskCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator) {
    if (cacheDir == null) {
        throw new IllegalArgumentException("cacheDir" + ERROR_ARG_NULL);
    }
    if (fileNameGenerator == null) {
        throw new IllegalArgumentException("fileNameGenerator" + ERROR_ARG_NULL);
    }

    this.cacheDir = cacheDir;
    this.reserveCacheDir = reserveCacheDir;
    this.fileNameGenerator = fileNameGenerator;
}
 
Example #15
Source File: BaseDiscCache.java    From letv with Apache License 2.0 5 votes vote down vote up
public BaseDiscCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator) {
    this.bufferSize = 32768;
    this.compressFormat = DEFAULT_COMPRESS_FORMAT;
    this.compressQuality = 100;
    if (cacheDir == null) {
        throw new IllegalArgumentException("cacheDir argument must be not null");
    } else if (fileNameGenerator == null) {
        throw new IllegalArgumentException("fileNameGenerator argument must be not null");
    } else {
        this.cacheDir = cacheDir;
        this.reserveCacheDir = reserveCacheDir;
        this.fileNameGenerator = fileNameGenerator;
    }
}
 
Example #16
Source File: ImageLoaderConfiguration.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
/**
 * Sets name generator for files cached in disk cache.<br />
 * Default value -
 * {@link com.nostra13.universalimageloader.core.DefaultConfigurationFactory#createFileNameGenerator()
 * DefaultConfigurationFactory.createFileNameGenerator()}
 */
public Builder diskCacheFileNameGenerator(FileNameGenerator fileNameGenerator) {
	if (diskCache != null) {
		L.w(WARNING_OVERLAP_DISK_CACHE_NAME_GENERATOR);
	}

	this.diskCacheFileNameGenerator = fileNameGenerator;
	return this;
}
 
Example #17
Source File: ImageLoaderConfiguration.java    From candybar with Apache License 2.0 5 votes vote down vote up
/**
 * Sets name generator for files cached in disk cache.<br />
 * Default value -
 * {@link com.nostra13.universalimageloader.core.DefaultConfigurationFactory#createFileNameGenerator()
 * DefaultConfigurationFactory.createFileNameGenerator()}
 */
public Builder diskCacheFileNameGenerator(FileNameGenerator fileNameGenerator) {
    if (diskCache != null) {
        L.w(WARNING_OVERLAP_DISK_CACHE_NAME_GENERATOR);
    }

    this.diskCacheFileNameGenerator = fileNameGenerator;
    return this;
}
 
Example #18
Source File: LruDiscCache.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheDir          Directory for file caching
 * @param reserveCacheDir   null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
 * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
 *                          Name generator} for cached files. Generated names must match the regex
 *                          <strong>[a-z0-9_-]{1,64}</strong>
 * @param cacheMaxSize      Max cache size in bytes. <b>0</b> means cache size is unlimited.
 * @param cacheMaxFileCount Max file count in cache. <b>0</b> means file count is unlimited.
 * @throws IOException if cache can't be initialized (e.g. "No space left on device")
 */
public LruDiscCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator, long cacheMaxSize,
		int cacheMaxFileCount) throws IOException {
	if (cacheDir == null) {
		throw new IllegalArgumentException("cacheDir" + ERROR_ARG_NULL);
	}
	if (cacheMaxSize < 0) {
		throw new IllegalArgumentException("cacheMaxSize" + ERROR_ARG_NEGATIVE);
	}
	if (cacheMaxFileCount < 0) {
		throw new IllegalArgumentException("cacheMaxFileCount" + ERROR_ARG_NEGATIVE);
	}
	if (fileNameGenerator == null) {
		throw new IllegalArgumentException("fileNameGenerator" + ERROR_ARG_NULL);
	}

	if (cacheMaxSize == 0) {
		cacheMaxSize = Long.MAX_VALUE;
	}
	if (cacheMaxFileCount == 0) {
		cacheMaxFileCount = Integer.MAX_VALUE;
	}

	this.reserveCacheDir = reserveCacheDir;
	this.fileNameGenerator = fileNameGenerator;
	initCache(cacheDir, reserveCacheDir, cacheMaxSize, cacheMaxFileCount);
}
 
Example #19
Source File: DefaultConfigurationFactory.java    From letv with Apache License 2.0 5 votes vote down vote up
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator, long diskCacheSize, int diskCacheFileCount) {
    File reserveCacheDir = createReserveDiskCacheDir(context);
    if (diskCacheSize > 0 || diskCacheFileCount > 0) {
        try {
            return new LruDiscCache(StorageUtils.getIndividualCacheDirectory(context), reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize, diskCacheFileCount);
        } catch (IOException e) {
            L.e(e);
        }
    }
    return new UnlimitedDiscCache(StorageUtils.getCacheDirectory(context), reserveCacheDir, diskCacheFileNameGenerator);
}
 
Example #20
Source File: DefaultConfigurationFactory.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static DiskCache createDiskCache(Context context, FileNameGenerator filenamegenerator, long l, int i)
{
    File file = a(context);
    if (l > 0L || i > 0)
    {
        LruDiscCache lrudisccache = new LruDiscCache(StorageUtils.getIndividualCacheDirectory(context), filenamegenerator, l, i);
        lrudisccache.setReserveCacheDir(file);
        return lrudisccache;
    } else
    {
        return new UnlimitedDiscCache(StorageUtils.getCacheDirectory(context), file, filenamegenerator);
    }
}
 
Example #21
Source File: BaseDiskCache.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheDir          Directory for file caching
 * @param reserveCacheDir   null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
 * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
 *                          Name generator} for cached files
 */
public BaseDiskCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator) {
	if (cacheDir == null) {
		throw new IllegalArgumentException("cacheDir" + ERROR_ARG_NULL);
	}
	if (fileNameGenerator == null) {
		throw new IllegalArgumentException("fileNameGenerator" + ERROR_ARG_NULL);
	}

	this.cacheDir = cacheDir;
	this.reserveCacheDir = reserveCacheDir;
	this.fileNameGenerator = fileNameGenerator;
}
 
Example #22
Source File: ImageLoaderConfiguration$Builder.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public u diskCacheFileNameGenerator(FileNameGenerator filenamegenerator)
{
    if (w != null)
    {
        L.w("diskCache() and diskCacheFileNameGenerator() calls overlap each other", new Object[0]);
    }
    x = filenamegenerator;
    return this;
}
 
Example #23
Source File: LruDiskCache.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheDir          Directory for file caching
 * @param reserveCacheDir   null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
 * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
 *                          Name generator} for cached files. Generated names must match the regex
 *                          <strong>[a-z0-9_-]{1,64}</strong>
 * @param cacheMaxSize      Max cache size in bytes. <b>0</b> means cache size is unlimited.
 * @param cacheMaxFileCount Max file count in cache. <b>0</b> means file count is unlimited.
 * @throws IOException if cache can't be initialized (e.g. "No space left on device")
 */
public LruDiskCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator, long cacheMaxSize,
		int cacheMaxFileCount) throws IOException {
	if (cacheDir == null) {
		throw new IllegalArgumentException("cacheDir" + ERROR_ARG_NULL);
	}
	if (cacheMaxSize < 0) {
		throw new IllegalArgumentException("cacheMaxSize" + ERROR_ARG_NEGATIVE);
	}
	if (cacheMaxFileCount < 0) {
		throw new IllegalArgumentException("cacheMaxFileCount" + ERROR_ARG_NEGATIVE);
	}
	if (fileNameGenerator == null) {
		throw new IllegalArgumentException("fileNameGenerator" + ERROR_ARG_NULL);
	}

	if (cacheMaxSize == 0) {
		cacheMaxSize = Long.MAX_VALUE;
	}
	if (cacheMaxFileCount == 0) {
		cacheMaxFileCount = Integer.MAX_VALUE;
	}

	this.reserveCacheDir = reserveCacheDir;
	this.fileNameGenerator = fileNameGenerator;
	initCache(cacheDir, reserveCacheDir, cacheMaxSize, cacheMaxFileCount);
}
 
Example #24
Source File: LruDiscCache.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public LruDiscCache(File file, FileNameGenerator filenamegenerator, long l, int i)
{
    bufferSize = 32768;
    compressFormat = DEFAULT_COMPRESS_FORMAT;
    compressQuality = 100;
    if (file == null)
    {
        throw new IllegalArgumentException("cacheDir argument must be not null");
    }
    if (l < 0L)
    {
        throw new IllegalArgumentException("cacheMaxSize argument must be positive number");
    }
    if (i < 0)
    {
        throw new IllegalArgumentException("cacheMaxFileCount argument must be positive number");
    }
    if (filenamegenerator == null)
    {
        throw new IllegalArgumentException("fileNameGenerator argument must be not null");
    }
    long l1;
    int j;
    if (l == 0L)
    {
        l1 = 0x7fffffffffffffffL;
    } else
    {
        l1 = l;
    }
    if (i == 0)
    {
        j = 0x7fffffff;
    } else
    {
        j = i;
    }
    fileNameGenerator = filenamegenerator;
    a(file, c, l1, j);
}
 
Example #25
Source File: ImageLoaderConfiguration.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
/**
 * Sets name generator for files cached in disk cache.<br />
 * Default value -
 * {@link com.nostra13.universalimageloader.core.DefaultConfigurationFactory#createFileNameGenerator()
 * DefaultConfigurationFactory.createFileNameGenerator()}
 */
public Builder diskCacheFileNameGenerator(FileNameGenerator fileNameGenerator) {
	if (diskCache != null) {
		L.w(WARNING_OVERLAP_DISK_CACHE_NAME_GENERATOR);
	}

	this.diskCacheFileNameGenerator = fileNameGenerator;
	return this;
}
 
Example #26
Source File: BaseDiskCache.java    From WliveTV with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheDir          Directory for file caching
 * @param reserveCacheDir   null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
 * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
 *                          Name generator} for cached files
 */
public BaseDiskCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator) {
	if (cacheDir == null) {
		throw new IllegalArgumentException("cacheDir" + ERROR_ARG_NULL);
	}
	if (fileNameGenerator == null) {
		throw new IllegalArgumentException("fileNameGenerator" + ERROR_ARG_NULL);
	}

	this.cacheDir = cacheDir;
	this.reserveCacheDir = reserveCacheDir;
	this.fileNameGenerator = fileNameGenerator;
}
 
Example #27
Source File: LruDiskCache.java    From candybar with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheDir          Directory for file caching
 * @param reserveCacheDir   null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
 * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
 *                          Name generator} for cached files. Generated names must match the regex
 *                          <strong>[a-z0-9_-]{1,64}</strong>
 * @param cacheMaxSize      Max cache size in bytes. <b>0</b> means cache size is unlimited.
 * @param cacheMaxFileCount Max file count in cache. <b>0</b> means file count is unlimited.
 * @throws IOException if cache can't be initialized (e.g. "No space left on device")
 */
public LruDiskCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator, long cacheMaxSize,
                    int cacheMaxFileCount) throws IOException {
    if (cacheDir == null) {
        throw new IllegalArgumentException("cacheDir" + ERROR_ARG_NULL);
    }
    if (cacheMaxSize < 0) {
        throw new IllegalArgumentException("cacheMaxSize" + ERROR_ARG_NEGATIVE);
    }
    if (cacheMaxFileCount < 0) {
        throw new IllegalArgumentException("cacheMaxFileCount" + ERROR_ARG_NEGATIVE);
    }
    if (fileNameGenerator == null) {
        throw new IllegalArgumentException("fileNameGenerator" + ERROR_ARG_NULL);
    }

    if (cacheMaxSize == 0) {
        cacheMaxSize = Long.MAX_VALUE;
    }
    if (cacheMaxFileCount == 0) {
        cacheMaxFileCount = Integer.MAX_VALUE;
    }

    this.reserveCacheDir = reserveCacheDir;
    this.fileNameGenerator = fileNameGenerator;
    initCache(cacheDir, reserveCacheDir, cacheMaxSize, cacheMaxFileCount);
}
 
Example #28
Source File: LruDiskCache.java    From WliveTV with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheDir          Directory for file caching
 * @param reserveCacheDir   null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
 * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
 *                          Name generator} for cached files. Generated names must match the regex
 *                          <strong>[a-z0-9_-]{1,64}</strong>
 * @param cacheMaxSize      Max cache size in bytes. <b>0</b> means cache size is unlimited.
 * @param cacheMaxFileCount Max file count in cache. <b>0</b> means file count is unlimited.
 * @throws IOException if cache can't be initialized (e.g. "No space left on device")
 */
public LruDiskCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator, long cacheMaxSize,
		int cacheMaxFileCount) throws IOException {
	if (cacheDir == null) {
		throw new IllegalArgumentException("cacheDir" + ERROR_ARG_NULL);
	}
	if (cacheMaxSize < 0) {
		throw new IllegalArgumentException("cacheMaxSize" + ERROR_ARG_NEGATIVE);
	}
	if (cacheMaxFileCount < 0) {
		throw new IllegalArgumentException("cacheMaxFileCount" + ERROR_ARG_NEGATIVE);
	}
	if (fileNameGenerator == null) {
		throw new IllegalArgumentException("fileNameGenerator" + ERROR_ARG_NULL);
	}

	if (cacheMaxSize == 0) {
		cacheMaxSize = Long.MAX_VALUE;
	}
	if (cacheMaxFileCount == 0) {
		cacheMaxFileCount = Integer.MAX_VALUE;
	}

	this.reserveCacheDir = reserveCacheDir;
	this.fileNameGenerator = fileNameGenerator;
	initCache(cacheDir, reserveCacheDir, cacheMaxSize, cacheMaxFileCount);
}
 
Example #29
Source File: ImageLoaderConfiguration.java    From WliveTV with Apache License 2.0 5 votes vote down vote up
/**
 * Sets name generator for files cached in disk cache.<br />
 * Default value -
 * {@link com.nostra13.universalimageloader.core.DefaultConfigurationFactory#createFileNameGenerator()
 * DefaultConfigurationFactory.createFileNameGenerator()}
 */
public Builder diskCacheFileNameGenerator(FileNameGenerator fileNameGenerator) {
	if (diskCache != null) {
		L.w(WARNING_OVERLAP_DISK_CACHE_NAME_GENERATOR);
	}

	this.diskCacheFileNameGenerator = fileNameGenerator;
	return this;
}
 
Example #30
Source File: ImageLoaderConfiguration.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
 * Sets name generator for files cached in disk cache.<br />
 * Default value -
 * {@link com.nostra13.universalimageloader.core.DefaultConfigurationFactory#createFileNameGenerator()
 * DefaultConfigurationFactory.createFileNameGenerator()}
 */
public Builder diskCacheFileNameGenerator(FileNameGenerator fileNameGenerator) {
	if (diskCache != null) {
		L.w(WARNING_OVERLAP_DISK_CACHE_NAME_GENERATOR);
	}

	this.diskCacheFileNameGenerator = fileNameGenerator;
	return this;
}