Back to project page Joetz-Android-V2.
The source code is released under:
GNU General Public License
If you think the Android project Joetz-Android-V2 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.example.jens.myapplication.sam; /* www. ja v a 2 s .co m*/ import android.app.Application; import android.content.Context; import android.content.Intent; import com.example.jens.myapplication.apimanager.manager.ActivityManager; import com.example.jens.myapplication.apimanager.manager.CampManager; import com.example.jens.myapplication.apimanager.manager.ImageManager; import com.example.jens.myapplication.apimanager.manager.LoginManager; import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; import com.nostra13.universalimageloader.core.assist.QueueProcessingType; /** * The application class for the Joetz application<br/> * Holds all the managers to manage resources of the application */ public class JoetzApplication extends Application { private static JoetzApplication context; private LoginManager loginManager; private CampManager campManager; private ImageManager imageManager; private ActivityManager activityManager; @Override public void onCreate() { super.onCreate(); this.context = this; initImageLoader(getApplicationContext()); } public LoginManager getLoginManager(){ if(loginManager == null){ loginManager = new LoginManager(this); } return loginManager; } public CampManager getCampManager(){ if(campManager == null){ campManager = new CampManager(); } return campManager; } public ImageManager getImageManager(){ if(imageManager == null){ imageManager = new ImageManager(); } return imageManager; } public ActivityManager getActivityManager(){ if(activityManager == null){ activityManager = new ActivityManager(); } return activityManager; } /** * Get the application * @return the application object */ public static JoetzApplication getContext(){ return context; } 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. ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .threadPriority(Thread.NORM_PRIORITY - 2) .denyCacheImageMultipleSizesInMemory() .diskCacheFileNameGenerator(new Md5FileNameGenerator()) .diskCacheSize(50 * 1024 * 1024) // 50 Mb .tasksProcessingOrder(QueueProcessingType.LIFO) .writeDebugLogs() // Remove for release app .build(); // Initialize ImageLoader with configuration. ImageLoader.getInstance().init(config); } /** * Restart the application if the user is not logged in. * Can be used when loading activities which require the user to be logged in, but due to * recreation of the application object, the user is no longer logged in. */ public void restartIfLoggedOut(){ if(!getLoginManager().isLoggedIn()){ restartApplication(); } } /** * Perform a restart of the application */ public void restartApplication(){ Intent i = getBaseContext().getPackageManager() .getLaunchIntentForPackage( getBaseContext().getPackageName() ); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); } }