Android队列后台和UI任务:AsyncJobLibrary

jopen 10年前

AsyncJobLibrary让开发人员能够轻松列队后台和UI任务。

以下是由AsyncJobBuilder 创建一个 AsyncJob 示例:

new AsyncJob.AsyncJobBuilder<Boolean>()          .doInBackground(new AsyncJob.AsyncAction<Boolean>() {              @Override              public Boolean doAsync() {                  // Do some background work                  try {                      Thread.sleep(1000);                  } catch (InterruptedException e) {                      e.printStackTrace();                  }                  return true;              }          })          .doWhenFinished(new AsyncJob.AsyncResultAction<Boolean>() {              @Override              public void onResult(Boolean result) {                  Toast.makeText(context, "Result was: " + result, Toast.LENGTH_SHORT).show();          }  }).create().start();

项目主页:http://www.open-open.com/lib/view/home/1411262634406