Android Open Source - observer Task






From Project

Back to project page observer.

License

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

package uk.ac.horizon.observer.model;
/*w  w  w. j a v a 2  s.com*/
import java.util.Date;

import uk.ac.horizon.observer.model.Observation.ObservationDBHelper;
import android.content.ContentValues;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;

/**
 * An observable task
 * 
 * @author Jesse
 * 
 */
public class Task extends Observation {
  private Place myPlace;
  private long myBin;

  public Task(String name) {
    super(name, "task");
    myPlace = null;
    myBin = Places.getCurrentBin();
  }

  public Task(String name, Place placeIn) {
    super(name, "task");
    myPlace = placeIn;
    myBin = Places.getCurrentBin();
  }

  /**
   * Inserts an observation into the database
   * 
   * @param context
   */
  public long addObservation(Context context) {
    // Create a new map of values, where column names are the keys
    ContentValues values = new ContentValues();

    values.put(ObservationDBHelper.ObservationColumns.COLUMN_NAME_SESSION,
        Places.getSession());
    values.put(ObservationDBHelper.ObservationColumns.COLUMN_NAME_OBS_TIME,
        this.getObservationTime().getTime());
    values.put(ObservationDBHelper.ObservationColumns.COLUMN_NAME_OBS_NAME,
        this.getName());
    values.put(ObservationDBHelper.ObservationColumns.COLUMN_NAME_OBS_TYPE,
        this.getType());
    values.put(ObservationDBHelper.ObservationColumns.COLUMN_NAME_OBS_BIN,
        myBin);
    if (null != myPlace) {
      values.put(
          ObservationDBHelper.ObservationColumns.COLUMN_NAME_RELATED_OBS_TIME,
          this.myPlace.getObservationTime().getTime());
      values.put(
          ObservationDBHelper.ObservationColumns.COLUMN_NAME_RELATED_OBS_NAME,
          this.myPlace.getName());
    }

    lastobs = ObservationDBHelper
        .getInstance(context)
        .getDb()
        .insert(ObservationDBHelper.ObservationColumns.TABLE_NAME,
            null, values);
    // Log the insertion of the new row
    //Log.i(this.getClass().getName(), "" + lastobs, null);
    //Toast.makeText(context, "lastobs: " + lastobs, Toast.LENGTH_SHORT)
    //.show();
    return lastobs;
  }
}




Java Source Code List

uk.ac.horizon.observer.model.Observation.java
uk.ac.horizon.observer.model.Place.java
uk.ac.horizon.observer.model.Places.java
uk.ac.horizon.observer.model.Stop.java
uk.ac.horizon.observer.model.TaskBin.java
uk.ac.horizon.observer.model.Task.java
uk.ac.horizon.observer.vc.PlacesActivity.java
uk.ac.horizon.observer.vc.PlacesFragment.java
uk.ac.horizon.observer.vc.SettingsActivity.java
uk.ac.horizon.observer.vc.SettingsFragment.java
uk.ac.horizon.observer.vc.TaskFragment.java
uk.ac.horizon.observer.vc.TasksActivity.java