/*
*
* * Copyright (C) 2012 Ignacio Gonzalez Sainz
* *
* * Holy Week Guide: An android application with the itineraries, images and all information of the brotherhoods Spain's holy week
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
* *
* * Ignacio Gonzalez Sainz
* * Cádiz (Spain)
* * ignacio.glez.s@gmail.com
* *
*
*/
package com.ignaciogs.semanasanta;
import android.app.Application;
import android.content.Context;
import android.graphics.Bitmap;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.cache.memory.MemoryCacheAware;
import com.nostra13.universalimageloader.cache.memory.impl.LRULimitedMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
public class ApplicationSemanaSanta extends Application {
private String nameActiveCity;
private DisplayImageOptions defaultOptionsImage;
public String getNameActiveCity() {
return nameActiveCity;
}
public void setNameActiveCity(String nameActiveCity) {
this.nameActiveCity = nameActiveCity;
}
@Override
public void onCreate() {
initImageLoader(getApplicationContext());
}
private void initImageLoader(Context context) {
//Create default options
defaultOptionsImage = new DisplayImageOptions.Builder()
.cacheInMemory()
.cacheOnDisc()
.build();
int memoryCacheSize = (int) (Runtime.getRuntime().maxMemory() / 8);
MemoryCacheAware<String, Bitmap> memoryCache = new LRULimitedMemoryCache(memoryCacheSize);
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.threadPriority(Thread.NORM_PRIORITY - 2)
.memoryCache(memoryCache)
.denyCacheImageMultipleSizesInMemory()
.discCacheFileNameGenerator(new Md5FileNameGenerator())
.tasksProcessingOrder(QueueProcessingType.LIFO)
.enableLogging()
.defaultDisplayImageOptions(defaultOptionsImage)
.build();
ImageLoader.getInstance().init(config);
}
public DisplayImageOptions getDefaultOptionsImage() {
return defaultOptionsImage;
}
}