sk.baka.ambient.views
Class LongOperationExecutor

java.lang.Object
  extended by sk.baka.ambient.views.LongOperationExecutor
All Implemented Interfaces:
DialogInterface.OnCancelListener, Runnable

public final class LongOperationExecutor
extends Object
implements Runnable, DialogInterface.OnCancelListener

Shows the wait-for dialog and runs long running operation in the background. The start() method starts the long running operation in new thread.

Exceptions thrown by the runnable are reported using AmbientApplication.error(Class, boolean, String, Throwable).

The Runnable should periodically check for the interrupted state (using Thread.currentThread().isInterrupted()). If it is interrupted it should finish ASAP. It may do so by throwing an Exception - exceptions are not reported when the process is interrupted.

Author:
Martin Vysny

Constructor Summary
LongOperationExecutor(Context context, int text, int errorMsg, Runnable longRunningOp)
          Creates the long running operation runner.
 
Method Summary
 void onCancel(DialogInterface arg0)
           
 void run()
          Internal, do not call.
 void start()
          Shows the dialog and starts the long-running operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LongOperationExecutor

public LongOperationExecutor(Context context,
                             int text,
                             int errorMsg,
                             Runnable longRunningOp)
Creates the long running operation runner. Must be called from an event thread.

Parameters:
context - the context
text - the text to show on the dialog.
errorMsg - shown when the operation fails.
longRunningOp - the operation to run. It will be executed in its own thread.
Method Detail

run

public void run()
Internal, do not call.

Specified by:
run in interface Runnable

onCancel

public void onCancel(DialogInterface arg0)
Specified by:
onCancel in interface DialogInterface.OnCancelListener

start

public void start()
Shows the dialog and starts the long-running operation.



Copyright © 2007-2008. All Rights Reserved.