package com.lukekorth.android_500px;

import android.content.Context;

import com.lukekorth.android_500px.helpers.Cache;
import com.lukekorth.android_500px.helpers.ThreadBus;
import com.squareup.otto.Bus;
import com.squareup.picasso.Picasso;

public class WallpaperApplication extends com.activeandroid.app.Application {

    private static ThreadBus sBus;
    private static Picasso sPicasso;

    @Override
    public void onCreate() {
        super.onCreate();
        sBus = new ThreadBus();
    }

    public static Bus getBus() {
        return sBus;
    }

    public static Picasso getPicasso(Context context) {
        if (sPicasso == null) {
            sPicasso = new Picasso.Builder(context.getApplicationContext())
                    .downloader(Cache.createCacheDownloader(context.getApplicationContext()))
                    .build();
        }
        return sPicasso;
    }

}


@@ -63,16 +63,143 @@
 ontext;%0A
+import android.content.SharedPreferences;%0Aimport android.preference.PreferenceManager;%0A%0Aimport com.activeandroid.ActiveAndroid;
 %0Aimport 
@@ -442,16 +442,70 @@
 tion %7B%0A%0A
+    private static final String VERSION = %22version%22;%0A%0A
     priv
@@ -669,16 +669,305 @@
 adBus();
+%0A%0A        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);%0A        if (prefs.getInt(VERSION, 0) %3C= 1) %7B%0A            ActiveAndroid.getDatabase().delete(%22Photos%22, null, null);%0A            prefs.edit().putInt(VERSION, BuildConfig.VERSION_CODE).apply();%0A        %7D
 %0A    %7D%0A%0A

Clear database for version <= 1