result = null; $this->onRun(); $this->setGarbage(); } /** * @deprecated * * @return bool */ public function isFinished(){ return $this->isGarbage(); } /** * @return mixed */ public function getResult(){ return $this->serialized ? unserialize($this->result) : $this->result; } /** * @return bool */ public function hasResult(){ return $this->result !== null; } /** * @param mixed $result * @param bool $serialize */ public function setResult($result, $serialize = true){ $this->result = $serialize ? serialize($result) : $result; $this->serialized = $serialize; } public function setTaskId($taskId){ $this->taskId = $taskId; } public function getTaskId(){ return $this->taskId; } /** * Actions to execute when run * * @return void */ public abstract function onRun(); /** * Actions to execute when completed (on main thread) * Implement this if you want to handle the data in your AsyncTask after it has been processed * * @param Server $server * * @return void */ public function onCompletion(Server $server){ } }