package tm.android.lampetorche;


import android.os.AsyncTask;

import java.util.ArrayList;

public class SosWorker extends AsyncTask<Void,MorseRenderer,Void> implements MorseAction
{
    private static  SosWorker _instance;
    private boolean run =true;
    private ArrayList<MorseRenderer> renderers;
    private morseAction currentAction;

private SosWorker(){
    renderers = new ArrayList<MorseRenderer>(2);
}

    public static SosWorker Instance(){
        if (_instance==null)
            _instance = new SosWorker();

        return _instance;
    }
    @Override
    protected Void doInBackground(Void... params) {

            try {
                while(run) {
                    if (renderers.size() == 0) {
                        Thread.sleep(100);
                        continue;
                    }
                    Morse.doWord("SOS", this);
                }
            } catch (InterruptedException e) {
               // e.printStackTrace();
            }

        return null;
    }

    @Override
    protected void onProgressUpdate(MorseRenderer... values) {
            for(MorseRenderer renderer : renderers)
                renderer.render(currentAction);

    }


    public void addRenderer(MorseRenderer renderer){

        renderers.add(renderer);
        Morse.unstop();
    }

    public void removeRenderer(MorseRenderer renderer){
        renderers.remove(renderer);
        if (renderers.size()==0)
            Morse.stop();
    }

    public void stop(){
        run=false;
        cancel(true);
        _instance=null;
    }

    @Override
    public void doAction(morseAction at) {
        currentAction=at;
        publishProgress();
    }
}

@@ -1,8 +1,133 @@
+/**%0A *  SosWorker%0A *%0A *  Copyright (c) 2014 Thierry Margenstern under MIT license%0A *  http://opensource.org/licenses/MIT%0A */%0A
 package 
@@ -211,16 +211,66 @@
 yList;%0A%0A
+/**%0A * @see tm.android.lampetorche.Morse%0A *%0A * */%0A
 public c
@@ -307,29 +307,20 @@
 sk%3CVoid,
-MorseRenderer
+Void
 ,Void%3E i
@@ -1013,16 +1013,17 @@
 e.doWord
+s
 (%22SOS%22, 
@@ -1230,30 +1230,23 @@
 ate(
-MorseRenderer... value
+Void... progres
 s) %7B

Change unnecessary method parameter type. Add MIT License