package com.example.svc.services;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;

import com.example.svc.utilities.Downloader;

public class DownloadService3 extends Service {
    public class DownloadBinder extends Binder {
        private ThreadGroup threadGroup = new ThreadGroup("Download");

        public void download(final String url) {
            new Thread(threadGroup, new Runnable() {
                public void run() {
                    Downloader d = 
                            new Downloader(DownloadService3.this, url);
                    d.interruptableDownloadFile();
                }
            }).start();
        }

        public void stopDownload() {
            threadGroup.interrupt();
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        return new DownloadBinder();
    }
}