Android Open Source - tracks-android Todo Context






From Project

Back to project page tracks-android.

License

The source code is released under:

Copyright (c) 2010 Adam Wolfe Gordon <awg@xvx.ca> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to...

If you think the Android project tracks-android 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

package ca.xvx.tracks;
//from w w  w .  jav  a2s .  c om
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class TodoContext implements Comparable<TodoContext> {
  private int _id;
  private String _name;
  private int _position;
  private boolean _hide;
  
  // Singleton list of contexts
  private static final Map<Integer, TodoContext> CONTEXTS;
  
  static {
    CONTEXTS = new HashMap<Integer, TodoContext>();
  }

  public TodoContext(String name, int position, boolean hide) {
    _id = -1;
    _name = name;
    _position = position;
    _hide = hide;
  }

  public TodoContext(int id, String name, int position, boolean hide) throws DuplicateContextException {
    this(name, position, hide);
    
    if(CONTEXTS.containsKey(id)) {
      throw new DuplicateContextException();
    }

    _id = id;
    
    CONTEXTS.put(id, this);
  }

  public int getId() {
    return _id;
  }
  
  public String getName() {
    return _name;
  }
  
  public int getPosition() {
    return _position;
  }
  
  public void setId(int id) {
    int oid = _id;
    _id = id;

    if(oid < 0) {
      if(!CONTEXTS.containsKey(id)) {
        CONTEXTS.put(id, this);
      }
    }
  }
  
  public String setName(String name) {
    String on = _name;
    _name = name;
    return on;
  }
  
  public int setPosition(int pos) {
    int op = _position;
    _position = pos;
    return op;
  }

  public boolean isHidden() {
    return _hide;
  }

  public boolean setHidden(boolean hide) {
    boolean oh = _hide;
    _hide = hide;
    return oh;
  }

  @Override
  public String toString() {
    return _name;
  }

  @Override
  public int compareTo(TodoContext c) {
    return _position - c._position;
  }

  // Singleton behavior
  public static TodoContext getContext(int id) {
    return CONTEXTS.get(id);
  }

  public static Collection<TodoContext> getAllContexts() {
    return CONTEXTS.values();
  }

  protected static void clear() {
    CONTEXTS.clear();
  }
}




Java Source Code List

ca.xvx.tracks.ContextEditorActivity.java
ca.xvx.tracks.ContextXmlHandler.java
ca.xvx.tracks.DuplicateContextException.java
ca.xvx.tracks.DuplicateProjectException.java
ca.xvx.tracks.DuplicateTaskException.java
ca.xvx.tracks.ProjectEditorActivity.java
ca.xvx.tracks.ProjectXmlHandler.java
ca.xvx.tracks.Project.java
ca.xvx.tracks.SettingsActivity.java
ca.xvx.tracks.TaskEditorActivity.java
ca.xvx.tracks.TaskListActivity.java
ca.xvx.tracks.TaskListAdapter.java
ca.xvx.tracks.TaskListItem.java
ca.xvx.tracks.TaskXmlHandler.java
ca.xvx.tracks.Task.java
ca.xvx.tracks.TodoContext.java
ca.xvx.tracks.TracksAction.java
ca.xvx.tracks.TracksCommunicator.java
ca.xvx.tracks.preferences.PreferenceConstants.java
ca.xvx.tracks.preferences.PreferenceUtils.java
ca.xvx.tracks.util.HttpConnection.java