use of com.cmput301w18t05.taskzilla.request.command.SearchTaskRequest in project Taskzilla by CMPUT301W18T05.
the class RequestManagerTest method testSearchTaskRequest.
public void testSearchTaskRequest() {
addUser();
addTask();
String keywords = task.getDescription();
SearchTaskRequest request = new SearchTaskRequest(keywords);
RequestManager.getInstance().invokeRequest(ctx, request);
assertNotNull(request.getTasks());
System.out.println("------- Search output -------");
System.out.println("******************************");
ArrayList<Task> ret = request.getTasks();
System.out.println(ret);
for (Task t : ret) {
System.out.println(t);
Log.i("Found Task", t.getId());
}
}
use of com.cmput301w18t05.taskzilla.request.command.SearchTaskRequest in project Taskzilla by CMPUT301W18T05.
the class SearchController method searchRequest.
/**
* This method invokes a search request using the given keywords, which is then sent
* to the request manager which determines if the app is online or offline, before doing
* the request.
*
* @param sentence string of keywords
* @see RequestManager
*/
public void searchRequest(String sentence) {
newRequest = new SearchTaskRequest(sentence);
RequestManager.getInstance().invokeRequest(ctx, newRequest);
ArrayList<Task> temp;
temp = newRequest.getTasks();
if (temp != null && temp.size() != 0) {
while (temp.size() > 0) {
for (Task t : temp) if (!t.getStatus().equalsIgnoreCase("assigned") && !t.getStatus().equalsIgnoreCase("completed")) {
this.searchResults.add(t);
}
RequestManager.getInstance().invokeRequest(ctx, newRequest);
temp = newRequest.getTasks();
}
} else if (temp == null) {
Toast.makeText(view.getActivity(), "Unable to search right now.", Toast.LENGTH_SHORT).show();
} else {
searchResults.clear();
}
view.notifyChange();
}
Aggregations