Java tutorial
/** * Copyright 2014 Daum Kakao Corp. * * Redistribution and modification in source or binary forms are not permitted without specific prior written permission. * * 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. */ package com.lime.mypol.application; import android.app.Application; import android.content.Context; import android.graphics.Bitmap; import android.support.v4.util.LruCache; import com.android.volley.RequestQueue; import com.android.volley.toolbox.ImageLoader; import com.android.volley.toolbox.Volley; import com.kakao.Session; import com.kakao.helper.SystemInfo; import com.lime.mypol.R; import com.lime.mypol.manager.DatabaseManager; import com.lime.mypol.manager.NetworkManager; import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; import com.nostra13.universalimageloader.core.assist.QueueProcessingType; import com.nostra13.universalimageloader.core.download.HttpClientImageDownloader; /** * ? ? ? ? ??. * ? ? . * * @author MJ */ public class GlobalApplication extends Application { private static Context mContext; @Override public void onCreate() { super.onCreate(); mContext = this; Session.initialize(this); SystemInfo.initialize(); initImageLoader(this); initDatabase(this); } private void initDatabase(Context context) { DatabaseManager.getInstance(context).open(); } public static Context getContext() { return mContext; } public static void initImageLoader(Context context) { // This configuration tuning is custom. You can tune every option, you may tune some of them, // or you can create default configuration by // ImageLoaderConfiguration.createDefault(this); // method. DisplayImageOptions options = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.ic_empty_photo).showImageForEmptyUri(R.drawable.ic_empty_photo) .showImageOnFail(R.drawable.ic_empty_photo).cacheInMemory(true).cacheOnDisc(true) .considerExifParams(true).build(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .threadPriority(Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory() .discCacheFileNameGenerator(new Md5FileNameGenerator()) .tasksProcessingOrder(QueueProcessingType.LIFO).writeDebugLogs() // Remove for release app .defaultDisplayImageOptions(options) .imageDownloader( new HttpClientImageDownloader(context, NetworkManager.getInstance().getHttpClient())) .build(); com.nostra13.universalimageloader.core.ImageLoader.getInstance().init(config); } }