Back to project page Avatar.
The source code is released under:
GNU General Public License
If you think the Android project Avatar listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.syw.avatar; //w ww . jav a2 s . c om import java.io.File; import android.app.Application; import android.content.Context; import android.graphics.Bitmap; import android.os.Build; import android.os.StrictMode; import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache; 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; @SuppressWarnings("unused") public class AvatarApplication extends Application { @Override public void onCreate() { if (Constants.DEVELOPER_MODE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDialog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyDeath().build()); } super.onCreate(); initImageLoader(getApplicationContext()); preventCachedMediaScaned(); } public static void initImageLoader(Context context) { DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.defaultpic) .showImageForEmptyUri(R.drawable.no_photo) .showImageOnFail(R.drawable.fail) .cacheInMemory(true) .cacheOnDisk(true) .considerExifParams(true) .bitmapConfig(Bitmap.Config.RGB_565) .build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .threadPriority(Thread.NORM_PRIORITY - 2) .threadPoolSize(5) .tasksProcessingOrder(QueueProcessingType.LIFO) .defaultDisplayImageOptions(defaultOptions) .build(); // Initialize ImageLoader with configuration. ImageLoader.getInstance().init(config); } private void preventCachedMediaScaned(){ String dirPath = Constants.BasePhotoUrlDiskCached + "/" + ".nomedia"; File file = new File(dirPath); if (file.exists() && file.isDirectory()){ return; } if (file.isFile()){ file.delete(); } file.mkdir(); } @Override public void onLowMemory() { super.onLowMemory(); } @Override public void onTerminate() { super.onTerminate(); } }