Below I have posted my application class.I have tried to add this below universal image loader code
into Appcontroller.java
class.
// UNIVERSAL IMAGE LOADER SETUP
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
.cacheOnDisc(true).cacheInMemory(true)
.imageScaleType(ImageScaleType.EXACTLY)
.displayer(new FadeInBitmapDisplayer(300)).build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
getApplicationContext())
.defaultDisplayImageOptions(defaultOptions)
.memoryCache(new WeakMemoryCache())
.discCacheSize(100 * 1024 * 1024).build();
ImageLoader.getInstance().init(config); ------> Compile error occurred here.because of imageloader import.
// END - UNIVERSAL IMAGE LOADER SETUP
But I couldn't add this.Because In volley image loader import is different to that universal image loader.
Imports:
Volley ImageLoader - import com.android.volley.toolbox.ImageLoader;
Universal ImageLoader -import com.nostra13.universalimageloader.core.ImageLoader;
If I add Universal Image Loader inside Appcontroller, I am getting compile error in this line ImageLoader.getInstance().init(config);
.
Because Two ImageLoader imports are differnet.
AppController .java:(Application Class)
import com.android.volley.toolbox.ImageLoader;
public class AppController extends Application {
private static int pendingNotificationsCount = 0;
public static final String TAG = AppController.class.getSimpleName();
private RequestQueue mRequestQueue;
private ImageLoader mImageLoader;
LruBitmapCache mLruBitmapCache;
private static AppController mInstance;
@Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
mInstance = this;
}
public static synchronized AppController getInstance() {
return mInstance;
}
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}
return mRequestQueue;
}
public ImageLoader getImageLoader() {
getRequestQueue();
if (mImageLoader == null) {
getLruBitmapCache();
mImageLoader = new ImageLoader(this.mRequestQueue, mLruBitmapCache);
}
return this.mImageLoader;
}
public LruBitmapCache getLruBitmapCache() {
if (mLruBitmapCache == null)
mLruBitmapCache = new LruBitmapCache();
return this.mLruBitmapCache;
}
public void addToRequestQueue(Request<String> req, String tag) {
req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
req.setShouldCache(false);
getRequestQueue().add(req);
}
public void addToRequestQueue(JsonObjectRequest req) {
req.setTag(TAG);
getRequestQueue().add(req);
}
public void cancelPendingRequests(Object tag) {
if (mRequestQueue != null) {
mRequestQueue.cancelAll(tag);
}
}
public static int getPendingNotificationsCount() {
return pendingNotificationsCount;
}
public static void setPendingNotificationsCount(int pendingNotifications) {
pendingNotificationsCount = pendingNotifications;
}
}