app/src/main/java/edu/washington/briluu/quizdroid/PreferencesActivity.java
// sets a timer that spins up the DownLoadFilesTask thread every x minutes
sets a timer that spins up the DownLoadFilesTask thread every x minutes
sets a timer that spins up the DownLoadFilesTask thread every x minutes
public void downloadQuizQuestions(final URL url, int interval) {
        final Handler handler = new Handler();
        final Timer timer = new Timer();
        TimerTask doAsynchronousTask = new TimerTask() {
            @Override
            public void run() {
                handler.post(new Runnable() {
                    public void run() {
                        try {
                            if (isNetworkConnected()) {
                                downLoadFilesTask = new DownLoadFilesTask();
                                downLoadFilesTask.execute(url);
                            } else {
                                timer.cancel();
                                DialogFragment dialogFragment = RetryDownloadDialogFragment.newInstance(download_url);
                                dialogFragment.show(getFragmentManager(), "RetryDownloadDialogFragment");
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                            Log.w("PreferencesActivity", e);
                        }
                    }
                });
            }
        };
        timer.schedule(doAsynchronousTask, 0, 1000 * 60 * interval); 
    }
public void downloadQuizQuestions ( final URL url , int interval ) { final Handler handler = new Handler ( ) ; final Timer timer = new Timer ( ) ; TimerTask doAsynchronousTask = new TimerTask ( ) { @ Override public void run ( ) { handler . post ( new Runnable ( ) { public void run ( ) { try { if ( isNetworkConnected ( ) ) { downLoadFilesTask = new DownLoadFilesTask ( ) ; downLoadFilesTask . execute ( url ) ; } else { timer . cancel ( ) ; DialogFragment dialogFragment = RetryDownloadDialogFragment . newInstance ( download_url ) ; dialogFragment . show ( getFragmentManager ( ) , "RetryDownloadDialogFragment" ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; Log . w ( "PreferencesActivity" , e ) ; } } } ) ; } } ; timer . schedule ( doAsynchronousTask , 0 , 1000 * 60 * interval ) ; }
sets a timer that spins up the DownLoadFilesTask thread every x minutes
sets a timer that spins up the DownLoadFilesTask thread every x minutes
//execute every 'interval' minutes