Android Open Source - PreCTS Async Task






From Project

Back to project page PreCTS.

License

The source code is released under:

Apache License

If you think the Android project PreCTS 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.androidhuman.ctsprepare.util;
/*ww  w .j av  a 2 s . c  o m*/
import org.eclipse.swt.widgets.Display;

public abstract class AsyncTask<T, U, V> {
  
  Thread thread;
  
  public final void execute(final T... params){
    Display.getDefault().syncExec(new Runnable(){
      public void run(){
        onPreExecute();
      }
    });
    
    thread = new Thread(new Runnable(){
      public void run(){
        
        if(!Thread.currentThread().isInterrupted()){
          final V result = doInBackground(params);
          Display.getDefault().syncExec(new Runnable(){
            public void run(){
              onPostExecute(result);
            }
          });
        }
        
      }
    });
    thread.start();
  }
  
  public final void updateProgress(final U progress){
    Display.getDefault().asyncExec(new Runnable(){
      public void run(){
        onProgressUpdate(progress);
      }
    });
  }
  
  
  public void cancel(){
    thread.interrupt();
  }
  
  public abstract void onPreExecute();
  public abstract V doInBackground(T... params);
  public abstract void onPostExecute(V result);
  public abstract void onProgressUpdate(U progress);
}




Java Source Code List

com.androidhuman.ctsprepare.automator.GoogleAccount.java
com.androidhuman.ctsprepare.automator.PreCTSAutomate.java
com.androidhuman.ctsprepare.automator.WifiAp.java
com.androidhuman.ctsprepare.data.BasicDeviceInfo.java
com.androidhuman.ctsprepare.data.Event.java
com.androidhuman.ctsprepare.data.GoogleAccount.java
com.androidhuman.ctsprepare.data.Model.java
com.androidhuman.ctsprepare.data.ProxySettings.java
com.androidhuman.ctsprepare.data.Task.java
com.androidhuman.ctsprepare.data.Waiver.java
com.androidhuman.ctsprepare.data.WifiAp.java
com.androidhuman.ctsprepare.dialog.CtsMediaDownloadDialog.java
com.androidhuman.ctsprepare.dialog.EditGoogleAccountDialog.java
com.androidhuman.ctsprepare.dialog.EditMacroDialog.java
com.androidhuman.ctsprepare.dialog.EditProxyDialog.java
com.androidhuman.ctsprepare.dialog.EditSdkPathDialog.java
com.androidhuman.ctsprepare.dialog.EditWifiApDialog.java
com.androidhuman.ctsprepare.dialog.TargetSelectionDialog.java
com.androidhuman.ctsprepare.shell.ConfigureMacroShell.java
com.androidhuman.ctsprepare.shell.Main.java
com.androidhuman.ctsprepare.util.AdbCommand.java
com.androidhuman.ctsprepare.util.AdbWrapper.java
com.androidhuman.ctsprepare.util.AsyncTask.java
com.androidhuman.ctsprepare.util.Download.java
com.androidhuman.ctsprepare.util.Utils.java
com.androidhuman.ctsprepare.util.Worker.java
com.androidhuman.prectsandroidsettingsapp.EnableSyncActivity.java
com.androidhuman.prectsandroidsettingsapp.FinishHandler.java
com.androidhuman.prectsandroidsettingsapp.MainActivity.java