public class PCTasksManager
extends java.lang.Object
This class manages the tasks each of them represents an action which is performed in separate thread. Usually one task stands for one separate connection to the PC Server.
In most cases you are not required to use any methods from this class in your application.
However there are some situations in which this class may appear useful to you. Consider the following example:
You are displaying a transaction with attachment in your application. So, to download the attachment you call
PCTransactionsManager.getTransactionBinaryData(PCUser, PCTransaction, PCGetTransactionBinaryDataCallback)
.
The attachment might be pretty heavy, so the user decides not to wait until it is downloaded and closes the
activity with transaction. But SDK knows literally nothing about activities in your app, so SDK cannot handle the
event of closing activity. So, the attachment is continued to be downloaded in background.
To prevent SDK from doing this you can call cancelAllTasksByTag(TaskTag)
with tag named
PCTasksManager.TaskTag.LOAD_TRANSACTION
. It will break any open connections with PC server which are used
to obtain any transaction data. Or, to fine-tune the task management, you can save the instance of
PCTask
returned by PCTaskCallback.onTaskCreated(PCTask)
and cancel this individual task by calling cancel(PCTask)
.
Modifier and Type | Class and Description |
---|---|
static class |
PCTasksManager.TaskTag
Number of tags describing different tasks
|
Constructor and Description |
---|
PCTasksManager() |
Modifier and Type | Method and Description |
---|---|
static void |
cancel(PCTask task) |
static void |
cancelAllTasks()
Stops all the tasks
|
static void |
cancelAllTasksByTag(PCTasksManager.TaskTag tag)
Stops all the tasks which were assigned the target
PCTasksManager.TaskTag |
static int |
getTaskQueueSize()
Returns number of tasks in a queue.
|
static boolean |
hasTaskWithTag(PCTasksManager.TaskTag tag)
Returns true if the task with such a tag exists in queue and is currently running
|
public static void cancel(PCTask task)
public static void cancelAllTasksByTag(PCTasksManager.TaskTag tag)
PCTasksManager.TaskTag
tag
- Tag of the taskpublic static void cancelAllTasks()
public static boolean hasTaskWithTag(PCTasksManager.TaskTag tag)
tag
- Target PCTasksManager.TaskTag
public static int getTaskQueueSize()