-/* ownCloud Android client application
- * Copyright (C) 2012-2014 ownCloud Inc.
+/**
+ * ownCloud Android client application
+ *
+ * Copyright (C) 2015 ownCloud Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
import java.io.InputStream;
import java.io.OutputStream;
-import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
-import android.util.Log;
import com.jakewharton.disklrucache.DiskLruCache;
import com.owncloud.android.BuildConfig;
private static final String TAG = DiskLruImageCache.class.getSimpleName();
- public DiskLruImageCache( Context context,String uniqueName, int diskCacheSize,
- CompressFormat compressFormat, int quality ) throws IOException {
- final File diskCacheDir = getDiskCacheDir(context, uniqueName );
+ //public DiskLruImageCache( Context context,String uniqueName, int diskCacheSize,
+ public DiskLruImageCache(
+ File diskCacheDir, int diskCacheSize, CompressFormat compressFormat, int quality
+ ) throws IOException {
+
mDiskCache = DiskLruCache.open(
diskCacheDir, CACHE_VERSION, VALUE_COUNT, diskCacheSize
);
}
}
- private File getDiskCacheDir(Context context, String uniqueName) {
-
- // Check if media is mounted or storage is built-in, if so, try and use external cache dir
- // otherwise use internal cache dir
- final String cachePath = context.getExternalCacheDir().getPath();
-
- Log_OC.d(TAG, "create dir: " + cachePath + File.separator + uniqueName);
-
- return new File(cachePath + File.separator + uniqueName);
- }
-
public void put( String key, Bitmap data ) {
DiskLruCache.Editor editor = null;
}
final InputStream in = snapshot.getInputStream( 0 );
if ( in != null ) {
- final BufferedInputStream buffIn =
+ final BufferedInputStream buffIn =
new BufferedInputStream( in, IO_BUFFER_SIZE );
- bitmap = BitmapFactory.decodeStream( buffIn );
- }
+ bitmap = BitmapFactory.decodeStream( buffIn );
+ }
} catch ( IOException e ) {
e.printStackTrace();
} finally {
e.printStackTrace();
}
}
+
+ public void setMaxSize(long maxSize){
+ mDiskCache.setMaxSize(maxSize);
+ }
+
+ public long getMaxSize(){
+ return mDiskCache.getMaxSize();
+ }
}
\ No newline at end of file