Skip to content

Commit

Permalink
Subtask and Location POJOs, work towards #1
Browse files Browse the repository at this point in the history
  • Loading branch information
vontell committed Jan 7, 2017
1 parent 8d839ac commit 8e7d0c2
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 3 deletions.
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

6 changes: 6 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'

// Custom dependencies
compile 'joda-time:joda-time:2.9.7'

testCompile 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.goodenoughapps.missioncomplete.domain;

/**
* Represents a subtask which may be contained within a primary Task
* @author Aaron Vontell
*/
public class Subtask {

private String title; // The text content of this subtask
private boolean completed; // True if this subtask should be marked as completed

public static final String TITLE_FIELD = "title";
public static final String COMPLETED_FIELD = "completed";

/**
* Creates a subtask with a given title
* @param title The text content of this subtask
* @param completed True if this subtask should be marked as completed
*/
public Subtask(String title, boolean completed) {
this.title = title;
this.completed = completed;
}

/**
* Creates a subtask with the given title, defaulting to not completed
* Useful for creating new tasks
* @param title The text content of this subtask
*/
public Subtask(String title) {
this.title = title;
this.completed = false;
}

/**
* Returns the content of this subtask
* @return the content of this subtask
*/
public String getTitle() {
return title;
}

/**
* Returns true if this subtask is completed
* @return true if this subtask is completed
*/
public boolean isCompleted() {
return completed;
}

/**
* Sets whether this subtask should be marked as completed or not
* @param completed true if this should be marked as completed, false otherwise
*/
public void setCompleted(boolean completed) {
this.completed = completed;
}

/**
* Returns a JSON object representing this subtask as marked in the Schema
* @return The JSON representation of this subtask
*/
public String getJSON() {
return String.format("{%s: %s,%s: %s}",
TITLE_FIELD, this.title, COMPLETED_FIELD, this.isCompleted());
}

/**
* Returns a string representing this task, useful for debugging purposes
* @return a string representing this task
*/
@Override
public String toString() {
return String.format("Task \"%s\" is %s",
this.title, this.isCompleted() ? "completed" : "not completed");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.goodenoughapps.missioncomplete.domain;

import org.joda.time.DateTime;

import java.util.List;

/**
* The main task object for all tasks within the application. Follows the schema as mentioned on
* https://github.com/GoodEnoughSoftware/Mission-Complete/issues/1
* @author Aaron Vontell
*/

public class Task {

private String title;
private double difficulty;
private DateTime date;
private boolean completed;
private String note;
private TaskLocation location;
private List<Subtask> subtasks;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.goodenoughapps.missioncomplete.domain;

/**
* Represents an immutable location which may be attributed to a Task
* @author Aaron Vontell
*/
public class TaskLocation {

private double latitude; // The latitude of this location
private double longitude; // The longitude of this location

public static final String LATITUDE_FIELD = "lat";
public static final String LONGITUDE_FIELD = "lng";

/**
* Creates a location from the given latitude and longitude
* @param latitude
* @param longitude
*/
public TaskLocation(double latitude, double longitude) {
this.latitude = latitude;
this.longitude = longitude;
}

/**
* Returns the latitude of this location
* @return the latitude of this location
*/
public double getLatitude() {
return latitude;
}

/**
* Returns the longitude of this location
* @return the longitude of this location
*/
public double getLongitude() {
return longitude;
}

/**
* Returns a JSON representation of this location as defined in the schema
* @return a JSON representation of this location as defined in the schema
*/
public String getJSON() {
return String.format("{%s: %s, %s: %s}",
LATITUDE_FIELD, this.latitude, LONGITUDE_FIELD, this.longitude);
}

/**
* Returns a string useful for debugging purposes representing this location
* @return a debugging string for this location
*/
@Override
public String toString() {
return String.format("Location at [%s, %s]", this.latitude, this.longitude);
}

}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-rc2'
classpath 'com.android.tools.build:gradle:2.2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit 8e7d0c2

Please sign in to comment.