Search in sources :

Example 6 with GetTaskRequest

use of com.cmput301w18t05.taskzilla.request.command.GetTaskRequest in project Taskzilla by CMPUT301W18T05.

the class TasksRequesterFragment method viewTask.

/**
 * upon pressing a task on the listview, switches to ViewTaskActivity
 * @param id id of the task to be view is passed in as a String
 * @author Colin
 */
public void viewTask(String id) {
    /*
        try except statement, when task clicked. Attempts to get from elastic search in order to test
        if the task still exists or not.
         */
    try {
        GetTaskRequest request = new GetTaskRequest(id);
        RequestManager.getInstance().invokeRequest(getContext(), request);
        Task testTask = request.getResult();
        String testTaskId = testTask.getTaskRequester().getId();
        Intent intent = new Intent(getActivity(), ViewTaskActivity.class);
        intent.putExtra("TaskId", id);
        startActivity(intent);
    } catch (Exception e) {
        RequestManager.getInstance().invokeRequest(getContext(), requestTasks);
        taskList.clear();
        taskList.addAll(requestTasks.getResult());
        adapter.notifyDataSetChanged();
        Toast.makeText(getActivity(), "Task no longer exists", Toast.LENGTH_SHORT).show();
    }
}
Also used : GetTaskRequest(com.cmput301w18t05.taskzilla.request.command.GetTaskRequest) Task(com.cmput301w18t05.taskzilla.Task) Intent(android.content.Intent)

Aggregations

GetTaskRequest (com.cmput301w18t05.taskzilla.request.command.GetTaskRequest)6 Task (com.cmput301w18t05.taskzilla.Task)2 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 AlertDialog (android.support.v7.app.AlertDialog)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 Bid (com.cmput301w18t05.taskzilla.Bid)1 GetBidByUserIdController (com.cmput301w18t05.taskzilla.controller.GetBidByUserIdController)1 RemoveBidRequest (com.cmput301w18t05.taskzilla.request.command.RemoveBidRequest)1 RemoveTaskRequest (com.cmput301w18t05.taskzilla.request.command.RemoveTaskRequest)1