use of com.cmput301w18t05.taskzilla.request.command.GetTaskRequest 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.request.command.GetTaskRequest in project Taskzilla by CMPUT301W18T05.
the class MyBidsFragment method onViewCreated.
/**
* initialize variables as well as set up adapter and onlongclick
* @param view states the current view
* @param savedInstanceState idk what this does
* @author myapplestory
*/
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
bidList = new ArrayList<>();
bidController = new GetBidByUserIdController(getContext(), currentUser.getInstance());
adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, bidList);
taskListView.setAdapter(adapter);
// goes to the respective task when a bid is tapped on
taskListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
viewTask(bidList.get(position));
}
});
// prompts to delete bid when held
taskListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
alert.setTitle("Delete");
alert.setMessage("Are you sure you want to delete this bid?");
alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// remove bid
Bid targetBid = bidList.get(position);
RemoveBidRequest removeRequest = new RemoveBidRequest(targetBid);
RequestManager.getInstance().invokeRequest(removeRequest);
bidList.remove(position);
// change status of task
GetTaskRequest getTaskRequest = new GetTaskRequest(targetBid.getTaskId());
RequestManager.getInstance().invokeRequest(getTaskRequest);
Task temptask = getTaskRequest.getResult();
temptask.setStatus("requested");
adapter.notifyDataSetChanged();
dialogInterface.dismiss();
}
});
alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
alert.show();
return true;
}
});
}
use of com.cmput301w18t05.taskzilla.request.command.GetTaskRequest in project Taskzilla by CMPUT301W18T05.
the class RequestManagerTest method testGetTaskRequest.
public void testGetTaskRequest() {
GetTaskRequest getTaskRequest = new GetTaskRequest(task.getId());
RequestManager.getInstance().invokeRequest(ctx, getTaskRequest);
Task ret = getTaskRequest.getResult();
Log.i("Event", "RETURNED TASK: " + ret.toString());
assertEquals(task.getId(), ret.getId());
assertEquals(task.getName(), ret.getName());
assertEquals(task.getDescription(), ret.getDescription());
}
use of com.cmput301w18t05.taskzilla.request.command.GetTaskRequest in project Taskzilla by CMPUT301W18T05.
the class RequestManagerTest method testRemoveTask.
public void testRemoveTask() {
RemoveTaskRequest request = new RemoveTaskRequest(task.getId());
RequestManager.getInstance().invokeRequest(ctx, request);
GetTaskRequest getTaskRequest = new GetTaskRequest(task.getId());
RequestManager.getInstance().invokeRequest(getTaskRequest);
assertNull(getTaskRequest.getResult());
}
use of com.cmput301w18t05.taskzilla.request.command.GetTaskRequest in project Taskzilla by CMPUT301W18T05.
the class Bid method toString.
/**
* Returns a string with the bid details
* @return the string which is with the details of the bid
*/
public String toString() {
GetTaskRequest taskRequest = new GetTaskRequest(this.taskId);
RequestManager.getInstance().invokeRequest(taskRequest);
return "Task: " + taskRequest.getResult().getName() + "\nBid amount: $" + Float.toString(this.bidAmount);
}
Aggregations