blob: 518eff8202f6fa46e064d44eaa93d8a210119952 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package uk.co.blatech.blaupload;
import android.app.Application;
import android.content.Context;
import android.os.Environment;
import android.util.Log;
import java.io.File;
import uk.co.senab.bitmapcache.BitmapLruCache;
public class BlauploadApplication extends Application {
private BitmapLruCache mCache;
@Override
public void onCreate() {
super.onCreate();
File cacheLocation;
// If we have external storage use it for the disk cache. Otherwise we use
// the cache dir
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
cacheLocation = new File(
Environment.getExternalStorageDirectory() + "/blaupload");
} else {
cacheLocation = new File(getFilesDir() + "/blaupload");
}
cacheLocation.mkdirs();
BitmapLruCache.Builder builder = new BitmapLruCache.Builder(this);
builder.setMemoryCacheEnabled(true).setMemoryCacheMaxSizeUsingHeapSize();
builder.setDiskCacheEnabled(true).setDiskCacheLocation(cacheLocation);
mCache = builder.build();
Log.d(BlauploadApplication.class.toString(), cacheLocation.toString());
}
public BitmapLruCache getBitmapCache() {
return mCache;
}
public static BlauploadApplication getApplication(Context context) {
return (BlauploadApplication) context.getApplicationContext();
}
}
|