-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Subtask and Location POJOs, work towards #1
- Loading branch information
Showing
9 changed files
with
200 additions
and
3 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
app/src/main/java/com/goodenoughapps/missioncomplete/domain/Subtask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/goodenoughapps/missioncomplete/domain/Task.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/goodenoughapps/missioncomplete/domain/TaskLocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters