Search in sources :

Example 1 with OsmTemplateModule

use of io.jawg.osmcontributor.modules.OsmTemplateModule in project osm-contributor by jawg.

the class OsmTemplateApplication method onCreate.

/*=========================================*/
/*---------------OVERRIDE------------------*/
/*=========================================*/
@Override
public void onCreate() {
    super.onCreate();
    if (BuildConfig.DEBUG) {
        Timber.plant(new Timber.DebugTree());
    }
    Fabric.with(this, new Crashlytics());
    // Init Stetho for debug purpose (database)
    Stetho.initializeWithDefaults(this);
    // Init Dagger
    osmTemplateComponent = DaggerOsmTemplateComponent.builder().osmTemplateModule(new OsmTemplateModule(this)).build();
    osmTemplateComponent.inject(this);
    // Init Flickr object
    StoreConfigManager configManager = new StoreConfigManager();
    flickr = new Flickr(configManager.getFlickrApiKey(), configManager.getFlickrApiKeySecret(), new REST());
    // Cache Disk for Fresco
    DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(this).setBaseDirectoryPath(new File(Environment.getExternalStorageDirectory().getAbsoluteFile(), getPackageName())).setBaseDirectoryName("images").build();
    // Cache Memory for Fresco
    ImagePipelineConfig imagePipelineConfig = ImagePipelineConfig.newBuilder(this).setBitmapMemoryCacheParamsSupplier(new Supplier<MemoryCacheParams>() {

        @Override
        public MemoryCacheParams get() {
            return new MemoryCacheParams(10485760, 100, 100, 100, 100);
        }
    }).setMainDiskCacheConfig(diskCacheConfig).build();
    // Init Fresco
    Fresco.initialize(this, imagePipelineConfig);
    // Init event bus
    EventBus bus = osmTemplateComponent.getEventBus();
    bus.register(getOsmTemplateComponent().getLoginManager());
    bus.register(getOsmTemplateComponent().getEditPoiManager());
    bus.register(getOsmTemplateComponent().getPoiManager());
    bus.register(getOsmTemplateComponent().getNoteManager());
    bus.register(getOsmTemplateComponent().getSyncManager());
    bus.register(getOsmTemplateComponent().getTypeManager());
    bus.register(getOsmTemplateComponent().getPresetsManager());
    bus.register(getOsmTemplateComponent().getGeocoder());
    bus.register(getOsmTemplateComponent().getEditVectorialWayManager());
    SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
    if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean(getString(R.string.shared_prefs_preset_default), false)) {
        editor.putBoolean(getString(R.string.shared_prefs_preset_default), true);
    }
    editor.apply();
    MapboxAccountManager.start(this, BuildConfig.MAPBOX_TOKEN);
}
Also used : SharedPreferences(android.content.SharedPreferences) Timber(timber.log.Timber) ImagePipelineConfig(com.facebook.imagepipeline.core.ImagePipelineConfig) EventBus(org.greenrobot.eventbus.EventBus) Crashlytics(com.crashlytics.android.Crashlytics) OsmTemplateModule(io.jawg.osmcontributor.modules.OsmTemplateModule) Flickr(com.flickr4java.flickr.Flickr) REST(com.flickr4java.flickr.REST) DiskCacheConfig(com.facebook.cache.disk.DiskCacheConfig) StoreConfigManager(io.jawg.osmcontributor.utils.core.StoreConfigManager) MemoryCacheParams(com.facebook.imagepipeline.cache.MemoryCacheParams) File(java.io.File)

Aggregations

SharedPreferences (android.content.SharedPreferences)1 Crashlytics (com.crashlytics.android.Crashlytics)1 DiskCacheConfig (com.facebook.cache.disk.DiskCacheConfig)1 MemoryCacheParams (com.facebook.imagepipeline.cache.MemoryCacheParams)1 ImagePipelineConfig (com.facebook.imagepipeline.core.ImagePipelineConfig)1 Flickr (com.flickr4java.flickr.Flickr)1 REST (com.flickr4java.flickr.REST)1 OsmTemplateModule (io.jawg.osmcontributor.modules.OsmTemplateModule)1 StoreConfigManager (io.jawg.osmcontributor.utils.core.StoreConfigManager)1 File (java.io.File)1 EventBus (org.greenrobot.eventbus.EventBus)1 Timber (timber.log.Timber)1