Search in sources :

Example 56 with Task

use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.

the class AddTaskRequest method executeOffline.

/**
 * add the task into the appcache for offline viewing.
 */
@Override
public void executeOffline() {
    AppCache appCache = AppCache.getInstance();
    appCache.addInCache(taskData);
    executedOffline = true;
}
Also used : AppCache(com.cmput301w18t05.taskzilla.AppCache)

Example 57 with Task

use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.

the class GetTasksByRequesterUsernameRequest method executeOffline.

/**
 * search through the app cache for tasks with this username
 */
@Override
public void executeOffline() {
    if (executedOfflineOnce) {
        result = new ArrayList<>();
        return;
    }
    executedOfflineOnce = true;
    System.out.println("Searching for tasks by requester username with username: " + user);
    executedOffline = true;
    AppCache appCache = AppCache.getInstance();
    ArrayList<Task> cachedTasks = appCache.getCachedTasks();
    this.result = new ArrayList<>();
    for (Task t : cachedTasks) {
        System.out.println("Looking at task: " + t);
        System.out.println("Looking at task with taskrequester uname: " + t.getTaskRequester().getUsername());
        if (t.getTaskRequester().getUsername().equals(user)) {
            System.out.println("Adding this to result");
            result.add(t);
        }
    }
}
Also used : Task(com.cmput301w18t05.taskzilla.Task) AppCache(com.cmput301w18t05.taskzilla.AppCache)

Example 58 with Task

use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.

the class ProfileController method getNumberOfTasksDone.

/**
 * getNumberOfTasksDone
 * get the number of tasks that the user
 * has provided and completed for another user
 *
 * @param username
 * @return number of tasks done by the user
 */
public String getNumberOfTasksDone(String username) {
    requestTasksProvider = new GetTasksByProviderUsernameRequest(username);
    RequestManager.getInstance().invokeRequest(ctx, requestTasksProvider);
    taskList = new ArrayList<Task>();
    this.taskList.addAll(requestTasksProvider.getResult());
    tasksDone = 0;
    for (Task task : taskList) {
        if (task.getStatus().equals("Completed")) {
            tasksDone++;
        }
    }
    while (taskList.size() > 0 && taskList != null) {
        taskList.clear();
        RequestManager.getInstance().invokeRequest(ctx, requestTasksProvider);
        this.taskList.addAll(requestTasksProvider.getResult());
        for (Task task : taskList) {
            if (task.getStatus().equals("Completed")) {
                tasksDone++;
            }
        }
    }
    return Integer.toString(tasksDone);
}
Also used : Task(com.cmput301w18t05.taskzilla.Task) GetTasksByProviderUsernameRequest(com.cmput301w18t05.taskzilla.request.command.GetTasksByProviderUsernameRequest)

Example 59 with Task

use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.

the class ViewTaskController method RemoveTaskRequest.

public void RemoveTaskRequest(Task task) {
    RemoveTaskRequest request = new RemoveTaskRequest(task.getId());
    RequestManager.getInstance().invokeRequest(ctx, request);
}
Also used : RemoveTaskRequest(com.cmput301w18t05.taskzilla.request.command.RemoveTaskRequest)

Aggregations

View (android.view.View)18 Task (com.cmput301w18t05.taskzilla.Task)16 MainActivity (com.cmput301w18t05.taskzilla.activity.MainActivity)10 AddTaskRequest (com.cmput301w18t05.taskzilla.request.command.AddTaskRequest)9 AlertDialog (android.support.v7.app.AlertDialog)6 AdapterView (android.widget.AdapterView)6 ListView (android.widget.ListView)6 GetTaskRequest (com.cmput301w18t05.taskzilla.request.command.GetTaskRequest)6 Intent (android.content.Intent)5 RecyclerView (android.support.v7.widget.RecyclerView)5 EditText (android.widget.EditText)5 ImageButton (android.widget.ImageButton)5 DecimalFormat (java.text.DecimalFormat)5 DialogInterface (android.content.DialogInterface)4 Button (android.widget.Button)4 TextView (android.widget.TextView)4 AppCache (com.cmput301w18t05.taskzilla.AppCache)4 Bid (com.cmput301w18t05.taskzilla.Bid)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 ActionBar (android.support.v7.app.ActionBar)3