Android Open Source - observer Task Bin

From Project

Back to project page observer.


The source code is released under:

GNU General Public License

If you think the Android project observer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*from w  ww .j a va  2  m*/
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import android.content.Context;

 * A singleton Map of Tasks.
 * @author pszjmb
public class TaskBin {
  private static TaskBin instance = null;
  private Map<String, Task> taskBin;
  private TaskBin(){
    taskBin = new HashMap<String, Task>();
  public static TaskBin getInstance(){
    if(null == instance){
      instance = new TaskBin();
    return instance;
   * Ensures that only one task with the given name is added. If
   * a second entry is attempted to be added, then the first is removed,
   * and none are added.
   * @param t
  public Task addTask(Task t){
      return taskBin.put(t.getName(), t);
      return removeTask(t);
  private Task removeTask(Task t){
    return taskBin.remove(t.getName());
   * Adds all task observations and then clears the tasks. 
   * @param context
  public void reset(Context context){
    for(Entry<String, Task> entry : taskBin.entrySet()){

Java Source Code List