use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.
the class ViewTaskController method getTaskRequest.
/**
* getTaskRequest
* get the task from elastic search using request manager
* and set the task of the controller to be the result
*
* @author Micheal-Nguyen
*/
public void getTaskRequest() {
GetTaskRequest request = new GetTaskRequest(taskID);
RequestManager.getInstance().invokeRequest(ctx, request);
this.task = request.getResult();
}
use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.
the class ViewTaskController method updateTaskRequest.
public void updateTaskRequest(Task task) {
AddTaskRequest request = new AddTaskRequest(task);
request.setUpdate(true);
RequestManager.getInstance().invokeRequest(ctx, request);
}
use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.
the class GetAllTasksRequest method executeOffline.
/**
* get all the tasks from the app cache
*/
@Override
public void executeOffline() {
// return what is in app cache
if (executedOfflineOnce) {
// prevent infinite loop
result = new ArrayList<Task>();
return;
}
AppCache appCache = AppCache.getInstance();
result = appCache.getCachedTasks();
executedOfflineOnce = true;
}
use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.
the class GetTasksByProviderUsernameRequest method executeOffline.
/**
* search through tasks in the app cache
* Also add the found tasks to the app cache
*/
@Override
public void executeOffline() {
if (executedOffline) {
result = new ArrayList<>();
return;
}
executedOffline = true;
AppCache appCache = AppCache.getInstance();
ArrayList<Task> cachedTasks = appCache.getCachedTasks();
result = new ArrayList<>();
for (Task t : cachedTasks) {
if (t.getTaskProvider().getUsername() != null && t.getTaskProvider().equals(user)) {
result.add(t);
}
}
}
use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.
the class NewTaskController method addTask.
/**
* Error checks the task name and description to enforce character limits.
* Then the task is added to Elastic Search
* @param name Task name
* @param user User that is making the task
* @param description Description of the task
*/
public void addTask(String name, User user, String description) {
// Check field lengths and give error
EditText taskName = view.findViewById(R.id.TaskName);
EditText taskDescription = view.findViewById(R.id.Description);
if (TextUtils.getTrimmedLength(taskName.getText()) <= 25 && TextUtils.getTrimmedLength(taskName.getText()) > 0 && TextUtils.getTrimmedLength(taskDescription.getText()) <= 25 && TextUtils.getTrimmedLength(taskDescription.getText()) > 0) {
Task task = new Task(name, user, description);
AddTaskRequest request = new AddTaskRequest(task);
RequestManager.getInstance().invokeRequest(ctx, request);
request.getResult();
taskId = task.getId();
Intent intent = new Intent();
intent.putExtra("result", taskId);
view.setResult(RESULT_OK, intent);
Toast.makeText(view, "New task created, refresh page to see updated list", Toast.LENGTH_SHORT).show();
view.finish();
} else {
if (TextUtils.getTrimmedLength(taskName.getText()) > 25) {
taskName.setError("Name can not exceed 25 characters");
}
if (TextUtils.getTrimmedLength(taskName.getText()) == 0) {
taskName.setError("Name can not empty");
}
if (TextUtils.getTrimmedLength(taskDescription.getText()) > 280) {
taskDescription.setError("Description can not exceed 280 characters");
}
if (TextUtils.getTrimmedLength(taskDescription.getText()) == 0) {
taskDescription.setError("Description can not be empty");
}
}
}
Aggregations