com.android.sdklib.internal.repository
Interface ITaskMonitor

All Superinterfaces:
com.android.utils.ILogger
All Known Implementing Classes:
NullTaskMonitor

public interface ITaskMonitor
extends com.android.utils.ILogger

A monitor interface for a ITask.

Depending on the task factory that created the task, there might not be any UI or it might not implement all the methods, in which case calling them would be a no-op but is guaranteed not to crash.

If the task runs in a non-UI worker thread, the task factory implementation will take care of the update the UI in the correct thread. The task itself must not have to deal with it.

A monitor typically has 3 levels of text displayed:
- A title may be present on a task dialog, typically when a task dialog is created. This is not covered by this monitor interface.
- A description displays prominent information on what the task is currently doing. This is expected to vary over time, typically changing with each sub-monitor, and typically only the last description is visible. For example an updater would typically have descriptions such as "downloading", "installing" and finally "done". This is set using setDescription(java.lang.String, java.lang.Object...).
- A verbose optional log that can provide more information than the summary description and is typically displayed in some kind of scrollable multi-line text field so that the user can keep track of what happened. 3 levels are provided: error, normal and verbose. An UI may hide the log till an error is logged and/or might hide the verbose text unless a flag is checked by the user. This is set using log(java.lang.String, java.lang.Object...), logError(java.lang.String, java.lang.Object...) and logVerbose(java.lang.String, java.lang.Object...).

A monitor is also an ILogger implementation.


Method Summary
 ITaskMonitor createSubMonitor(int tickCount)
          Creates a sub-monitor that will use up to tickCount on the progress bar.
 UserCredentials displayLoginCredentialsPrompt(java.lang.String title, java.lang.String message)
          Launch an interface which asks for user credentials.
 boolean displayPrompt(java.lang.String title, java.lang.String message)
          Display a yes/no question dialog box.
 int getProgress()
          Returns the current value of the progress bar, between 0 and up to setProgressMax(int) - 1.
 int getProgressMax()
          Returns the max value of the progress bar, as last set by setProgressMax(int).
 void incProgress(int delta)
          Increments the current value of the progress bar.
 boolean isCancelRequested()
          Returns true if the user requested to cancel the operation.
 void log(java.lang.String format, java.lang.Object... args)
          Logs a "normal" information line.
 void logError(java.lang.String format, java.lang.Object... args)
          Logs an "error" information line.
 void logVerbose(java.lang.String format, java.lang.Object... args)
          Logs a "verbose" information line, that is extra details which are typically not that useful for the end-user and might be hidden until explicitly shown.
 void setDescription(java.lang.String format, java.lang.Object... args)
          Sets the description in the current task dialog.
 void setProgressMax(int max)
          Sets the max value of the progress bar.
 
Methods inherited from interface com.android.utils.ILogger
error, info, verbose, warning
 

Method Detail

setDescription

void setDescription(java.lang.String format,
                    java.lang.Object... args)
Sets the description in the current task dialog. This method can be invoked from a non-UI thread.


log

void log(java.lang.String format,
         java.lang.Object... args)
Logs a "normal" information line. This method can be invoked from a non-UI thread.


logError

void logError(java.lang.String format,
              java.lang.Object... args)
Logs an "error" information line. This method can be invoked from a non-UI thread.


logVerbose

void logVerbose(java.lang.String format,
                java.lang.Object... args)
Logs a "verbose" information line, that is extra details which are typically not that useful for the end-user and might be hidden until explicitly shown. This method can be invoked from a non-UI thread.


setProgressMax

void setProgressMax(int max)
Sets the max value of the progress bar. This method can be invoked from a non-UI thread. This method MUST be invoked once before using incProgress(int) or getProgress() or createSubMonitor(int). Callers are discouraged from using more than once -- implementations can either discard the next calls or behave incoherently.


getProgressMax

int getProgressMax()
Returns the max value of the progress bar, as last set by setProgressMax(int). Returns 0 if the max has never been set yet.


incProgress

void incProgress(int delta)
Increments the current value of the progress bar. This method can be invoked from a non-UI thread. Callers MUST use setProgressMax before using this method.


getProgress

int getProgress()
Returns the current value of the progress bar, between 0 and up to setProgressMax(int) - 1. Callers MUST use setProgressMax before using this method.


isCancelRequested

boolean isCancelRequested()
Returns true if the user requested to cancel the operation. It is up to the task thread to pool this and exit as soon as possible.


createSubMonitor

ITaskMonitor createSubMonitor(int tickCount)
Creates a sub-monitor that will use up to tickCount on the progress bar. tickCount must be 1 or more.


displayPrompt

boolean displayPrompt(java.lang.String title,
                      java.lang.String message)
Display a yes/no question dialog box. Implementations MUST allow this to be called from any thread, e.g. by making sure the dialog is opened synchronously in the ui thread.

Parameters:
title - The title of the dialog box
message - The error message
Returns:
true if YES was clicked.

displayLoginCredentialsPrompt

UserCredentials displayLoginCredentialsPrompt(java.lang.String title,
                                              java.lang.String message)
Launch an interface which asks for user credentials. Implementations MUST allow this to be called from any thread, e.g. by making sure the dialog is opened synchronously in the UI thread.

Parameters:
title - The title of the dialog box.
message - The message to be displayed as an instruction.
Returns:
Returns the user provided credentials. Some fields may be blank if the user did not provide any input. If operation is canceled by user the return value must be null.