package me.vickychijwani.popularmovies;

import android.app.Application;
import android.util.Log;

import com.squareup.otto.Subscribe;

import io.realm.Realm;
import io.realm.RealmConfiguration;
import me.vickychijwani.popularmovies.event.DataBusProvider;
import me.vickychijwani.popularmovies.event.events.ApiErrorEvent;
import me.vickychijwani.popularmovies.model.Database;
import me.vickychijwani.popularmovies.network.NetworkService;

public class PopularMoviesApplication extends Application {

    private static final int DB_SCHEMA_VERSION = 1;
    private static final String TAG = "Application";

    @SuppressWarnings("FieldCanBeLocal")
    private NetworkService mNetworkService;

    @SuppressWarnings("FieldCanBeLocal")
    private Database mDatabase;

    @Override
    public void onCreate() {
        super.onCreate();

        // initialize the database
        RealmConfiguration realmConfiguration = new RealmConfiguration.Builder(this)
                .name(Realm.DEFAULT_REALM_NAME)
                .schemaVersion(DB_SCHEMA_VERSION)
                .build();
        Realm.setDefaultConfiguration(realmConfiguration);
        mDatabase = new Database();

        // start the NetworkService so it can listen for and handle data request events
        mNetworkService = new NetworkService(mDatabase);
        mNetworkService.start();

        DataBusProvider.getBus().register(this);
    }

}

@@ -85,52 +85,45 @@
 oid.
-util.Log;%0A%0Aimport com.squareup.otto.Subscrib
+os.Build;%0Aimport android.os.StrictMod
 e;%0A%0A
@@ -246,74 +246,8 @@
 er;%0A
-import me.vickychijwani.popularmovies.event.events.ApiErrorEvent;%0A
 impo
@@ -750,24 +750,52 @@
 .onCreate();
+%0A        enableStrictMode();
 %0A%0A        //
@@ -1299,24 +1299,24 @@
 e.start();%0A%0A
-
         Data
@@ -1359,10 +1359,964 @@
 %0A    %7D%0A%0A
+    /**%0A     * Used to enable %7B@link android.os.StrictMode%7D during development%0A     */%0A    public static void enableStrictMode() %7B%0A        if (!BuildConfig.DEBUG) %7B%0A            return;%0A        %7D%0A        // thread violations%0A        final StrictMode.ThreadPolicy.Builder threadPolicyBuilder = new StrictMode.ThreadPolicy.Builder();%0A        threadPolicyBuilder.detectAll();%0A        threadPolicyBuilder.penaltyLog();%0A        threadPolicyBuilder.penaltyDialog();%0A        StrictMode.setThreadPolicy(threadPolicyBuilder.build());%0A%0A        // activity leaks, unclosed resources, etc%0A        final StrictMode.VmPolicy.Builder vmPolicyBuilder = new StrictMode.VmPolicy.Builder();%0A        vmPolicyBuilder.detectAll();%0A        vmPolicyBuilder.penaltyLog();%0A        if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.JELLY_BEAN) %7B%0A            vmPolicyBuilder.detectLeakedRegistrationObjects();%0A        %7D%0A        StrictMode.setVmPolicy(vmPolicyBuilder.build());%0A    %7D%0A%0A
 %7D%0A

Enable StrictMode in debug builds to catch issues faster.