use of com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache in project android by testpress.
the class TestpressApplication method initImageLoader.
public static void initImageLoader(Context context) {
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheOnDisk(true).cacheInMemory(true).imageScaleType(ImageScaleType.EXACTLY).displayer(new FadeInBitmapDisplayer(300)).build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).defaultDisplayImageOptions(defaultOptions).memoryCache(new WeakMemoryCache()).diskCacheSize(500 * 1024 * 1024).build();
ImageLoader.getInstance().init(config);
}
use of com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache in project teamward-client by Neamar.
the class LolApplication method onCreate.
@Override
public void onCreate() {
super.onCreate();
// Create default options which will be used for every
// displayImage(...) call if no options will be passed to this method
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheOnDisk(true).bitmapConfig(Bitmap.Config.RGB_565).build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).defaultDisplayImageOptions(defaultOptions).diskCacheFileCount(300).threadPoolSize(5).memoryCache(new WeakMemoryCache()).build();
ImageLoader.getInstance().init(config);
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().permitDiskReads().penaltyLog().penaltyDeath().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
}
// Tracking initialization
final Runnable r = new Runnable() {
public void run() {
identifyOnAmplitude();
identifyOnTrackers();
}
};
Handler handler = new Handler();
handler.post(r);
}
use of com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache in project KenBurnsView by flavioarfaria.
the class FromURLActivity method loadImage.
private void loadImage() {
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
String cacheDirName = "." + getString(R.string.app_name);
cacheDir = new File(Environment.getExternalStorageDirectory(), cacheDirName);
} else {
cacheDir = getCacheDir();
}
if (!cacheDir.exists()) {
cacheDir.mkdirs();
}
config = new ImageLoaderConfiguration.Builder(this).memoryCache(new WeakMemoryCache()).denyCacheImageMultipleSizesInMemory().diskCache(new UnlimitedDiscCache(cacheDir)).threadPoolSize(5).build();
options = new DisplayImageOptions.Builder().bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.IN_SAMPLE_INT).cacheOnDisk(true).cacheInMemory(true).build();
imageLoader.init(config);
imageLoader.displayImage("http://i.imgur.com/gysR4Ee.jpg", mImg, options, this);
}
use of com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache in project JamsMusicPlayer by psaravan.
the class Common method onCreate.
@Override
public void onCreate() {
super.onCreate();
//Application context.
mContext = getApplicationContext();
//SharedPreferences.
mSharedPreferences = this.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
//Init the database.
mDBAccessHelper = new DBAccessHelper(mContext);
//Playback kickstarter.
mPlaybackKickstarter = new PlaybackKickstarter(this.getApplicationContext());
//Picasso.
mPicasso = new Picasso.Builder(mContext).build();
//ImageLoader.
mImageLoader = ImageLoader.getInstance();
mImageLoaderConfiguration = new ImageLoaderConfiguration.Builder(getApplicationContext()).memoryCache(new WeakMemoryCache()).memoryCacheSizePercentage(13).imageDownloader(new ByteArrayUniversalImageLoader(mContext)).build();
mImageLoader.init(mImageLoaderConfiguration);
//Init DisplayImageOptions.
initDisplayImageOptions();
//Log the user into Google Play Music only if the account is currently set up and active.
if (mSharedPreferences.getBoolean("GOOGLE_PLAY_MUSIC_ENABLED", false) == true) {
//Create a temp WebView to retrieve the user agent string.
String userAgentString = "";
if (mSharedPreferences.getBoolean("GOT_USER_AGENT", false) == false) {
WebView webView = new WebView(getApplicationContext());
webView.setVisibility(View.GONE);
webView.loadUrl("http://www.google.com");
userAgentString = webView.getSettings().getUserAgentString();
mSharedPreferences.edit().putBoolean("GOT_USER_AGENT", true).commit();
mSharedPreferences.edit().putString("USER_AGENT", userAgentString).commit();
webView = null;
}
setGMusicClientCalls(GMusicClientCalls.getInstance(getApplicationContext()));
GMusicClientCalls.setWebClientUserAgent(userAgentString);
String accountName = mSharedPreferences.getString("GOOGLE_PLAY_MUSIC_ACCOUNT", "");
//Authenticate with Google.
AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(mContext, false, accountName);
task.execute();
}
}
use of com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache in project CustomViews by AndroidStudy233.
the class MyApplication method initImageLoader.
/**
* 初始化ImageLoader
*/
private void initImageLoader() {
File cacheDir = getCacheDir();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).memoryCacheExtraOptions(480, // max width, max height,即保存的每个缓存文件的最大长宽
800).threadPoolSize(// 线程池内加载的数量
3).threadPriority(// 线程优先级
Thread.NORM_PRIORITY - 1).denyCacheImageMultipleSizesInMemory().memoryCache(new WeakMemoryCache()).memoryCacheSize(// 内存缓存2MB
2 * 1024 * 1024).tasksProcessingOrder(QueueProcessingType.LIFO).diskCache(// 限制缓存时长
new LimitedAgeDiskCache(cacheDir, 7 * 24 * 60 * 60)).diskCacheSize(// 本地缓存50MB
50 * 1024 * 1024).diskCacheFileNameGenerator(// MD5加密名字
new Md5FileNameGenerator()).defaultDisplayImageOptions(// 设置默认选项
DisplayImageOptions.createSimple()).imageDownloader(// connectTimeout (5 s), readTimeout (30 s)超时时间
new BaseImageDownloader(getApplicationContext(), 5 * 1000, 20 * 1000)).build();
// 开始构建
ImageLoader.getInstance().init(config);
}
Aggregations