/*
 * Copyright (c) 2016 Adventech <info@adventech.io>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.cryart.sabbathschool;

import android.app.Application;
import android.content.Context;

import com.crashlytics.android.Crashlytics;
import com.google.firebase.database.FirebaseDatabase;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import net.danlew.android.joda.JodaTimeAndroid;

import io.fabric.sdk.android.Fabric;
import rx.Scheduler;
import rx.schedulers.Schedulers;

public class SSApplication extends Application {
    private static SSApplication instance;
    private Scheduler defaultSubscribeScheduler;

    public static SSApplication get(Context context) {
        return (SSApplication) context.getApplicationContext();
    }

    public static SSApplication get(){
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        JodaTimeAndroid.init(this);
        FirebaseDatabase.getInstance().setPersistenceEnabled(true);
        Fabric.with(this, new Crashlytics());

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
        ImageLoader.getInstance().init(config);
    }

    public Scheduler defaultSubscribeScheduler() {
        if (defaultSubscribeScheduler == null) {
            defaultSubscribeScheduler = Schedulers.io();
        }
        return defaultSubscribeScheduler;
    }
}

@@ -1231,105 +1231,331 @@
 xt;%0A
-%0Aimport com.crashlytics.android.Crashlytics;%0Aimport com.google.firebase.database.FirebaseDatabase
+import android.graphics.drawable.Drawable;%0Aimport android.net.Uri;%0Aimport android.widget.ImageView;%0A%0Aimport com.crashlytics.android.Crashlytics;%0Aimport com.google.firebase.database.FirebaseDatabase;%0Aimport com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader;%0Aimport com.mikepenz.materialdrawer.util.DrawerImageLoader
 ;%0Aim
@@ -2551,16 +2551,458 @@
 config);
+%0A%0A        DrawerImageLoader.init(new AbstractDrawerImageLoader() %7B%0A            @Override%0A            public void set(ImageView imageView, Uri uri, Drawable placeholder) %7B%0A                ImageLoader.getInstance().displayImage(uri.toString(), imageView);%0A            %7D%0A%0A            @Override%0A            public void cancel(ImageView imageView) %7B%0A                ImageLoader.getInstance().cancelDisplayTask(imageView);%0A            %7D%0A        %7D);
 %0A    %7D%0A%0A

Make sure Drawer header image can be loaded via URL