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

The following examples show how to use com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator. These examples are extracted from open source projects. 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 Project: candybar   Source File: DefaultConfigurationFactory.java    License: 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 2
Source Project: letv   Source File: LruDiscCache.java    License: 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 3
Source Project: mobile-manager-tool   Source File: DefaultConfigurationFactory.java    License: 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 4
/**
 * 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 Project: WliveTV   Source File: DefaultConfigurationFactory.java    License: 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 6
Source Project: MiBandDecompiled   Source File: BaseDiscCache.java    License: 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 7
/**
 * 默认图片 本地路径缓存
 * 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
/**
 * 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 9
Source Project: candybar   Source File: BaseDiskCache.java    License: 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 Project: candybar   Source File: LruDiskCache.java    License: 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 11
Source Project: candybar   Source File: ImageLoaderConfiguration.java    License: 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 12
Source Project: letv   Source File: BaseDiscCache.java    License: 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 13
Source Project: letv   Source File: ImageLoaderConfiguration.java    License: 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 Project: letv   Source File: DefaultConfigurationFactory.java    License: 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 15
Source Project: aptoide-client   Source File: Aptoide.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Inits nostra13's ImageLoader
 */
private void initImageLoader() {

    DisplayImageOptions options = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisc(true)
            .resetViewBeforeLoading(true)
            .showStubImage(R.drawable.icon_non_available)
            .build();

    FileNameGenerator generator = new FileNameGenerator() {
        @Override
        public String generate(String s) {

            if(s!=null){
                return s.substring(s.lastIndexOf('/') + 1);
            } else {
                return null;
            }
        }
    };

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
            .discCache(new UnlimitedDiscCache(new File(getConfiguration().getPathCacheIcons()), null, generator))
            .imageDownloader(new ImageDownloaderWithPermissions(getContext()))
            .defaultDisplayImageOptions(options)
            .build();

    ImageLoader.getInstance().init(config);
}
 
Example 16
Source Project: mobile-manager-tool   Source File: BaseDiscCache.java    License: 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
 */
public BaseDiscCache(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 17
Source Project: mobile-manager-tool   Source File: LruDiscCache.java    License: 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 18
Source Project: mobile-manager-tool   Source File: ImageLoaderConfiguration.java    License: 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;
}
 
Example 19
Source Project: BigApp_WordPress_Android   Source File: BaseDiskCache.java    License: 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 20
Source Project: BigApp_WordPress_Android   Source File: LruDiskCache.java    License: 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 21
/**
 * 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 22
Source Project: WliveTV   Source File: BaseDiskCache.java    License: 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 23
Source Project: WliveTV   Source File: LruDiskCache.java    License: 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 Project: WliveTV   Source File: ImageLoaderConfiguration.java    License: 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 25
Source Project: MiBandDecompiled   Source File: LruDiscCache.java    License: 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 26
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 27
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 28
/**
 * 构造方法   传入缓存文件夹 以及备用缓存文件夹,缓存文件命名方式
 * @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 29
/**
 * 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 30
/**
 * 设置本地文件缓存器中 缓存文件名生成器
 * 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;
}