forked from upstream-mirrors/OpenTracks
Code review fixes
This commit is contained in:
@@ -122,10 +122,7 @@ public class GDataWrapper {
|
|||||||
private boolean runCommon(final AuthenticatedFunction function,
|
private boolean runCommon(final AuthenticatedFunction function,
|
||||||
final QueryFunction query) {
|
final QueryFunction query) {
|
||||||
for (int i = 0; i <= AUTH_TOKEN_INVALIDATE_REFRESH_NUM_RETRIES; i++) {
|
for (int i = 0; i <= AUTH_TOKEN_INVALIDATE_REFRESH_NUM_RETRIES; i++) {
|
||||||
if (!runOne(function, query)) {
|
runOne(function, query);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errorType == ERROR_NO_ERROR) {
|
if (errorType == ERROR_NO_ERROR) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -145,10 +142,8 @@ public class GDataWrapper {
|
|||||||
/**
|
/**
|
||||||
* Execute a given function or query. If one is executed, errorType and
|
* Execute a given function or query. If one is executed, errorType and
|
||||||
* errorMessage will contain the result/status of the function/query.
|
* errorMessage will contain the result/status of the function/query.
|
||||||
*
|
|
||||||
* @return true if function or query was non-null. false if both were null.
|
|
||||||
*/
|
*/
|
||||||
private boolean runOne(final AuthenticatedFunction function,
|
private void runOne(final AuthenticatedFunction function,
|
||||||
final QueryFunction query) {
|
final QueryFunction query) {
|
||||||
try {
|
try {
|
||||||
if (function != null) {
|
if (function != null) {
|
||||||
@@ -156,12 +151,13 @@ public class GDataWrapper {
|
|||||||
} else if (query != null) {
|
} else if (query != null) {
|
||||||
query.query(gdataServiceClient);
|
query.query(gdataServiceClient);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
throw new IllegalArgumentException(
|
||||||
|
"invalid invocation of runOne; one of function/query " +
|
||||||
|
"must be non-null");
|
||||||
}
|
}
|
||||||
|
|
||||||
errorType = ERROR_NO_ERROR;
|
errorType = ERROR_NO_ERROR;
|
||||||
errorMessage = null;
|
errorMessage = null;
|
||||||
return true;
|
|
||||||
|
|
||||||
} catch (AuthenticationException e) {
|
} catch (AuthenticationException e) {
|
||||||
Log.e(MyTracksConstants.TAG, "Exception", e);
|
Log.e(MyTracksConstants.TAG, "Exception", e);
|
||||||
@@ -196,8 +192,6 @@ public class GDataWrapper {
|
|||||||
errorType = ERROR_CONFLICT;
|
errorType = ERROR_CONFLICT;
|
||||||
errorMessage = e.getMessage();
|
errorMessage = e.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -209,6 +203,8 @@ public class GDataWrapper {
|
|||||||
*/
|
*/
|
||||||
private boolean invalidateAndRefreshAuthToken() {
|
private boolean invalidateAndRefreshAuthToken() {
|
||||||
Log.d(MyTracksConstants.TAG, "Retrying due to auth failure");
|
Log.d(MyTracksConstants.TAG, "Retrying due to auth failure");
|
||||||
|
// This FutureTask doesn't do anything -- it exists simply to be
|
||||||
|
// blocked upon using get().
|
||||||
FutureTask<?> whenFinishedFuture = new FutureTask<Object>(new Runnable() {
|
FutureTask<?> whenFinishedFuture = new FutureTask<Object>(new Runnable() {
|
||||||
public void run() {}
|
public void run() {}
|
||||||
}, null);
|
}, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user