Issue #90 : possibly relevant improvement to logic - no point in canceling the AsyncTask which will always be running at that point if it exists

This commit is contained in:
Sean Owen 2014-03-20 17:07:42 +04:00
parent 9e8a47c7e4
commit 264a49a148

View file

@ -64,7 +64,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
autoFocusAgainLater();
}
private void autoFocusAgainLater() {
private synchronized void autoFocusAgainLater() {
if (!stopped && outstandingTask == null) {
AutoFocusTask newTask = new AutoFocusTask();
try {
@ -78,7 +78,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
synchronized void start() {
if (useAutoFocus) {
cancelOutstandingTask();
outstandingTask = null;
if (!stopped && !focusing) {
try {
camera.autoFocus(this);
@ -93,7 +93,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
}
}
private void cancelOutstandingTask() {
private synchronized void cancelOutstandingTask() {
if (outstandingTask != null) {
if (outstandingTask.getStatus() != AsyncTask.Status.FINISHED) {
outstandingTask.cancel(true);