001package org.intellimate.izou.sdk.activator; 002 003import org.intellimate.izou.activator.ActivatorModel; 004import org.intellimate.izou.sdk.Context; 005import org.intellimate.izou.sdk.util.AddOnModule; 006import org.intellimate.izou.sdk.util.FireEvent; 007 008/** 009 * The Task of an Activator is to listen for whatever you choose to implement and fires events to notify a change. 010 * <p> 011 * The Activator always runs in the Background, just overwrite activatorStarts(). To use Activator simply extend from it 012 * and hand an instance over to the ActivatorManager. 013 */ 014public abstract class Activator extends AddOnModule implements ActivatorModel, FireEvent { 015 private boolean stop = false; 016 017 public Activator(Context context, String ID) { 018 super(context, ID); 019 } 020 021 @Override 022 public Boolean call() throws Exception { 023 while (!stop) { 024 activatorStarts(); 025 Thread.sleep(10); 026 } 027 return false; 028 } 029 030 /** 031 * This method will be called in a loop. 032 */ 033 public abstract void activatorStarts(); 034 035 /** 036 * stops the activator. 037 */ 038 public void stop() { 039 stop = true; 040 } 041}