Back to project page pinpoint-android.
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.
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; } }