Skip to content

Instantly share code, notes, and snippets.

@hiranya911
Created December 2, 2017 21:07
Show Gist options
  • Save hiranya911/34b6ebbf4460c091b8bf0544d1877292 to your computer and use it in GitHub Desktop.
Save hiranya911/34b6ebbf4460c091b8bf0544d1877292 to your computer and use it in GitHub Desktop.
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutureCallback;
import com.google.api.core.ApiFutures;
@Deprecated
public void addTaskCallbacks(Task<String> task) {
task.addOnSuccessListener(new OnSuccessListener<String>() {
@Override
public void onSuccess(String result) {
System.out.println("Operation completed with result: " + result);
}
});
task.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
System.out.println("Operation failed with error: " + e);
}
});
}
public void addFutureCallbacks(ApiFuture<String> future) {
ApiFutures.addCallback(future, new ApiFutureCallback<String>() {
@Override
public void onSuccess(String result) {
System.out.println("Operation completed with result: " + result);
}
@Override
public void onFailure(Throwable t) {
System.out.println("Operation failed with error: " + t);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment