@Override
public void onCreate() {
super.onCreate();
sThis = this;
if(!BuildConfig.GIT_BRANCH.equals("local"))
Fabric.with(this, new Crashlytics());
sDefSystemLanguage = LocaleUtils.getCurrentAsString();
LeakCanary.install(this);
Foreground.init(this);
Constants.DEBUG_ENABLED = false;
int versionCode = 0;
try {
String packageName = getPackageName();
PackageInfo packageInfo = getPackageManager().getPackageInfo(packageName, 0);
int flags = packageInfo.applicationInfo.flags;
versionCode = packageInfo.versionCode;
Constants.DEBUG_ENABLED = (flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
//initialise logging
if (Constants.DEBUG_ENABLED) {
Timber.plant(new Timber.DebugTree());
}
PopcornUpdater.getInstance(this, this).checkUpdates(false);
if(VersionUtils.isUsingCorrectBuild()) {
TorrentService.start(this);
}
File path = new File(PrefUtils.get(this, Prefs.STORAGE_LOCATION, StorageUtils.getIdealCacheDirectory(this).toString()));
File directory = new File(path, "/torrents/");
if (PrefUtils.get(this, Prefs.REMOVE_CACHE, true)) {
FileUtils.recursiveDelete(directory);
FileUtils.recursiveDelete(new File(path + "/subs"));
} else {
File statusFile = new File(directory, "status.json");
statusFile.delete();
}
Timber.d("StorageLocations: " + StorageUtils.getAllStorageLocations());
Timber.i("Chosen cache location: " + directory);
if (PrefUtils.get(this, Prefs.INSTALLED_VERSION, 0) < versionCode) {
PrefUtils.save(this, Prefs.INSTALLED_VERSION, versionCode);
FileUtils.recursiveDelete(new File(StorageUtils.getIdealCacheDirectory(this) + "/backend"));
}
Picasso.Builder builder = new Picasso.Builder(getAppContext());
OkHttpDownloader downloader = new OkHttpDownloader(getHttpClient());
builder.downloader(downloader);
Picasso.setSingletonInstance(builder.build());
}
PopcornApplication.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:popcorn-android
作者:
评论列表
文章目录