Android Open Source - pinpoint-android Task Log Entry






From Project

Back to project page pinpoint-android.

License

The source code is released under:

MIT License

If you think the Android project pinpoint-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 co.islovely.pinpoint;
/*from  www.  j  a v a  2 s  .c o  m*/
import java.util.Date;
import org.json.JSONException;
import org.json.JSONObject;

public class TaskLogEntry {
  private boolean wasCorrect;

  private Class activityClass;

  private Date
      completedAt,
      createdAt;

  private String touchTarget;

  private float
      touchCoordinatesX,
      touchCoordinatesY;

  private int launcherItemId;

  public TaskLogEntry(LauncherItem launcherItem, Class activityClass) {
    this.activityClass = activityClass;
    this.createdAt = new Date();
    this.launcherItemId = launcherItem.getId();
    this.touchCoordinatesX = -1f;
    this.touchCoordinatesY = -1f;
    this.touchTarget = "";
  }

  public void complete() {
    this.completedAt = new Date();
  }

  public Class getActivityClass() {
    return this.activityClass;
  }

  public long getDuration() {
    return this.completedAt.getTime() - this.createdAt.getTime();
  }

  public void setTouchCoordinates(float x, float y) {
    this.touchCoordinatesX = x;
    this.touchCoordinatesY = y;
  }

  public void setTouchTarget(String target) {
    this.touchTarget = target;
  }

  public void setWasCorrect(boolean wasCorrect) {
    this.wasCorrect = wasCorrect;
  }

  public boolean wasCorrect() {
    return this.wasCorrect;
  }

  public JSONObject toJSON() {
    JSONObject
        coordinates = new JSONObject(),
        jsonObject = new JSONObject(),
        touch = new JSONObject();

    try {
      jsonObject.put("activity", this.activityClass.getSimpleName());
      jsonObject.put("completedAt", this.completedAt.getTime());
      jsonObject.put("createdAt", this.createdAt.getTime());
      jsonObject.put("launcheritem", this.launcherItemId);
      jsonObject.put("wasCorrect", this.wasCorrect);

      touch.put("target", this.touchTarget);

      coordinates.put("x", this.touchCoordinatesX);
      coordinates.put("y", this.touchCoordinatesY);
      touch.put("coordinates", coordinates);

      jsonObject.put("touch", touch);
    } catch (JSONException exception) {
      Pinpoint.log("Could not create JSONObject from TaskLogEntry.");
    }

    return jsonObject;
  }
}




Java Source Code List

co.islovely.pinpoint.ColumnsActivity.java
co.islovely.pinpoint.Configuration.java
co.islovely.pinpoint.DeviceMetrics.java
co.islovely.pinpoint.GridActivity.java
co.islovely.pinpoint.HomescreenAdapter.java
co.islovely.pinpoint.HomescreenSelectActivity.java
co.islovely.pinpoint.Homescreen.java
co.islovely.pinpoint.IntermissionActivity.java
co.islovely.pinpoint.LauncherItem.java
co.islovely.pinpoint.LauncherReader.java
co.islovely.pinpoint.LayoutConfigurationActivity.java
co.islovely.pinpoint.MainActivity.java
co.islovely.pinpoint.MyApplication.java
co.islovely.pinpoint.PinpointActivity.java
co.islovely.pinpoint.Pinpoint.java
co.islovely.pinpoint.QuadrantsActivity.java
co.islovely.pinpoint.RowsActivity.java
co.islovely.pinpoint.StatisticsActivity.java
co.islovely.pinpoint.TaskLogEntry.java
co.islovely.pinpoint.TaskLog.java
co.islovely.pinpoint.TaskManager.java
co.islovely.pinpoint.Task.java
co.islovely.pinpoint.User.java
util.Base64.java