コード例 #1
0
ファイル: AsyncRunner.java プロジェクト: JokeLook/framework
 @Override
 protected void onPostExecute(RunnerResult result) {
   if (mLogVerbose) Log.v(TAG, "Starting post-execute.");
   setRunning(false);
   if (result == null) {
     // Cancelled before got to doInBackground
     result = new RunnerResult();
     result.status = RESULT_STOPPED;
   }
   setException(result.exception);
   if (result.status == RESULT_STOPPED || result.status == RESULT_ERROR) {
     if (mLogVerbose) Log.v(TAG, "Closing filters.");
     try {
       mRunner.close();
     } catch (Exception exception) {
       result.status = RESULT_ERROR;
       setException(exception);
     }
   }
   if (mDoneListener != null) {
     if (mLogVerbose) Log.v(TAG, "Calling graph done callback.");
     mDoneListener.onRunnerDone(result.status);
   }
   if (mLogVerbose) Log.v(TAG, "Completed post-execute.");
 }
コード例 #2
0
ファイル: AsyncRunner.java プロジェクト: JokeLook/framework
    @Override
    protected RunnerResult doInBackground(SyncRunner... runner) {
      RunnerResult result = new RunnerResult();
      try {
        if (runner.length > 1) {
          throw new RuntimeException("More than one runner received!");
        }

        runner[0].assertReadyToStep();

        // Preparation
        if (mLogVerbose) Log.v(TAG, "Starting background graph processing.");
        activateGlContext();

        if (mLogVerbose) Log.v(TAG, "Preparing filter graph for processing.");
        runner[0].beginProcessing();

        if (mLogVerbose) Log.v(TAG, "Running graph.");

        // Run loop
        result.status = RESULT_RUNNING;
        while (!isCancelled() && result.status == RESULT_RUNNING) {
          if (!runner[0].performStep()) {
            result.status = runner[0].determinePostRunState();
            if (result.status == GraphRunner.RESULT_SLEEPING) {
              runner[0].waitUntilWake();
              result.status = RESULT_RUNNING;
            }
          }
        }

        // Cleanup
        if (isCancelled()) {
          result.status = RESULT_STOPPED;
        }
      } catch (Exception exception) {
        result.exception = exception;
        result.status = RESULT_ERROR;
      }

      // Deactivate context.
      try {
        deactivateGlContext();
      } catch (Exception exception) {
        result.exception = exception;
        result.status = RESULT_ERROR;
      }

      if (mLogVerbose) Log.v(TAG, "Done with background graph processing.");
      return result;
    }