mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2025-12-08 19:05:54 +00:00
60 lines
2.0 KiB
Java
60 lines
2.0 KiB
Java
package com.fastaccess;
|
|
|
|
import android.support.annotation.NonNull;
|
|
import android.support.multidex.MultiDexApplication;
|
|
import android.support.v7.preference.PreferenceManager;
|
|
|
|
import com.fastaccess.data.dao.model.Models;
|
|
import com.fastaccess.helper.TypeFaceHelper;
|
|
import com.fastaccess.provider.tasks.notification.NotificationSchedulerJobTask;
|
|
import com.fastaccess.provider.uil.UILProvider;
|
|
|
|
import io.requery.Persistable;
|
|
import io.requery.android.sqlite.DatabaseSource;
|
|
import io.requery.meta.EntityModel;
|
|
import io.requery.rx.RxSupport;
|
|
import io.requery.rx.SingleEntityStore;
|
|
import io.requery.sql.Configuration;
|
|
import io.requery.sql.ConfigurationBuilder;
|
|
import io.requery.sql.EntityDataStore;
|
|
import io.requery.sql.TableCreationMode;
|
|
|
|
|
|
/**
|
|
* Created by Kosh on 03 Feb 2017, 12:07 AM
|
|
*/
|
|
|
|
public class App extends MultiDexApplication {
|
|
private static App instance;
|
|
private SingleEntityStore<Persistable> dataStore;
|
|
|
|
@Override public void onCreate() {
|
|
super.onCreate();
|
|
instance = this;
|
|
deleteDatabase("database.db");
|
|
PreferenceManager.setDefaultValues(this, R.xml.fasthub_settings, false);
|
|
UILProvider.initUIL(this);
|
|
TypeFaceHelper.generateTypeface(this);
|
|
NotificationSchedulerJobTask.scheduleJob(this);//schedule the job for the notifications
|
|
}
|
|
|
|
@NonNull public static App getInstance() {
|
|
return instance;
|
|
}
|
|
|
|
public SingleEntityStore<Persistable> getDataStore() {
|
|
if (dataStore == null) {
|
|
EntityModel model = Models.DEFAULT;
|
|
DatabaseSource source = new DatabaseSource(this, model, "FastHub-DB", 1);
|
|
Configuration configuration = new ConfigurationBuilder(source, model)
|
|
.useDefaultLogging()
|
|
.build();
|
|
if (BuildConfig.DEBUG) {
|
|
source.setTableCreationMode(TableCreationMode.DROP_CREATE);
|
|
}
|
|
dataStore = RxSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
|
|
}
|
|
return dataStore;
|
|
}
|
|
}
|