package com.novoda.downloadmanager.demo.extended;

import android.app.Application;
import android.hardware.SensorManager;

import com.facebook.stetho.Stetho;
import com.novoda.downloadmanager.Download;
import com.novoda.downloadmanager.DownloadManagerBuilder;
import com.novoda.downloadmanager.lib.DownloadClientReadyChecker;
import com.novoda.downloadmanager.lib.DownloadManager;
import com.novoda.downloadmanager.lib.NotificationCustomiser;
import com.novoda.downloadmanager.lib.NotificationCustomiserProvider;
import com.novoda.notils.logger.simple.Log;

public class DemoApplication extends Application implements DownloadClientReadyChecker, NotificationCustomiserProvider {

    private OneRuleToBindThem oneRuleToBindThem;
    private NotificationCustomiser notificationCustomiser;

    @Override
    public void onCreate() {
        super.onCreate();
        notificationCustomiser = new DemoNotificationCustomiser(DemoApplication.this);
        oneRuleToBindThem = new OneRuleToBindThem();

        Stetho.initializeWithDefaults(this);

        Log.setShowLogs(true);

        Log.d("Test, DemoApplication sanity check download manager and force start");
        DownloadManager downloadManager = DownloadManagerBuilder.from(this).build();
        downloadManager.sanityCheckBatchStatuses();
        downloadManager.forceStart();



    }

    @Override
    public boolean isAllowedToDownload(Download download) {
        // Here you would add any reasons you may not want to download
        // For instance if you have some type of geo-location lock on your download capability
        return oneRuleToBindThem.shouldWeDownload(download);
    }

    @Override
    public NotificationCustomiser getNotificationCustomiser() {
        return notificationCustomiser;
    }

    private static final class OneRuleToBindThem {

        /**
         * @return for our demo we expect always to return true ... unless you want to conquer the galaxy
         */
        public boolean shouldWeDownload(Download download) {
            return download.getTotalSize() > SensorManager.GRAVITY_DEATH_STAR_I;
        }
    }

}

@@ -120,43 +120,8 @@
 r;%0A%0A
-import com.facebook.stetho.Stetho;%0A
 impo
@@ -160,16 +160,16 @@
 wnload;%0A
+
 import c
@@ -474,52 +474,8 @@
 der;
-%0Aimport com.novoda.notils.logger.simple.Log;
 %0A%0Apu
@@ -917,172 +917,8 @@
 );%0A%0A
-        Stetho.initializeWithDefaults(this);%0A%0A        Log.setShowLogs(true);%0A%0A        Log.d(%22Test, DemoApplication sanity check download manager and force start%22);%0A
     
@@ -1046,24 +1046,24 @@
 Statuses();%0A
+
         down
@@ -1088,19 +1088,16 @@
 tart();%0A
-%0A%0A%0A
     %7D%0A%0A 

Remove stetho