If you think the Android project SmartTools listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.nj.simba.utils;
/*www.java2s.com*/import java.io.IOException;
import com.android.ddmlib.SyncException;
import com.android.ddmlib.SyncService.ISyncProgressMonitor;
import com.android.ddmlib.TimeoutException;
import com.nj.simba.app.MainFrame;
import com.nj.simba.app.SmartToolsApp;
import com.nj.simba.ctrls.MyProgessBar;
publicclass SyncProgressHelper {
/**
* a runnable class run with an {@link ISyncProgressMonitor}.
*/publicinterface SyncRunnable {
/** Runs the sync action */void run(ISyncProgressMonitor monitor) throws SyncException, IOException, TimeoutException;
/** close the {@link SyncService} */void close();
}
/**
* Runs a {@link SyncRunnable} in a {@link ProgressMonitorDialog}.
* @param runnable The {@link SyncRunnable} to run.
* @param progressMessage the message to display in the progress dialog
* @param parentShell the parent shell for the progress dialog.
*
* @throws InvocationTargetException
* @throws InterruptedException
* @throws SyncException if an error happens during the push of the package on the device.
* @throws IOException
* @throws TimeoutException
*/publicstaticvoid run(final SyncRunnable runnable, final String progressMessage )
throws InterruptedException, SyncException, IOException,
TimeoutException {
new Thread(new Runnable() {
@Override
publicvoid run() {
final Exception[] result = new Exception[1];
MainFrame frm = SmartToolsApp.getApp().getMainFrm();
MyProgessBar bar = frm.getProgressBar();
try {
System.out.println("SyncProgressHelper: run");
runnable.run(new SyncProgressMonitor(bar, progressMessage));
} catch (Exception e) {
result[0] = e;
} finally {
runnable.close();
}
}
}).start();
}
}