2014-07-03 07:48:39 +02:00
|
|
|
/*
|
|
|
|
* Twidere - Twitter client for Android
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.mariotaku.twidere.app;
|
|
|
|
|
|
|
|
import android.content.ComponentName;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.SharedPreferences;
|
2015-03-26 10:32:27 +01:00
|
|
|
import android.content.SharedPreferences.Editor;
|
2014-07-03 07:48:39 +02:00
|
|
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
|
|
import android.database.sqlite.SQLiteOpenHelper;
|
|
|
|
import android.os.AsyncTask;
|
|
|
|
import android.os.Handler;
|
2015-03-24 16:40:47 +01:00
|
|
|
import android.support.annotation.NonNull;
|
2015-01-19 18:46:14 +01:00
|
|
|
import android.support.multidex.MultiDexApplication;
|
2014-07-03 07:48:39 +02:00
|
|
|
|
|
|
|
import com.nostra13.universalimageloader.cache.disc.DiskCache;
|
|
|
|
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;
|
|
|
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
|
|
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
|
|
|
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
|
|
|
|
import com.nostra13.universalimageloader.core.download.ImageDownloader;
|
|
|
|
import com.nostra13.universalimageloader.utils.L;
|
2015-05-08 21:46:58 +02:00
|
|
|
import com.squareup.okhttp.internal.Network;
|
2014-12-07 16:13:07 +01:00
|
|
|
import com.squareup.otto.Bus;
|
2014-07-03 07:48:39 +02:00
|
|
|
|
|
|
|
import org.mariotaku.twidere.Constants;
|
2015-03-30 08:08:17 +02:00
|
|
|
import org.mariotaku.twidere.activity.AssistLauncherActivity;
|
2014-07-03 07:48:39 +02:00
|
|
|
import org.mariotaku.twidere.activity.MainActivity;
|
|
|
|
import org.mariotaku.twidere.activity.MainHondaJOJOActivity;
|
|
|
|
import org.mariotaku.twidere.service.RefreshService;
|
|
|
|
import org.mariotaku.twidere.util.AsyncTaskManager;
|
|
|
|
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
2015-04-12 18:37:54 +02:00
|
|
|
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
2015-03-22 18:06:25 +01:00
|
|
|
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
2014-07-03 07:48:39 +02:00
|
|
|
import org.mariotaku.twidere.util.MultiSelectManager;
|
2015-03-27 17:50:18 +01:00
|
|
|
import org.mariotaku.twidere.util.ReadStateManager;
|
2014-07-03 07:48:39 +02:00
|
|
|
import org.mariotaku.twidere.util.StrictModeUtils;
|
2015-04-11 23:16:13 +02:00
|
|
|
import org.mariotaku.twidere.util.UserAgentUtils;
|
2015-04-24 08:14:33 +02:00
|
|
|
import org.mariotaku.twidere.util.UserColorNameManager;
|
2014-07-03 07:48:39 +02:00
|
|
|
import org.mariotaku.twidere.util.Utils;
|
2015-03-22 18:06:25 +01:00
|
|
|
import org.mariotaku.twidere.util.VideoLoader;
|
2014-07-03 07:48:39 +02:00
|
|
|
import org.mariotaku.twidere.util.content.TwidereSQLiteOpenHelper;
|
|
|
|
import org.mariotaku.twidere.util.imageloader.TwidereImageDownloader;
|
|
|
|
import org.mariotaku.twidere.util.imageloader.URLFileNameGenerator;
|
|
|
|
import org.mariotaku.twidere.util.net.TwidereHostAddressResolver;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
2015-03-04 09:02:32 +01:00
|
|
|
import edu.tsinghua.spice.SpiceService;
|
2014-09-20 07:33:27 +02:00
|
|
|
import edu.ucdavis.earlybird.UCDService;
|
|
|
|
|
|
|
|
import static org.mariotaku.twidere.util.Utils.getBestCacheDir;
|
|
|
|
import static org.mariotaku.twidere.util.Utils.getInternalCacheDir;
|
|
|
|
import static org.mariotaku.twidere.util.Utils.initAccountColor;
|
|
|
|
import static org.mariotaku.twidere.util.Utils.startRefreshServiceIfNeeded;
|
2015-03-26 10:32:27 +01:00
|
|
|
import static org.mariotaku.twidere.util.Utils.startUsageStatisticsServiceIfNeeded;
|
2014-09-20 07:33:27 +02:00
|
|
|
|
2015-01-19 18:46:14 +01:00
|
|
|
public class TwidereApplication extends MultiDexApplication implements Constants,
|
|
|
|
OnSharedPreferenceChangeListener {
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2015-03-30 18:32:50 +02:00
|
|
|
private static final String KEY_UCD_DATA_PROFILING = "ucd_data_profiling";
|
|
|
|
private static final String KEY_SPICE_DATA_PROFILING = "spice_data_profiling";
|
2015-04-13 18:34:10 +02:00
|
|
|
private static final String KEY_KEYBOARD_SHORTCUT_INITIALIZED = "keyboard_shortcut_initialized";
|
2015-03-30 18:32:50 +02:00
|
|
|
|
2014-09-20 07:33:27 +02:00
|
|
|
private Handler mHandler;
|
2015-03-22 18:06:25 +01:00
|
|
|
private MediaLoaderWrapper mMediaLoaderWrapper;
|
2014-09-20 07:33:27 +02:00
|
|
|
private ImageLoader mImageLoader;
|
|
|
|
private AsyncTaskManager mAsyncTaskManager;
|
|
|
|
private SharedPreferences mPreferences;
|
|
|
|
private AsyncTwitterWrapper mTwitterWrapper;
|
|
|
|
private MultiSelectManager mMultiSelectManager;
|
|
|
|
private TwidereImageDownloader mImageDownloader, mFullImageDownloader;
|
|
|
|
private DiskCache mDiskCache, mFullDiskCache;
|
|
|
|
private SQLiteOpenHelper mSQLiteOpenHelper;
|
2015-05-08 21:46:58 +02:00
|
|
|
private Network mNetwork;
|
2014-09-20 07:33:27 +02:00
|
|
|
private SQLiteDatabase mDatabase;
|
2014-12-07 16:13:07 +01:00
|
|
|
private Bus mMessageBus;
|
2015-03-22 18:06:25 +01:00
|
|
|
private VideoLoader mVideoLoader;
|
2015-03-27 17:50:18 +01:00
|
|
|
private ReadStateManager mReadStateManager;
|
2015-04-12 18:37:54 +02:00
|
|
|
private KeyboardShortcutsHandler mKeyboardShortcutsHandler;
|
2015-04-24 08:14:33 +02:00
|
|
|
private UserColorNameManager mUserColorNameManager;
|
2014-09-20 07:33:27 +02:00
|
|
|
|
2015-04-11 23:16:13 +02:00
|
|
|
private String mDefaultUserAgent;
|
|
|
|
|
2015-04-24 08:14:33 +02:00
|
|
|
@NonNull
|
|
|
|
public static TwidereApplication getInstance(@NonNull final Context context) {
|
|
|
|
return (TwidereApplication) context.getApplicationContext();
|
|
|
|
}
|
|
|
|
|
2014-09-20 07:33:27 +02:00
|
|
|
public AsyncTaskManager getAsyncTaskManager() {
|
|
|
|
if (mAsyncTaskManager != null) return mAsyncTaskManager;
|
|
|
|
return mAsyncTaskManager = AsyncTaskManager.getInstance();
|
|
|
|
}
|
|
|
|
|
2015-04-11 23:16:13 +02:00
|
|
|
public String getDefaultUserAgent() {
|
|
|
|
return mDefaultUserAgent;
|
|
|
|
}
|
|
|
|
|
2014-09-20 07:33:27 +02:00
|
|
|
public DiskCache getDiskCache() {
|
|
|
|
if (mDiskCache != null) return mDiskCache;
|
|
|
|
return mDiskCache = createDiskCache(DIR_NAME_IMAGE_CACHE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public DiskCache getFullDiskCache() {
|
|
|
|
if (mFullDiskCache != null) return mFullDiskCache;
|
|
|
|
return mFullDiskCache = createDiskCache(DIR_NAME_FULL_IMAGE_CACHE);
|
|
|
|
}
|
|
|
|
|
2015-04-24 08:14:33 +02:00
|
|
|
public UserColorNameManager getUserColorNameManager() {
|
|
|
|
if (mUserColorNameManager != null) return mUserColorNameManager;
|
|
|
|
return mUserColorNameManager = new UserColorNameManager(this);
|
|
|
|
}
|
|
|
|
|
2014-09-20 07:33:27 +02:00
|
|
|
public ImageDownloader getFullImageDownloader() {
|
|
|
|
if (mFullImageDownloader != null) return mFullImageDownloader;
|
2015-04-07 17:43:03 +02:00
|
|
|
return mFullImageDownloader = new TwidereImageDownloader(this, true, true);
|
2014-09-20 07:33:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Handler getHandler() {
|
|
|
|
return mHandler;
|
|
|
|
}
|
|
|
|
|
2015-05-08 21:46:58 +02:00
|
|
|
public Network getNetwork() {
|
|
|
|
if (mNetwork != null) return mNetwork;
|
|
|
|
return mNetwork = new TwidereHostAddressResolver(this);
|
2014-09-20 07:33:27 +02:00
|
|
|
}
|
|
|
|
|
2015-03-27 17:50:18 +01:00
|
|
|
public ReadStateManager getReadStateManager() {
|
|
|
|
if (mReadStateManager != null) return mReadStateManager;
|
|
|
|
return mReadStateManager = new ReadStateManager(this);
|
|
|
|
}
|
|
|
|
|
2015-04-12 18:37:54 +02:00
|
|
|
public KeyboardShortcutsHandler getKeyboardShortcutsHandler() {
|
|
|
|
if (mKeyboardShortcutsHandler != null) return mKeyboardShortcutsHandler;
|
|
|
|
mKeyboardShortcutsHandler = new KeyboardShortcutsHandler(this);
|
2015-04-13 18:34:10 +02:00
|
|
|
final SharedPreferences preferences = getSharedPreferences();
|
2015-04-24 08:14:33 +02:00
|
|
|
if (!preferences.getBoolean(KEY_KEYBOARD_SHORTCUT_INITIALIZED, false)) {
|
2015-04-12 18:37:54 +02:00
|
|
|
mKeyboardShortcutsHandler.reset();
|
2015-04-21 05:29:05 +02:00
|
|
|
preferences.edit().putBoolean(KEY_KEYBOARD_SHORTCUT_INITIALIZED, true).apply();
|
2015-04-12 18:37:54 +02:00
|
|
|
}
|
|
|
|
return mKeyboardShortcutsHandler;
|
|
|
|
}
|
|
|
|
|
2014-09-20 07:33:27 +02:00
|
|
|
public ImageDownloader getImageDownloader() {
|
|
|
|
if (mImageDownloader != null) return mImageDownloader;
|
2015-04-07 17:43:03 +02:00
|
|
|
return mImageDownloader = new TwidereImageDownloader(this, false, true);
|
2014-09-20 07:33:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ImageLoader getImageLoader() {
|
|
|
|
if (mImageLoader != null) return mImageLoader;
|
|
|
|
final ImageLoader loader = ImageLoader.getInstance();
|
|
|
|
final ImageLoaderConfiguration.Builder cb = new ImageLoaderConfiguration.Builder(this);
|
|
|
|
cb.threadPriority(Thread.NORM_PRIORITY - 2);
|
|
|
|
cb.denyCacheImageMultipleSizesInMemory();
|
|
|
|
cb.tasksProcessingOrder(QueueProcessingType.LIFO);
|
|
|
|
// cb.memoryCache(new ImageMemoryCache(40));
|
|
|
|
cb.diskCache(getDiskCache());
|
|
|
|
cb.imageDownloader(getImageDownloader());
|
|
|
|
L.writeDebugLogs(Utils.isDebugBuild());
|
|
|
|
loader.init(cb.build());
|
|
|
|
return mImageLoader = loader;
|
|
|
|
}
|
|
|
|
|
2015-03-22 18:06:25 +01:00
|
|
|
public VideoLoader getVideoLoader() {
|
|
|
|
if (mVideoLoader != null) return mVideoLoader;
|
|
|
|
final VideoLoader loader = new VideoLoader(this);
|
|
|
|
return mVideoLoader = loader;
|
|
|
|
}
|
|
|
|
|
2015-03-30 18:32:50 +02:00
|
|
|
public MediaLoaderWrapper getMediaLoaderWrapper() {
|
2015-03-22 18:06:25 +01:00
|
|
|
if (mMediaLoaderWrapper != null) return mMediaLoaderWrapper;
|
|
|
|
return mMediaLoaderWrapper = new MediaLoaderWrapper(getImageLoader(), getVideoLoader());
|
2014-09-20 07:33:27 +02:00
|
|
|
}
|
|
|
|
|
2015-01-19 18:46:14 +01:00
|
|
|
public Bus getMessageBus() {
|
|
|
|
return mMessageBus;
|
|
|
|
}
|
|
|
|
|
2014-09-20 07:33:27 +02:00
|
|
|
public MultiSelectManager getMultiSelectManager() {
|
|
|
|
if (mMultiSelectManager != null) return mMultiSelectManager;
|
|
|
|
return mMultiSelectManager = new MultiSelectManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
public SQLiteDatabase getSQLiteDatabase() {
|
|
|
|
if (mDatabase != null) return mDatabase;
|
|
|
|
StrictModeUtils.checkDiskIO();
|
|
|
|
return mDatabase = getSQLiteOpenHelper().getWritableDatabase();
|
|
|
|
}
|
|
|
|
|
|
|
|
public SQLiteOpenHelper getSQLiteOpenHelper() {
|
|
|
|
if (mSQLiteOpenHelper != null) return mSQLiteOpenHelper;
|
|
|
|
return mSQLiteOpenHelper = new TwidereSQLiteOpenHelper(this, DATABASES_NAME, DATABASES_VERSION);
|
|
|
|
}
|
|
|
|
|
|
|
|
public AsyncTwitterWrapper getTwitterWrapper() {
|
|
|
|
if (mTwitterWrapper != null) return mTwitterWrapper;
|
2015-04-24 08:14:33 +02:00
|
|
|
return mTwitterWrapper = new AsyncTwitterWrapper(this);
|
2014-09-20 07:33:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate() {
|
|
|
|
if (Utils.isDebugBuild()) {
|
|
|
|
StrictModeUtils.detectAllVmPolicy();
|
|
|
|
}
|
|
|
|
super.onCreate();
|
2015-04-11 23:16:13 +02:00
|
|
|
mDefaultUserAgent = UserAgentUtils.getDefaultUserAgentString(this);
|
2014-09-20 07:33:27 +02:00
|
|
|
mHandler = new Handler();
|
2014-12-07 16:13:07 +01:00
|
|
|
mMessageBus = new Bus();
|
2014-09-20 07:33:27 +02:00
|
|
|
initializeAsyncTask();
|
|
|
|
initAccountColor(this);
|
|
|
|
|
|
|
|
final PackageManager pm = getPackageManager();
|
|
|
|
final ComponentName main = new ComponentName(this, MainActivity.class);
|
|
|
|
final ComponentName main2 = new ComponentName(this, MainHondaJOJOActivity.class);
|
|
|
|
final boolean mainDisabled = pm.getComponentEnabledSetting(main) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
|
|
|
|
final boolean main2Disabled = pm.getComponentEnabledSetting(main2) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
|
2015-03-29 15:07:31 +02:00
|
|
|
final boolean noEntry = mainDisabled && main2Disabled;
|
|
|
|
if (noEntry) {
|
2014-09-20 07:33:27 +02:00
|
|
|
pm.setComponentEnabledSetting(main, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
|
|
|
PackageManager.DONT_KILL_APP);
|
|
|
|
} else if (!mainDisabled) {
|
|
|
|
pm.setComponentEnabledSetting(main2, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
|
|
|
PackageManager.DONT_KILL_APP);
|
|
|
|
}
|
2015-03-30 08:08:17 +02:00
|
|
|
if (!Utils.isComposeNowSupported()) {
|
|
|
|
final ComponentName assist = new ComponentName(this, AssistLauncherActivity.class);
|
|
|
|
pm.setComponentEnabledSetting(assist, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
|
|
|
PackageManager.DONT_KILL_APP);
|
|
|
|
}
|
2014-09-20 07:33:27 +02:00
|
|
|
|
2015-03-26 10:32:27 +01:00
|
|
|
migrateUsageStatisticsPreferences();
|
|
|
|
startUsageStatisticsServiceIfNeeded(this);
|
2014-09-20 07:33:27 +02:00
|
|
|
startRefreshServiceIfNeeded(this);
|
2015-04-11 23:16:13 +02:00
|
|
|
|
|
|
|
reloadConnectivitySettings();
|
2014-09-20 07:33:27 +02:00
|
|
|
}
|
|
|
|
|
2015-03-26 10:32:27 +01:00
|
|
|
private void migrateUsageStatisticsPreferences() {
|
2015-04-13 18:34:10 +02:00
|
|
|
final SharedPreferences preferences = getSharedPreferences();
|
|
|
|
final boolean hasUsageStatistics = preferences.contains(KEY_USAGE_STATISTICS);
|
2015-03-26 11:43:05 +01:00
|
|
|
if (hasUsageStatistics) return;
|
2015-04-13 18:34:10 +02:00
|
|
|
if (preferences.contains(KEY_UCD_DATA_PROFILING) || preferences.contains(KEY_SPICE_DATA_PROFILING)) {
|
|
|
|
final boolean prevUsageEnabled = preferences.getBoolean(KEY_UCD_DATA_PROFILING, false)
|
|
|
|
|| preferences.getBoolean(KEY_SPICE_DATA_PROFILING, false);
|
|
|
|
final Editor editor = preferences.edit();
|
2015-03-26 10:32:27 +01:00
|
|
|
editor.putBoolean(KEY_USAGE_STATISTICS, prevUsageEnabled);
|
|
|
|
editor.remove(KEY_UCD_DATA_PROFILING);
|
|
|
|
editor.remove(KEY_SPICE_DATA_PROFILING);
|
|
|
|
editor.apply();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-13 18:34:10 +02:00
|
|
|
private SharedPreferences getSharedPreferences() {
|
|
|
|
if (mPreferences != null) return mPreferences;
|
|
|
|
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
|
|
|
|
mPreferences.registerOnSharedPreferenceChangeListener(this);
|
|
|
|
return mPreferences;
|
|
|
|
}
|
|
|
|
|
2014-09-20 07:33:27 +02:00
|
|
|
@Override
|
|
|
|
public void onLowMemory() {
|
2015-03-22 18:06:25 +01:00
|
|
|
if (mMediaLoaderWrapper != null) {
|
|
|
|
mMediaLoaderWrapper.clearMemoryCache();
|
2014-09-20 07:33:27 +02:00
|
|
|
}
|
|
|
|
super.onLowMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSharedPreferenceChanged(final SharedPreferences preferences, final String key) {
|
|
|
|
if (KEY_REFRESH_INTERVAL.equals(key)) {
|
|
|
|
stopService(new Intent(this, RefreshService.class));
|
|
|
|
startRefreshServiceIfNeeded(this);
|
|
|
|
} else if (KEY_ENABLE_PROXY.equals(key) || KEY_CONNECTION_TIMEOUT.equals(key) || KEY_PROXY_HOST.equals(key)
|
|
|
|
|| KEY_PROXY_PORT.equals(key) || KEY_FAST_IMAGE_LOADING.equals(key)) {
|
|
|
|
reloadConnectivitySettings();
|
2015-03-25 14:20:51 +01:00
|
|
|
} else if (KEY_USAGE_STATISTICS.equals(key)) {
|
2014-09-20 07:33:27 +02:00
|
|
|
stopService(new Intent(this, UCDService.class));
|
2015-03-25 14:20:51 +01:00
|
|
|
//spice
|
2015-03-04 09:02:32 +01:00
|
|
|
stopService(new Intent(this, SpiceService.class));
|
2015-03-26 10:32:27 +01:00
|
|
|
startUsageStatisticsServiceIfNeeded(this);
|
2015-03-25 14:20:51 +01:00
|
|
|
//end
|
|
|
|
} else if (KEY_CONSUMER_KEY.equals(key) || KEY_CONSUMER_SECRET.equals(key) || KEY_API_URL_FORMAT.equals(key)
|
2015-04-07 17:43:03 +02:00
|
|
|
|| KEY_AUTH_TYPE.equals(key) || KEY_SAME_OAUTH_SIGNING_URL.equals(key) || KEY_THUMBOR_ENABLED.equals(key)
|
|
|
|
|| KEY_THUMBOR_ADDRESS.equals(key) || KEY_THUMBOR_SECURITY_KEY.equals(key)) {
|
2014-09-20 07:33:27 +02:00
|
|
|
final SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
editor.putLong(KEY_API_LAST_CHANGE, System.currentTimeMillis());
|
|
|
|
editor.apply();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void reloadConnectivitySettings() {
|
|
|
|
if (mImageDownloader != null) {
|
|
|
|
mImageDownloader.reloadConnectivitySettings();
|
|
|
|
}
|
2015-03-30 18:32:50 +02:00
|
|
|
if (mFullImageDownloader != null) {
|
|
|
|
mFullImageDownloader.reloadConnectivitySettings();
|
|
|
|
}
|
2014-09-20 07:33:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private DiskCache createDiskCache(final String dirName) {
|
|
|
|
final File cacheDir = getBestCacheDir(this, dirName);
|
|
|
|
final File fallbackCacheDir = getInternalCacheDir(this, dirName);
|
|
|
|
// final LruDiscCache discCache = new LruDiscCache(cacheDir, new URLFileNameGenerator(), 384 *
|
|
|
|
// 1024 * 1024);
|
|
|
|
// discCache.setReserveCacheDir(fallbackCacheDir);
|
|
|
|
// return discCache;
|
|
|
|
return new UnlimitedDiscCache(cacheDir, fallbackCacheDir, new URLFileNameGenerator());
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initializeAsyncTask() {
|
|
|
|
// AsyncTask class needs to be loaded in UI thread.
|
|
|
|
// So we load it here to comply the rule.
|
|
|
|
try {
|
|
|
|
Class.forName(AsyncTask.class.getName());
|
2015-01-14 09:47:51 +01:00
|
|
|
} catch (final ClassNotFoundException ignore) {
|
2014-09-20 07:33:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-03 07:48:39 +02:00
|
|
|
}
|